1 #ifndef _COLOR_SPINOR_FIELD_H
2 #define _COLOR_SPINOR_FIELD_H
27 }
else if (nSpin == 2) {
29 }
else if (nSpin == 1) {
39 }
else if (nSpin == 2) {
41 }
else if (nSpin == 1) {
173 bool force_native =
false)
239 for (
int d = 0; d <
nDim; d++)
x[d] = X[d];
340 class cpuColorSpinorField;
341 class cudaColorSpinorField;
484 const int*
X()
const {
return x; }
485 int X(
int d)
const {
return x[d]; }
500 void*
V() {
return v;}
501 const void*
V()
const {
return v;}
504 virtual const void*
Ghost2()
const {
return nullptr; }
521 void exchange(
void **
ghost,
void **sendbuf,
int nFace=1)
const;
538 const MemoryLocation *halo_location=
nullptr,
bool gdr_send=
false,
bool gdr_recv=
false,
582 void*
Ghost(
const int i);
583 const void*
Ghost(
const int i)
const;
585 const void*
GhostNorm(
const int i)
const;
590 void*
const*
Ghost()
const;
691 mutable bool ghostTexInit;
696 mutable void *ghost_field_tex[4];
751 void createComms(
int nFace,
bool spin_project=
true);
780 bool spin_project,
double a = 0,
double b = 0,
double c = 0,
int shmem = 0);
842 bool spin_project =
true,
double a = 0,
double b = 0,
double c = 0,
int shmem = 0);
845 qudaStream_t *stream_p,
const bool zeroCopyPack =
false);
872 bool remote_write =
false);
885 bool gdr_recv =
false);
898 bool gdr_recv =
false);
911 bool gdr_recv =
false);
941 const MemoryLocation *halo_location=
nullptr,
bool gdr_send=
false,
bool gdr_recv=
false,
1067 const MemoryLocation *halo_location=
nullptr,
bool gdr_send=
false,
bool gdr_recv=
false,
1083 void *dstNorm=0,
void*srcNorm=0);
1148 errorQuda(
"PCTypes %d %d do not match (%s:%d in %s())\n", a.
PCType(), b.
PCType(), file, line, func);
1159 template <
typename... Args>
1166 #define checkPCType(...) PCType_(__func__, __FILE__, __LINE__, __VA_ARGS__)
1192 template <
typename... Args>
1199 #define checkOrder(...) Order_(__func__, __FILE__, __LINE__, __VA_ARGS__)
1213 errorQuda(
"Lengths %lu %lu do not match (%s:%d in %s())\n", a.
Length(), b.
Length(), file, line, func);
1224 template <
typename... Args>
1226 const Args &... args)
1228 return static_cast<int>(
Length_(func, file, line, a, b) &
Length_(func, file, line, a, args...));
1231 #define checkLength(...) Length_(__func__, __FILE__, __LINE__, __VA_ARGS__)
const DslashConstant & getDslashConstant() const
Get the dslash_constant structure from this field.
void exchange(void **ghost, void **sendbuf, int nFace=1) const
void fill(ColorSpinorParam &) const
void LatticeIndex(int *y, int i) const
int ghostFace[QUDA_MAX_DIM]
virtual void PrintVector(unsigned int x) const =0
void *const * Ghost() const
virtual const void * Ghost2() const
ColorSpinorField * CreateAlias(const ColorSpinorParam ¶m)
Create a field that aliases this field's storage. The alias field can use a different precision than ...
friend std::ostream & operator<<(std::ostream &out, const ColorSpinorField &)
int ComponentStride() const
virtual ColorSpinorField & operator=(const ColorSpinorField &)
void * ghost_buf[2 *QUDA_MAX_DIM]
QudaParity suggested_parity
QudaParity SuggestedParity() const
size_t ComponentBytes() const
const ColorSpinorField & Odd() const
CompositeColorSpinorFieldDescriptor composite_descr
used for deflation eigenvector sets etc.:
size_t TotalBytes() const
size_t ComponentNormBytes() const
size_t GhostFaceBytes(int i) const
ColorSpinorField(const ColorSpinorField &)
CompositeColorSpinorField & Components()
size_t GhostOffset(const int dim, const int dir) const
QudaTwistFlavorType TwistFlavor() const
void setSuggestedParity(QudaParity suggested_parity)
QudaTwistFlavorType twistFlavor
ColorSpinorField * CreateFine(const int *geoblockSize, int spinBlockSize, int Nvec, QudaPrecision precision=QUDA_INVALID_PRECISION, QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION, QudaMemoryType mem_type=QUDA_MEMORY_INVALID)
Create a fine color-spinor field, using this field to set the meta data.
size_t GhostNormBytes() const
size_t ComponentRealLength() const
virtual int full_dim(int d) const
int ComponentVolume() const
QudaSiteOrder SiteOrder() const
CompositeColorSpinorField components
QudaGammaBasis gammaBasis
QudaSiteSubset SiteSubset() const
const int * GhostFace() const
size_t ComponentLength() const
size_t RealLength() const
size_t GhostBytes() const
void * ghost[2][QUDA_MAX_DIM]
static ColorSpinorField * Create(const ColorSpinorParam ¶m)
void reset(const ColorSpinorParam &)
void createGhostZone(int nFace, bool spin_project=true) const
static void checkField(const ColorSpinorField &, const ColorSpinorField &)
QudaPrecision ghost_precision_allocated
ColorSpinorField * CreateCoarse(const int *geoBlockSize, int spinBlockSize, int Nvec, QudaPrecision precision=QUDA_INVALID_PRECISION, QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION, QudaMemoryType mem_Type=QUDA_MEMORY_INVALID)
Create a coarse color-spinor field, using this field to set the meta data.
QudaFieldOrder fieldOrder
void OffsetIndex(int &i, int *y) const
int ComponentVolumeCB() const
void * GhostNorm(const int i)
friend class ColorSpinorParam
virtual void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr, const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false, QudaPrecision ghost_precision=QUDA_INVALID_PRECISION) const =0
QudaFieldOrder FieldOrder() const
const ColorSpinorField & Even() const
QudaGammaBasis GammaBasis() const
void PrintVector(unsigned int x_cb, unsigned int parity) const
Thin wrapper around PrintVector that takes in a checkerboard index and a parity instead of a full ind...
QudaSiteSubset siteSubset
ColorSpinorField & Component(const int idx) const
const void * Norm() const
int ghostFaceCB[QUDA_MAX_DIM]
void * ghostNorm[2][QUDA_MAX_DIM]
void setTuningString()
Set the vol_string and aux_string for use in tuning.
virtual void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)=0
virtual ~ColorSpinorField()
QudaPCType PCType() const
DslashConstant dslash_constant
const int * GhostFaceCB() const
QudaGammaBasis gammaBasis
virtual ~ColorSpinorParam()
QudaFieldLocation location
QudaParity suggested_parity
void setPrecision(QudaPrecision precision, QudaPrecision ghost_precision=QUDA_INVALID_PRECISION, bool force_native=false)
ColorSpinorParam(ColorSpinorParam &cpuParam, QudaInvertParam &inv_param, QudaFieldLocation location=QUDA_CUDA_FIELD_LOCATION)
bool is_composite
for deflation solvers:
ColorSpinorParam(void *V, QudaInvertParam &inv_param, const int *X, const bool pc_solution, QudaFieldLocation location=QUDA_CPU_FIELD_LOCATION)
QudaFieldOrder fieldOrder
QudaTwistFlavorType twistFlavor
size_t ghost_offset[QUDA_MAX_DIM][2]
QudaPrecision ghost_precision
static void * ghost_pinned_recv_buffer_hd[2]
size_t ghost_face_bytes[QUDA_MAX_DIM]
static void * ghost_recv_buffer_d[2]
Class declaration to initialize and hold CURAND RNG states.
virtual void copy_from_buffer(void *buffer)
Copy all contents of the field from a host buffer to this field.
static int initGhostFaceBuffer
void unpackGhost(void *ghost_spinor, const int dim, const QudaDirection dir, const int dagger)
virtual ~cpuColorSpinorField()
static void freeGhostBuffer(void)
void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr, const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false, QudaPrecision ghost_precision=QUDA_INVALID_PRECISION) const
This is a unified ghost exchange function for doing a complete halo exchange regardless of the type o...
static size_t ghostFaceBytes[QUDA_MAX_DIM]
static void * fwdGhostFaceSendBuffer[QUDA_MAX_DIM]
virtual void copy_to_buffer(void *buffer) const
Copy all contents of the field to a host buffer.
void backup() const
Backs up the cpuColorSpinorField.
static void * fwdGhostFaceBuffer[QUDA_MAX_DIM]
void packGhost(void **ghost, const QudaParity parity, const int nFace, const int dagger) const
void restore() const
Restores the cpuColorSpinorField.
static void * backGhostFaceSendBuffer[QUDA_MAX_DIM]
void copy(const cpuColorSpinorField &)
ColorSpinorField & operator=(const ColorSpinorField &)
void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)
static int Compare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, const int resolution=1)
Perform a component by component comparison of two color-spinor fields. In doing we normalize with re...
cpuColorSpinorField(const cpuColorSpinorField &)
static void * backGhostFaceBuffer[QUDA_MAX_DIM]
void PrintVector(unsigned int x) const
void allocateGhostBuffer(int nFace) const
Allocate the ghost buffers.
friend std::ostream & operator<<(std::ostream &out, const cudaColorSpinorField &)
void createComms(int nFace, bool spin_project=true)
Create the communication handlers and buffers.
void prefetch(QudaFieldLocation mem_space, qudaStream_t stream=0) const
If managed memory and prefetch is enabled, prefetch the spinor, the norm field (as appropriate),...
virtual void copy_from_buffer(void *buffer)
Copy all contents of the field from a host buffer to this field.
cudaColorSpinorField(const cudaColorSpinorField &)
void recvStart(int nFace, int dir, int dagger=0, qudaStream_t *stream_p=nullptr, bool gdr=false)
Initiate halo communication receive.
virtual ~cudaColorSpinorField()
void commsWait(int nFace, int d, int dagger=0, qudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Wait on halo communication to complete.
void pack(int nFace, int parity, int dagger, int stream_idx, MemoryLocation location[], MemoryLocation location_label, bool spin_project=true, double a=0, double b=0, double c=0, int shmem=0)
void CopySubset(cudaColorSpinorField &dst, const int range, const int first_element=0) const
void streamInit(qudaStream_t *stream_p)
void sendGhost(void *ghost_spinor, const int nFace, const int dim, const QudaDirection dir, const int dagger, qudaStream_t *stream)
const void * Ghost2() const
void packGhostExtended(const int nFace, const int R[], const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, qudaStream_t *stream, bool zero_copy=false)
ColorSpinorField & operator=(const ColorSpinorField &)
void sendStart(int nFace, int d, int dagger=0, qudaStream_t *stream_p=nullptr, bool gdr=false, bool remote_write=false)
Initiate halo communication sending.
cudaColorSpinorField & Component(const int idx) const
for composite fields:
void scatterExtended(int nFace, int parity, int dagger, int dir)
void unpackGhostExtended(const void *ghost_spinor, const int nFace, const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, qudaStream_t *stream, bool zero_copy)
void backup() const
Backs up the cudaColorSpinorField.
void commsStart(int nFace, int d, int dagger=0, qudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Initiate halo communication.
virtual void copy_to_buffer(void *buffer) const
Copy all contents of the field to a host buffer.
void gather(int nFace, int dagger, int dir, qudaStream_t *stream_p=NULL)
int commsQuery(int nFace, int d, int dagger=0, qudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Non-blocking query if the halo communication has completed.
void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)
CompositeColorSpinorField & Components() const
void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr, const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false, QudaPrecision ghost_precision=QUDA_INVALID_PRECISION) const
This is a unified ghost exchange function for doing a complete halo exchange regardless of the type o...
void copy(const cudaColorSpinorField &)
void scatter(int nFace, int dagger, int dir, qudaStream_t *stream_p)
void switchBufferPinned()
void restore() const
Restores the cudaColorSpinorField.
void packGhost(const int nFace, const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, qudaStream_t *stream, MemoryLocation location[2 *QUDA_MAX_DIM], MemoryLocation location_label, bool spin_project, double a=0, double b=0, double c=0, int shmem=0)
Packs the cudaColorSpinorField's ghost zone.
void allocateGhostBuffer(int nFace, bool spin_project=true) const
Allocate the ghost buffers.
void packExtended(const int nFace, const int R[], const int parity, const int dagger, const int dim, qudaStream_t *stream_p, const bool zeroCopyPack=false)
void PrintVector(unsigned int x) const
void unpackGhost(const void *ghost_spinor, const int nFace, const int dim, const QudaDirection dir, const int dagger, qudaStream_t *stream)
QudaTwistFlavorType twist_flavor
QudaDslashType dslash_type
cpuColorSpinorField * spinor
QudaInvertParam inv_param
enum QudaSiteOrder_s QudaSiteOrder
enum QudaPrecision_s QudaPrecision
@ QUDA_TWISTED_MASS_DSLASH
@ QUDA_DOMAIN_WALL_DSLASH
@ QUDA_MOBIUS_DWF_EOFA_DSLASH
@ QUDA_DOMAIN_WALL_4D_DSLASH
@ QUDA_CUDA_FIELD_LOCATION
@ QUDA_CPU_FIELD_LOCATION
@ QUDA_INVALID_FIELD_LOCATION
enum QudaTwistFlavorType_s QudaTwistFlavorType
enum QudaDirection_s QudaDirection
@ QUDA_PARITY_SITE_SUBSET
@ QUDA_DEGRAND_ROSSI_GAMMA_BASIS
@ QUDA_INVALID_GAMMA_BASIS
enum QudaPCType_s QudaPCType
@ QUDA_QDPJIT_DIRAC_ORDER
@ QUDA_INTERNAL_DIRAC_ORDER
@ QUDA_TIFR_PADDED_DIRAC_ORDER
@ QUDA_CPS_WILSON_DIRAC_ORDER
enum QudaNoiseType_s QudaNoiseType
enum QudaFieldOrder_s QudaFieldOrder
enum QudaSiteSubset_s QudaSiteSubset
enum QudaFieldLocation_s QudaFieldLocation
enum QudaFieldCreate_s QudaFieldCreate
@ QUDA_MATPC_ODD_ODD_ASYMMETRIC
@ QUDA_MATPC_EVEN_EVEN_ASYMMETRIC
enum QudaMatPCType_s QudaMatPCType
@ QUDA_EVEN_ODD_SITE_ORDER
@ QUDA_INVALID_SITE_ORDER
@ QUDA_ODD_EVEN_SITE_ORDER
enum QudaMemoryType_s QudaMemoryType
enum QudaSourceType_s QudaSourceType
@ QUDA_INVALID_FIELD_ORDER
@ QUDA_FLOAT2_FIELD_ORDER
@ QUDA_SPACE_COLOR_SPIN_FIELD_ORDER
@ QUDA_FLOAT4_FIELD_ORDER
@ QUDA_FLOAT8_FIELD_ORDER
@ QUDA_QDPJIT_FIELD_ORDER
@ QUDA_PADDED_SPACE_SPIN_COLOR_FIELD_ORDER
@ QUDA_SPACE_SPIN_COLOR_FIELD_ORDER
enum QudaGammaBasis_s QudaGammaBasis
@ QUDA_INVALID_FIELD_CREATE
@ QUDA_REFERENCE_FIELD_CREATE
@ QUDA_TWIST_NONDEG_DOUBLET
enum QudaParity_s QudaParity
QudaPrecision & cuda_prec
void init()
Create the BLAS context.
void destroy()
Destroy the BLAS context.
bool isNative(QudaFieldOrder order, QudaPrecision precision, int nSpin, int nColor)
void genericPackGhost(void **ghost, const ColorSpinorField &a, QudaParity parity, int nFace, int dagger, MemoryLocation *destination=nullptr)
Generic ghost packing routine.
QudaFieldOrder Order_(const char *func, const char *file, int line, const ColorSpinorField &a, const ColorSpinorField &b)
Helper function for determining if the order of the fields is the same.
void copyGenericColorSpinor(ColorSpinorField &dst, const ColorSpinorField &src, QudaFieldLocation location, void *Dst=0, void *Src=0, void *dstNorm=0, void *srcNorm=0)
void exchangeExtendedGhost(cudaColorSpinorField *spinor, int R[], int parity, qudaStream_t *stream_p)
void genericPrintVector(const cpuColorSpinorField &a, unsigned int x)
void genericCudaPrintVector(const cudaColorSpinorField &a, unsigned x)
QudaPCType PCType_(const char *func, const char *file, int line, const ColorSpinorField &a, const ColorSpinorField &b)
Helper function for determining if the preconditioning type of the fields is the same.
std::vector< ColorSpinorField * > CompositeColorSpinorField
int Length_(const char *func, const char *file, int line, const ColorSpinorField &a, const ColorSpinorField &b)
Helper function for determining if the length of the fields is the same.
void copyExtendedColorSpinor(ColorSpinorField &dst, const ColorSpinorField &src, QudaFieldLocation location, const int parity, void *Dst, void *Src, void *dstNorm, void *srcNorm)
void genericSource(cpuColorSpinorField &a, QudaSourceType sourceType, int x, int s, int c)
void copyFieldOffset(CloverField &out, const CloverField &in, CommKey offset, QudaPCType pc_type)
This function is used for copying from a source clover field to a destination clover field with an of...
constexpr QudaParity impliedParityFromMatPC(const QudaMatPCType &matpc_type)
Helper function for getting the implied spinor parity from a matrix preconditioning type.
void spinorNoise(ColorSpinorField &src, RNG &randstates, QudaNoiseType type)
Generate a random noise spinor. This variant allows the user to manage the RNG state.
int genericCompare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, int tol)
Main header file for the QUDA library.
cudaStream_t qudaStream_t
#define QUDA_MAX_DIM
Maximum number of dimensions supported by QUDA. In practice, no routines make use of more than 5.
QudaDslashType dslash_type
QudaDiracFieldOrder dirac_order
CompositeColorSpinorFieldDescriptor()
CompositeColorSpinorFieldDescriptor(const CompositeColorSpinorFieldDescriptor &descr)
CompositeColorSpinorFieldDescriptor(bool is_composite, int dim, bool is_component=false, int id=0)
Constants used by dslash and packing kernels.
int_fastdiv Xh[QUDA_MAX_DIM]
int ghostFace[QUDA_MAX_DIM+1]
int ghostFaceCB[QUDA_MAX_DIM+1]
int_fastdiv X[QUDA_MAX_DIM]
QudaPrecision ghost_precision
QudaSiteSubset siteSubset