Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:lattice/quda into feature/tm_force
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyscientist committed Dec 2, 2023
2 parents b770a71 + 3d78e70 commit a6b85ac
Show file tree
Hide file tree
Showing 199 changed files with 5,350 additions and 6,025 deletions.
8 changes: 3 additions & 5 deletions include/blas_helper.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ namespace quda
{}

data_t(const ColorSpinorField &x) :
spinor(static_cast<store_t *>(const_cast<ColorSpinorField &>(x).V())),
stride(x.VolumeCB()),
cb_offset(x.Bytes() / (2 * sizeof(store_t) * N))
spinor(x.data<store_t *>()), stride(x.VolumeCB()), cb_offset(x.Bytes() / (2 * sizeof(store_t) * N))
{}
};

Expand Down Expand Up @@ -141,8 +139,8 @@ namespace quda
{}

data_t(const ColorSpinorField &x) :
spinor(static_cast<store_t *>(const_cast<ColorSpinorField &>(x).V())),
norm(static_cast<norm_t *>(const_cast<ColorSpinorField &>(x).Norm())),
spinor(x.data<store_t *>()),
norm(static_cast<norm_t *>(x.Norm())),
stride(x.VolumeCB()),
cb_offset(x.Bytes() / (2 * sizeof(store_t) * N)),
cb_norm_offset(x.Bytes() / (2 * sizeof(norm_t)))
Expand Down
5 changes: 1 addition & 4 deletions include/blas_quda.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ namespace quda {

void setParam(int kernel, int prec, int threads, int blocks);

extern unsigned long long flops;
extern unsigned long long bytes;

inline void zero(cvector_ref<ColorSpinorField> &x)
{
for (auto i = 0u; i < x.size(); i++) x[i].zero();
}

inline void copy(ColorSpinorField &dst, const ColorSpinorField &src)
{
if (dst.V() == src.V()) {
if (dst.data() == src.data()) {
// check the fields are equivalent else error
if (ColorSpinorField::are_compatible(dst, src))
return;
Expand Down
21 changes: 12 additions & 9 deletions include/clover_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ namespace quda {
int nColor = 0;
int nSpin = 0;

void *clover = nullptr;
void *cloverInv = nullptr;
quda_ptr clover = {};
quda_ptr cloverInv = {};

bool inverse = false;
double diagonal = 0.0;
array<double, 2> max = {};

Expand Down Expand Up @@ -213,12 +214,18 @@ namespace quda {

public:
CloverField(const CloverFieldParam &param);
virtual ~CloverField();

static CloverField *Create(const CloverFieldParam &param);

void* V(bool inverse=false) { return inverse ? cloverInv : clover; }
const void* V(bool inverse=false) const { return inverse ? cloverInv : clover; }
template <typename T = void *> auto data(bool inverse = false) const
{
return inverse ? reinterpret_cast<T>(cloverInv.data()) : reinterpret_cast<T>(clover.data());
}

/**
@return whether the inverse is explicitly been allocated
*/
bool Inverse() const { return inverse; }

/**
@return diagonal scaling factor applied to the identity
Expand Down Expand Up @@ -406,10 +413,6 @@ namespace quda {
*/
void copy_from_buffer(void *buffer);

friend class DiracClover;
friend class DiracCloverPC;
friend class DiracTwistedClover;
friend class DiracTwistedCloverPC;
};

/**
Expand Down
14 changes: 7 additions & 7 deletions include/clover_field_order.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ namespace quda {
static constexpr int N = nColor * nSpin / 2;
reconstruct_t<Float, N * N, clover::reconstruct()> recon;
FloatNAccessor(const CloverField &A, bool inverse = false) :
a(static_cast<Float *>(const_cast<void *>(A.V(inverse)))),
a(A.Bytes() ? A.data<Float *>(inverse) : nullptr),
stride(A.VolumeCB()),
offset_cb(A.Bytes() / (2 * sizeof(Float))),
compressed_block_size(A.compressed_block_size()),
Expand Down Expand Up @@ -403,7 +403,7 @@ namespace quda {
const int N = nSpin * nColor / 2;
const complex<Float> zero;
Accessor(const CloverField &A, bool inverse = false) :
a(static_cast<Float *>(const_cast<void *>(A.V(inverse)))),
a(A.Bytes() ? A.data<Float *>(inverse) : nullptr),
offset_cb(A.Bytes() / (2 * sizeof(Float))),
zero(complex<Float>(0.0, 0.0))
{
Expand Down Expand Up @@ -639,7 +639,7 @@ namespace quda {
if (clover.max_element(is_inverse) == 0.0 && isFixed<Float>::value)
errorQuda("%p max_element(%d) appears unset", &clover, is_inverse);
if (clover.Diagonal() == 0.0 && clover.Reconstruct()) errorQuda("%p diagonal appears unset", &clover);
this->clover = clover_ ? clover_ : (Float *)(clover.V(is_inverse));
this->clover = clover_ ? clover_ : clover.data<Float *>(is_inverse);
}

QudaTwistFlavorType TwistFlavor() const { return twist_flavor; }
Expand Down Expand Up @@ -844,7 +844,7 @@ namespace quda {
if (clover.Order() != QUDA_PACKED_CLOVER_ORDER) {
errorQuda("Invalid clover order %d for this accessor", clover.Order());
}
this->clover = clover_ ? clover_ : (Float *)(clover.V(inverse));
this->clover = clover_ ? clover_ : clover.data<Float *>(inverse);
}

QudaTwistFlavorType TwistFlavor() const { return twist_flavor; }
Expand Down Expand Up @@ -892,8 +892,8 @@ namespace quda {
if (clover.Order() != QUDA_QDPJIT_CLOVER_ORDER) {
errorQuda("Invalid clover order %d for this accessor", clover.Order());
}
offdiag = clover_ ? ((Float **)clover_)[0] : ((Float **)clover.V(inverse))[0];
diag = clover_ ? ((Float **)clover_)[1] : ((Float **)clover.V(inverse))[1];
offdiag = clover_ ? ((Float **)clover_)[0] : clover.data<Float **>(inverse)[0];
diag = clover_ ? ((Float **)clover_)[1] : clover.data<Float **>(inverse)[1];
}

QudaTwistFlavorType TwistFlavor() const { return twist_flavor; }
Expand Down Expand Up @@ -970,7 +970,7 @@ namespace quda {
if (clover.Order() != QUDA_BQCD_CLOVER_ORDER) {
errorQuda("Invalid clover order %d for this accessor", clover.Order());
}
this->clover[0] = clover_ ? clover_ : (Float *)(clover.V(inverse));
this->clover[0] = clover_ ? clover_ : clover.data<Float *>(inverse);
this->clover[1] = (Float *)((char *)this->clover[0] + clover.Bytes() / 2);
}

Expand Down
77 changes: 26 additions & 51 deletions include/color_spinor_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,13 @@ namespace quda
}
};

class ColorSpinorParam : public LatticeFieldParam
{

public:
struct ColorSpinorParam : public LatticeFieldParam {
int nColor = 0; // Number of colors of the field
int nSpin = 0; // =1 for staggered, =2 for coarse Dslash, =4 for 4d spinor
int nVec = 1; // number of packed vectors (for multigrid transfer operator)

QudaTwistFlavorType twistFlavor = QUDA_TWIST_INVALID; // used by twisted mass

QudaSiteOrder siteOrder = QUDA_INVALID_SITE_ORDER; // defined for full fields

QudaFieldOrder fieldOrder = QUDA_INVALID_FIELD_ORDER; // Float, Float2, Float4 etc.
QudaGammaBasis gammaBasis = QUDA_INVALID_GAMMA_BASIS;
QudaFieldCreate create = QUDA_INVALID_FIELD_CREATE;
Expand Down Expand Up @@ -179,7 +174,6 @@ namespace quda
ColorSpinorParam() = default;

// used to create cpu params

ColorSpinorParam(void *V, QudaInvertParam &inv_param, const lat_dim_t &X, const bool pc_solution,
QudaFieldLocation location = QUDA_CPU_FIELD_LOCATION) :
LatticeFieldParam(4, X, 0, location, inv_param.cpu_prec),
Expand All @@ -188,20 +182,12 @@ namespace quda
|| inv_param.dslash_type == QUDA_LAPLACE_DSLASH) ?
1 :
4),
nVec(1),
twistFlavor(inv_param.twist_flavor),
siteOrder(QUDA_INVALID_SITE_ORDER),
fieldOrder(QUDA_INVALID_FIELD_ORDER),
gammaBasis(inv_param.gamma_basis),
create(QUDA_REFERENCE_FIELD_CREATE),
pc_type(inv_param.dslash_type == QUDA_DOMAIN_WALL_DSLASH ? QUDA_5D_PC : QUDA_4D_PC),
v(V),
is_composite(false),
composite_dim(0),
is_component(false),
component_id(0)
v(V)
{

if (nDim > QUDA_MAX_DIM) errorQuda("Number of dimensions too great");
for (int d = 0; d < nDim; d++) x[d] = X[d];

Expand Down Expand Up @@ -343,8 +329,7 @@ namespace quda

size_t length = 0; // length including pads, but not norm zone

void *v = nullptr; // the field elements
void *v_h = nullptr; // the field elements
quda_ptr v = {}; // the field elements
size_t norm_offset = 0; /** offset to the norm (if applicable) */

// multi-GPU parameters
Expand Down Expand Up @@ -441,6 +426,12 @@ namespace quda
*/
ColorSpinorField &operator=(ColorSpinorField &&field);

/**
@brief Returns if the object is empty (not initialized)
@return true if the object has not been allocated, otherwise false
*/
bool empty() const { return !init; }

/**
@brief Copy the source field contents into this
@param[in] src Source from which we are copying
Expand Down Expand Up @@ -477,37 +468,19 @@ namespace quda
/**
@brief Return pointer to the field allocation
*/
void *V()
{
if (ghost_only) errorQuda("Not defined for ghost-only field");
return v;
}

/**
@brief Return pointer to the field allocation
*/
const void *V() const
{
if (ghost_only) errorQuda("Not defined for ghost-only field");
return v;
}

/**
@brief Return pointer to the norm base pointer in the field allocation
*/
void *Norm()
template <typename T = void *> auto data() const
{
if (ghost_only) errorQuda("Not defined for ghost-only field");
return static_cast<char *>(v) + norm_offset;
return reinterpret_cast<T>(v.data());
}

/**
@brief Return pointer to the norm base pointer in the field allocation
*/
const void *Norm() const
void *Norm() const
{
if (ghost_only) errorQuda("Not defined for ghost-only field");
return static_cast<char *>(v) + norm_offset;
return static_cast<char *>(v.data()) + norm_offset;
}

size_t NormOffset() const { return norm_offset; }
Expand Down Expand Up @@ -938,7 +911,7 @@ namespace quda
static void test_compatible_weak(const ColorSpinorField &a, const ColorSpinorField &b);

friend std::ostream &operator<<(std::ostream &out, const ColorSpinorField &);
friend class ColorSpinorParam;
friend struct ColorSpinorParam;
};

/**
Expand Down Expand Up @@ -1022,28 +995,30 @@ namespace quda

/**
@brief Generate a random noise spinor. This variant allows the user to manage the RNG state.
@param src The colorspinorfield
@param randstates Random state
@param type The type of noise to create (QUDA_NOISE_GAUSSIAN or QUDA_NOISE_UNIFORM)
@param[out] src The colorspinorfield
@param[in,out] randstates Random state
@param[in] type The type of noise to create (QUDA_NOISE_GAUSSIAN or QUDA_NOISE_UNIFORM)
*/
void spinorNoise(ColorSpinorField &src, RNG &randstates, QudaNoiseType type);

/**
@brief Generate a random noise spinor. This variant just
requires a seed and will create and destroy the random number state.
@param src The colorspinorfield
@param seed Seed
@param type The type of noise to create (QUDA_NOISE_GAUSSIAN or QUDA_NOISE_UNIFORM)
@param[out] src The colorspinorfield
@param[in] seed Seed
@param[in] type The type of noise to create (QUDA_NOISE_GAUSSIAN or QUDA_NOISE_UNIFORM)
*/
void spinorNoise(ColorSpinorField &src, unsigned long long seed, QudaNoiseType type);

/**
@brief Generate a set of diluted color spinors from a single source.
@param v Diluted vector set
@param src The input source
@param type The type of dilution to apply (QUDA_DILUTION_SPIN_COLOR, etc.)
@param[out] v Diluted vector set
@param[in] src The input source
@param[in] type The type of dilution to apply (QUDA_DILUTION_SPIN_COLOR, etc.)
@param[in] local_block The local block size to use when using QUDA_DILUTION_BLOCK dilution
*/
void spinorDilute(std::vector<ColorSpinorField> &v, const ColorSpinorField &src, QudaDilutionType type);
void spinorDilute(std::vector<ColorSpinorField> &v, const ColorSpinorField &src, QudaDilutionType type,
const lat_dim_t &local_block = {});

/**
@brief Helper function for determining if the preconditioning
Expand Down
Loading

0 comments on commit a6b85ac

Please sign in to comment.