QUDA  0.9.0
color_spinor_field.h
Go to the documentation of this file.
1 #ifndef _COLOR_SPINOR_FIELD_H
2 #define _COLOR_SPINOR_FIELD_H
3 
4 #include <quda_internal.h>
5 #include <quda.h>
6 
7 #include <iostream>
8 
9 #include <lattice_field.h>
10 #include <random_quda.h>
11 #include <fast_intdiv.h>
12 
13 namespace quda {
14 
15  enum MemoryLocation { Device = 1, Host = 2, Remote = 4 };
16 
17  struct FullClover;
18 
20  typedef std::vector<ColorSpinorField*> CompositeColorSpinorField;
21 
30 
31  bool is_composite; //set to 'false' for a regular spinor field
32  bool is_component; //set to 'true' if we want to work with an individual component (otherwise will work with the whole set)
33 
34  int dim;//individual component has dim = 0
35  int id;
36 
37  int volume; // volume of a single eigenvector
38  int volumeCB; // CB volume of a single eigenvector
39  int stride; // stride of a single eigenvector
40  size_t real_length; // physical length of a single eigenvector
41  size_t length; // length including pads (but not ghost zones)
42 
43  size_t bytes; // size in bytes of spinor field
44  size_t norm_bytes; // makes no sense but let's keep it...
45 
47  : is_composite(false), is_component(false), dim(0), id(0), volume(0), volumeCB(0),
48  stride(0), real_length(0), length(0), bytes(0), norm_bytes(0) {};
49 
52  stride(0), real_length(0), length(0), bytes(0), norm_bytes(0)
53  {
54  if(is_composite && is_component) errorQuda("\nComposite type is not implemented.\n");
55  else if(is_composite && dim == 0) is_composite = false;
56  }
57 
59  {
60  is_composite = descr.is_composite;
61  is_component = descr.is_component;
62 
63  if(is_composite && is_component) errorQuda("\nComposite type is not implemented.\n");
64 
65  dim = descr.dim;
66  id = descr.id;
67 
68  volume = descr.volume;
69  volumeCB = descr.volumeCB;
70  stride = descr.stride; // stride of a single eigenvector
71  real_length = descr.real_length; // physical length of a single eigenvector
72  length = descr.length; // length including pads (but not ghost zones)
73 
74  bytes = descr.bytes; // size in bytes of spinor field
75  norm_bytes = descr.norm_bytes; // makes no sense but let's keep it...
76  }
77 
78  };
79 
81 
82  public:
83  QudaFieldLocation location; // where are we storing the field (CUDA or CPU)?
84 
85  int nColor; // Number of colors of the field
86  int nSpin; // =1 for staggered, =2 for coarse Dslash, =4 for 4d spinor
87 
88  QudaTwistFlavorType twistFlavor; // used by twisted mass
89 
90  QudaSiteOrder siteOrder; // defined for full fields
91 
92  QudaFieldOrder fieldOrder; // Float, Float2, Float4 etc.
95 
96  QudaDWFPCType PCtype; // used to select preconditioning method in DWF
97 
98  void *v; // pointer to field
99  void *norm;
100 
103  int composite_dim; //e.g., number of eigenvectors in the set
105  int component_id; //eigenvector index
106 
108 
114  is_composite(false), composite_dim(0), is_component(false), component_id(0) { ; }
115 
116  // used to create cpu params
117  ColorSpinorParam(void *V, QudaInvertParam &inv_param, const int *X, const bool pc_solution,
128  v(V), is_composite(false), composite_dim(0), is_component(false), component_id(0) {
129 
130  if (nDim > QUDA_MAX_DIM) errorQuda("Number of dimensions too great");
131  for (int d=0; d<nDim; d++) x[d] = X[d];
132 
133  if (!pc_solution) {
135  } else {
136  x[0] /= 2; // X defined the full lattice dimensions
138  }
139 
143  nDim++;
144  x[4] = inv_param.Ls;
146  nDim++;
147  x[4] = 2;//for two flavors
149  nDim++;
150  x[4] = inv_param.Ls;
151  }
152 
163  } else if (inv_param.dirac_order == QUDA_DIRAC_ORDER) {
172  } else {
173  errorQuda("Dirac order %d not supported", inv_param.dirac_order);
174  }
175  }
176 
177  // normally used to create cuda param from a cpu param
180  : LatticeFieldParam(cpuParam.nDim, cpuParam.x, inv_param.sp_pad, inv_param.cuda_prec),
181  location(location), nColor(cpuParam.nColor), nSpin(cpuParam.nSpin), twistFlavor(cpuParam.twistFlavor),
185  {
186  siteSubset = cpuParam.siteSubset;
189  }
190 
198  // is the current status in native field order?
199  bool native = false;
200  if ( ((this->precision == QUDA_DOUBLE_PRECISION || nSpin==1 || nSpin==2) &&
202  ((this->precision == QUDA_SINGLE_PRECISION || this->precision == QUDA_HALF_PRECISION) &&
203  (nSpin==4) && fieldOrder == QUDA_FLOAT4_FIELD_ORDER) ) { native = true; }
204 
205  this->precision = precision;
206 
207  // if this is a native field order, let's preserve that status, else keep the same field order
208  if (native) fieldOrder = (precision == QUDA_DOUBLE_PRECISION || nSpin == 1 || nSpin == 2) ?
210  }
211 
212  void print() {
213  printfQuda("nColor = %d\n", nColor);
214  printfQuda("nSpin = %d\n", nSpin);
215  printfQuda("twistFlavor = %d\n", twistFlavor);
216  printfQuda("nDim = %d\n", nDim);
217  for (int d=0; d<nDim; d++) printfQuda("x[%d] = %d\n", d, x[d]);
218  printfQuda("precision = %d\n", precision);
219  printfQuda("pad = %d\n", pad);
220  printfQuda("siteSubset = %d\n", siteSubset);
221  printfQuda("siteOrder = %d\n", siteOrder);
222  printfQuda("fieldOrder = %d\n", fieldOrder);
223  printfQuda("gammaBasis = %d\n", gammaBasis);
224  printfQuda("create = %d\n", create);
225  printfQuda("v = %lx\n", (unsigned long)v);
226  printfQuda("norm = %lx\n", (unsigned long)norm);
228  if(is_composite) printfQuda("Number of elements = %d\n", composite_dim);
229  }
230 
231  virtual ~ColorSpinorParam() {
232  }
233 
234  };
235 
236  class cpuColorSpinorField;
237  class cudaColorSpinorField;
238 
242  struct DslashConstant {
243  int Vh;
246  int Ls;
247 
250 
258 
260 
261  int X2X1;
262  int X3X2X1;
263  int X2X1mX1;
267 
269  };
270 
272 
273  private:
274  void create(int nDim, const int *x, int Nc, int Ns, QudaTwistFlavorType Twistflavor,
278  void destroy();
279 
280  protected:
281  bool init;
282  mutable bool init_ghost_zone;
283 
284  int nColor;
285  int nSpin;
286 
287  int nDim;
289 
290  int volume;
291  int volumeCB;
292  int pad;
293  int stride;
294 
296 
297  QudaDWFPCType PCtype; // used to select preconditioning method in DWF
298 
299  size_t real_length; // physical length only
300  size_t length; // length including pads, but not ghost zone - used for BLAS
301 
302  void *v; // the field elements
303  void *norm; // the normalization field
304 
305  void *v_h; // the field elements
306  void *norm_h; // the normalization field
307 
308  // multi-GPU parameters
309 
310  void* ghost[2][QUDA_MAX_DIM]; // pointers to the ghost regions - NULL by default
311  void* ghostNorm[2][QUDA_MAX_DIM]; // pointers to ghost norms - NULL by default
312 
313  mutable int ghostFace[QUDA_MAX_DIM];// the size of each face
314 
315  mutable void *ghost_buf[2*QUDA_MAX_DIM]; // wrapper that points to current ghost zone
316 
317  mutable DslashConstant dslash_constant; // constants used by dslash and packing kernels
318 
319  size_t bytes; // size in bytes of spinor field
320  size_t norm_bytes; // size in bytes of norm field
321 
326 
327  // in the case of full fields, these are references to the even / odd sublattices
330 
333  //
335 
341  void createGhostZone(int nFace, bool spin_project=true) const;
342 
343  // resets the above attributes based on contents of param
344  void reset(const ColorSpinorParam &);
345  void fill(ColorSpinorParam &) const;
346  static void checkField(const ColorSpinorField &, const ColorSpinorField &);
347 
348  char aux_string[TuneKey::aux_n]; // used as a label in the autotuner
349  void setTuningString(); // set the vol_string and aux_string for use in tuning
350 
351  public:
352  //ColorSpinorField();
355 
356  virtual ~ColorSpinorField();
357 
358  virtual ColorSpinorField& operator=(const ColorSpinorField &);
359 
360  int Ncolor() const { return nColor; }
361  int Nspin() const { return nSpin; }
363  int Ndim() const { return nDim; }
364  const int* X() const { return x; }
365  int X(int d) const { return x[d]; }
366  size_t RealLength() const { return real_length; }
367  size_t Length() const { return length; }
368  int Stride() const { return stride; }
369  int Volume() const { return volume; }
370  int VolumeCB() const { return siteSubset == QUDA_PARITY_SITE_SUBSET ? volume : volume / 2; }
371  int Pad() const { return pad; }
372  size_t Bytes() const { return bytes; }
373  size_t NormBytes() const { return norm_bytes; }
374  size_t GhostBytes() const { return ghost_bytes; }
375  size_t GhostNormBytes() const { return ghost_bytes; }
376  void PrintDims() const { printfQuda("dimensions=%d %d %d %d\n", x[0], x[1], x[2], x[3]); }
377 
378  inline const char *AuxString() const { return aux_string; }
379 
380  void* V() {return v;}
381  const void* V() const {return v;}
382  void* Norm(){return norm;}
383  const void* Norm() const {return norm;}
384  virtual const void* Ghost2() const { return nullptr; }
385 
394  void exchange(void **ghost, void **sendbuf, int nFace=1) const;
395 
409  virtual void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr,
410  const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false) const = 0;
411 
417  bool isNative() const;
418 
419  bool IsComposite() const { return composite_descr.is_composite; }
420  bool IsComponent() const { return composite_descr.is_component; }
421 
422  int CompositeDim() const { return composite_descr.dim; }
423  int ComponentId() const { return composite_descr.id; }
424  int ComponentVolume() const { return composite_descr.volume; }
426  int ComponentStride() const { return composite_descr.stride; }
427  size_t ComponentLength() const { return composite_descr.length; }
429 
430  size_t ComponentBytes() const { return composite_descr.bytes; }
431  size_t ComponentNormBytes() const { return composite_descr.norm_bytes; }
432 
433  QudaDWFPCType DWFPCtype() const { return PCtype; }
434 
436  QudaSiteOrder SiteOrder() const { return siteOrder; }
439 
440  const int *GhostFace() const { return ghostFace; }
441  int GhostOffset(const int i) const { return ghostOffset[i][0]; }
442  int GhostOffset(const int i, const int j) const { return ghostOffset[i][j]; }
443  int GhostNormOffset(const int i ) const { return ghostNormOffset[i][0]; }
444  int GhostNormOffset(const int i, const int j) const { return ghostNormOffset[i][j]; }
445 
446  void* Ghost(const int i);
447  const void* Ghost(const int i) const;
448  void* GhostNorm(const int i);
449  const void* GhostNorm(const int i) const;
450 
454  void* const* Ghost() const;
455 
460 
461  const ColorSpinorField& Even() const;
462  const ColorSpinorField& Odd() const;
463 
466 
467  ColorSpinorField& Component(const int idx) const;
468  ColorSpinorField& Component(const int idx);
469 
471  return components;
472  };
473 
474  virtual void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0) = 0;
475 
476  virtual void PrintVector(unsigned int x) = 0;
477 
483  void LatticeIndex(int *y, int i) const;
484 
490  void OffsetIndex(int &i, int *y) const;
491 
494  ColorSpinorField* CreateCoarse(const int *geoblockSize, int spinBlockSize, int Nvec,
496  ColorSpinorField* CreateFine(const int *geoblockSize, int spinBlockSize, int Nvec,
498 
499  friend std::ostream& operator<<(std::ostream &out, const ColorSpinorField &);
500  friend class ColorSpinorParam;
501  };
502 
503  // CUDA implementation
505 
506  friend class cpuColorSpinorField;
507 
508  private:
509  bool alloc; // whether we allocated memory
510  bool init;
511 
512  bool texInit; // whether a texture object has been created or not
513  mutable bool ghostTexInit; // whether the ghost texture object has been created
514 #ifdef USE_TEXTURE_OBJECTS
515  cudaTextureObject_t tex;
516  cudaTextureObject_t texNorm;
517  void createTexObject();
518  void destroyTexObject();
519  mutable cudaTextureObject_t ghostTex[4]; // these are double buffered and variants to host-mapped buffers
520  mutable cudaTextureObject_t ghostTexNorm[4];
521  void createGhostTexObject() const;
522  void destroyGhostTexObject() const;
523 #endif
524 
525  bool reference; // whether the field is a reference or not
526 
527  mutable void *ghost_field_tex[4]; // instance pointer to GPU halo buffer (used to check if static allocation has changed)
528 
529  void create(const QudaFieldCreate);
530  void destroy();
531  void copy(const cudaColorSpinorField &);
532 
533  void zeroPad();
534 
539  void copySpinorField(const ColorSpinorField &src);
540 
541  void loadSpinorField(const ColorSpinorField &src);
542  void saveSpinorField (ColorSpinorField &src) const;
543 
546 
547  public:
548 
549  //cudaColorSpinorField();
554  virtual ~cudaColorSpinorField();
555 
559 
560  void switchBufferPinned();
561 
567  void createComms(int nFace, bool spin_project=true);
568 
574  void allocateGhostBuffer(int nFace, bool spin_project=true) const;
575 
592  void packGhost(const int nFace, const QudaParity parity, const int dim, const QudaDirection dir, const int dagger,
593  cudaStream_t* stream, MemoryLocation location[2*QUDA_MAX_DIM], MemoryLocation location_label,
594  double a=0, double b=0);
595 
596 
597  void packGhostExtended(const int nFace, const int R[], const QudaParity parity, const int dim, const QudaDirection dir,
598  const int dagger,cudaStream_t* stream, bool zero_copy=false);
599 
600 
601  void packGhost(FullClover &clov, FullClover &clovInv, const int nFace, const QudaParity parity, const int dim,
602  const QudaDirection dir, const int dagger, cudaStream_t* stream, void *buffer=0, double a=0);
603 
613  void sendGhost(void *ghost_spinor, const int nFace, const int dim, const QudaDirection dir,
614  const int dagger, cudaStream_t *stream);
615 
625  void unpackGhost(const void* ghost_spinor, const int nFace, const int dim,
626  const QudaDirection dir, const int dagger, cudaStream_t* stream);
627 
639  void unpackGhostExtended(const void* ghost_spinor, const int nFace, const QudaParity parity,
640  const int dim, const QudaDirection dir, const int dagger, cudaStream_t* stream, bool zero_copy);
641 
642 
643  void streamInit(cudaStream_t *stream_p);
644 
659  void pack(int nFace, int parity, int dagger, int stream_idx,
660  MemoryLocation location[], MemoryLocation location_label, double a=0, double b=0);
661 
662  void packExtended(const int nFace, const int R[], const int parity, const int dagger,
663  const int dim, cudaStream_t *stream_p, const bool zeroCopyPack=false);
664 
665  void gather(int nFace, int dagger, int dir, cudaStream_t *stream_p=NULL);
666 
676  void recvStart(int nFace, int dir, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr=false);
677 
689  void sendStart(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr=false, bool remote_write=false);
690 
701  void commsStart(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false);
702 
713  int commsQuery(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false);
714 
725  void commsWait(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false);
726 
727  void scatter(int nFace, int dagger, int dir, cudaStream_t *stream_p);
728  void scatter(int nFace, int dagger, int dir);
729 
730  void scatterExtended(int nFace, int parity, int dagger, int dir);
731 
732  inline const void* Ghost2() const {
733  if (bufferIndex < 2) {
735  } else {
736  return static_cast<char*>(ghost_pinned_buffer_hd[bufferIndex%2])+ghost_bytes;
737  }
738  }
739 
753  void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr,
754  const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false) const;
755 
756 #ifdef USE_TEXTURE_OBJECTS
757  inline const cudaTextureObject_t& Tex() const { return tex; }
758  inline const cudaTextureObject_t& TexNorm() const { return texNorm; }
759  inline const cudaTextureObject_t& GhostTex() const { return ghostTex[bufferIndex]; }
760  inline const cudaTextureObject_t& GhostTexNorm() const { return ghostTexNorm[bufferIndex]; }
761 #endif
762 
763  cudaColorSpinorField& Component(const int idx) const;
765  void CopySubset(cudaColorSpinorField& dst, const int range, const int first_element=0) const;
766 
767  void zero();
768 
769  friend std::ostream& operator<<(std::ostream &out, const cudaColorSpinorField &);
770 
771  void getTexObjectInfo() const;
772 
773  void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0);
774 
775  void PrintVector(unsigned int x);
776 
780  void backup() const;
781 
785  void restore();
786  };
787 
788  // CPU implementation
790 
791  friend class cudaColorSpinorField;
792 
793  public:
794  static void* fwdGhostFaceBuffer[QUDA_MAX_DIM]; //cpu memory
795  static void* backGhostFaceBuffer[QUDA_MAX_DIM]; //cpu memory
796  static void* fwdGhostFaceSendBuffer[QUDA_MAX_DIM]; //cpu memory
797  static void* backGhostFaceSendBuffer[QUDA_MAX_DIM]; //cpu memory
799  static size_t ghostFaceBytes[QUDA_MAX_DIM];
800 
801  private:
802  //void *v; // the field elements
803  //void *norm; // the normalization field
804  bool init;
805  bool reference; // whether the field is a reference or not
806 
807  void create(const QudaFieldCreate);
808  void destroy();
809 
810  public:
811  //cpuColorSpinorField();
816  virtual ~cpuColorSpinorField();
817 
821 
822  void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0);
823  static int Compare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, const int resolution=1);
824  void PrintVector(unsigned int x);
825 
830  void allocateGhostBuffer(int nFace) const;
831  static void freeGhostBuffer(void);
832 
833  void packGhost(void **ghost, const QudaParity parity, const int nFace, const int dagger) const;
834  void unpackGhost(void* ghost_spinor, const int dim,
835  const QudaDirection dir, const int dagger);
836 
837  void copy(const cpuColorSpinorField&);
838  void zero();
839 
853  void exchangeGhost(QudaParity parity, int nFace, int dagger, const MemoryLocation *pack_destination=nullptr,
854  const MemoryLocation *halo_location=nullptr, bool gdr_send=false, bool gdr_recv=false) const;
855 
859  void backup() const;
860 
864  void restore();
865  };
866 
868  QudaFieldLocation location, void *Dst=0, void *Src=0,
869  void *dstNorm=0, void*srcNorm=0);
870  void genericSource(cpuColorSpinorField &a, QudaSourceType sourceType, int x, int s, int c);
871  int genericCompare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, int tol);
872  void genericPrintVector(cpuColorSpinorField &a, unsigned int x);
873 
874  void wuppertalStep(ColorSpinorField &out, const ColorSpinorField &in, int parity, const GaugeField& U, double A, double B);
875  void wuppertalStep(ColorSpinorField &out, const ColorSpinorField &in, int parity, const GaugeField& U, double alpha);
876 
877  void exchangeExtendedGhost(cudaColorSpinorField* spinor, int R[], int parity, cudaStream_t *stream_p);
878 
880  QudaFieldLocation location, const int parity, void *Dst, void *Src, void *dstNorm, void *srcNorm);
881 
891  void genericPackGhost(void **ghost, const ColorSpinorField &a, QudaParity parity,
892  int nFace, int dagger, MemoryLocation *destination=nullptr);
893 
894  /*Generate a gaussian distributed spinor
895  * @param src The spinorfield
896  * @param seed Seed
897  * */
898  void spinorGauss(ColorSpinorField &src, int seed);
899 
900  /*Generate a gaussian distributed spinor
901  * @param src The spinorfield
902  * @param randstates Random state
903  * */
904  void spinorGauss(ColorSpinorField &src, RNG& randstates);
905 
906 } // namespace quda
907 
908 #endif // _COLOR_SPINOR_FIELD_H
QudaDslashType dslash_type
Definition: test_util.cpp:1626
QudaDiracFieldOrder dirac_order
Definition: quda.h:195
int genericCompare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, int tol)
void setPrecision(QudaPrecision precision)
CompositeColorSpinorField components
void OffsetIndex(int &i, int *y) const
void copy(const cpuColorSpinorField &)
void commsStart(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Initiate halo communication.
friend std::ostream & operator<<(std::ostream &out, const ColorSpinorField &)
int ghostNormOffset[QUDA_MAX_DIM][2]
void unpackGhost(void *ghost_spinor, const int dim, const QudaDirection dir, const int dagger)
enum QudaPrecision_s QudaPrecision
void streamInit(cudaStream_t *stream_p)
const void * Ghost2() 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) const
This is a unified ghost exchange function for doing a complete halo exchange regardless of the type o...
void allocateGhostBuffer(int nFace, bool spin_project=true) const
Allocate the ghost buffers.
const void * Norm() const
virtual void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)=0
Constants used by dslash and packing kernels.
void * ghostNorm[2][QUDA_MAX_DIM]
int ghostFace[QUDA_MAX_DIM]
const char * AuxString() const
const void * src
static void * ghost_pinned_buffer_hd[2]
void spinorGauss(ColorSpinorField &src, int seed)
void unpackGhost(const void *ghost_spinor, const int nFace, const int dim, const QudaDirection dir, const int dagger, cudaStream_t *stream)
void gather(int nFace, int dagger, int dir, cudaStream_t *stream_p=NULL)
#define errorQuda(...)
Definition: util_quda.h:90
int GhostOffset(const int i, const int j) const
QudaDslashType dslash_type
Definition: quda.h:93
void copySpinorField(const ColorSpinorField &src)
enum QudaFieldOrder_s QudaFieldOrder
void sendGhost(void *ghost_spinor, const int nFace, const int dim, const QudaDirection dir, const int dagger, cudaStream_t *stream)
void create(const QudaFieldCreate)
CompositeColorSpinorFieldDescriptor composite_descr
used for deflation eigenvector sets etc.:
cpuColorSpinorField(const cpuColorSpinorField &)
void commsWait(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Wait on halo communication to complete.
cudaStream_t * stream
void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)
static __inline__ dim3 dim3 void size_t cudaStream_t int dim
void loadSpinorField(const ColorSpinorField &src)
const ColorSpinorField & Even() const
enum QudaSiteOrder_s QudaSiteOrder
CompositeColorSpinorField & Components()
const ColorSpinorField & Odd() const
static ColorSpinorField * Create(const ColorSpinorParam &param)
QudaGammaBasis GammaBasis() const
ColorSpinorField * CreateFine(const int *geoblockSize, int spinBlockSize, int Nvec, QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION)
virtual void PrintVector(unsigned int x)=0
size_t ComponentLength() const
QudaPrecision precision
Definition: lattice_field.h:54
static int R[4]
DslashConstant dslash_constant
void copyGenericColorSpinor(ColorSpinorField &dst, const ColorSpinorField &src, QudaFieldLocation location, void *Dst=0, void *Src=0, void *dstNorm=0, void *srcNorm=0)
ColorSpinorField & Component(const int idx) const
void scatterExtended(int nFace, int parity, int dagger, int dir)
void CopySubset(cudaColorSpinorField &dst, const int range, const int first_element=0) 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) const
This is a unified ghost exchange function for doing a complete halo exchange regardless of the type o...
void copy(const cudaColorSpinorField &)
int_fastdiv dims[4][3]
ColorSpinorParam(ColorSpinorParam &cpuParam, QudaInvertParam &inv_param, QudaFieldLocation location=QUDA_CUDA_FIELD_LOCATION)
QudaSiteSubset siteSubset
Definition: lattice_field.h:55
int commsQuery(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr_send=false, bool gdr_recv=false)
Non-blocking query if the halo communication has completed.
ColorSpinorField(const ColorSpinorField &)
QudaPrecision cpu_prec
Definition: covdev_test.cpp:33
enum QudaSourceType_s QudaSourceType
QudaGaugeParam param
Definition: pack_test.cpp:17
#define b
void packGhost(void **ghost, const QudaParity parity, const int nFace, const int dagger) const
int_fastdiv Xh[QUDA_MAX_DIM]
int x[QUDA_MAX_DIM]
Definition: lattice_field.h:50
const int * R() const
bool is_composite
for deflation solvers:
enum QudaDirection_s QudaDirection
static void * backGhostFaceSendBuffer[QUDA_MAX_DIM]
void genericPackGhost(void **ghost, const ColorSpinorField &a, QudaParity parity, int nFace, int dagger, MemoryLocation *destination=nullptr)
Generic ghost packing routine.
QudaDWFPCType DWFPCtype() const
std::vector< ColorSpinorField * > CompositeColorSpinorField
enum QudaDWFPCType_s QudaDWFPCType
ColorSpinorField * odd
double tol
Definition: test_util.cpp:1647
void Source(const QudaSourceType sourceType, const int st=0, const int s=0, const int c=0)
QudaFieldLocation location
static int bufferIndex
QudaInvertParam inv_param
Definition: covdev_test.cpp:37
int_fastdiv X[QUDA_MAX_DIM]
static void checkField(const ColorSpinorField &, const ColorSpinorField &)
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) const =0
void createComms(int nFace, bool spin_project=true)
Create the communication handlers and buffers.
void create(int nDim, const int *x, int Nc, int Ns, QudaTwistFlavorType Twistflavor, QudaPrecision precision, int pad, QudaSiteSubset subset, QudaSiteOrder siteOrder, QudaFieldOrder fieldOrder, QudaGammaBasis gammaBasis, QudaDWFPCType PCtype)
void exchange(void **ghost, void **sendbuf, int nFace=1) const
void reset(const ColorSpinorParam &)
QudaPrecision cuda_prec
Definition: covdev_test.cpp:34
friend std::ostream & operator<<(std::ostream &out, const cudaColorSpinorField &)
cpuColorSpinorField * in
int GhostNormOffset(const int i, const int j) const
void * GhostNorm(const int i)
QudaSiteSubset SiteSubset() const
void saveSpinorField(ColorSpinorField &src) const
Class declaration to initialize and hold CURAND RNG states.
Definition: random_quda.h:23
int V
Definition: test_util.cpp:28
void packExtended(const int nFace, const int R[], const int parity, const int dagger, const int dim, cudaStream_t *stream_p, const bool zeroCopyPack=false)
void exchangeExtendedGhost(cudaColorSpinorField *spinor, int R[], int parity, cudaStream_t *stream_p)
void * ghost[2][QUDA_MAX_DIM]
ColorSpinorField & operator=(const ColorSpinorField &)
static void * backGhostFaceBuffer[QUDA_MAX_DIM]
void restore()
Restores the cudaColorSpinorField.
enum QudaParity_s QudaParity
void genericSource(cpuColorSpinorField &a, QudaSourceType sourceType, int x, int s, int c)
void sendStart(int nFace, int d, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr=false, bool remote_write=false)
Initiate halo communication sending.
cudaColorSpinorField & Component(const int idx) const
for composite fields:
static void * fwdGhostFaceSendBuffer[QUDA_MAX_DIM]
QudaTwistFlavorType twistFlavor
int GhostOffset(const int i) const
static void * fwdGhostFaceBuffer[QUDA_MAX_DIM]
static int Compare(const cpuColorSpinorField &a, const cpuColorSpinorField &b, const int resolution=1)
void genericPrintVector(cpuColorSpinorField &a, unsigned int x)
void create(const QudaFieldCreate)
virtual ColorSpinorField & operator=(const ColorSpinorField &)
enum QudaSiteSubset_s QudaSiteSubset
const DslashConstant & getDslashConstant() const
Get the dslash_constant structure from this field.
void unpackGhostExtended(const void *ghost_spinor, const int nFace, const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, cudaStream_t *stream, bool zero_copy)
CompositeColorSpinorFieldDescriptor(bool is_composite, int dim, bool is_component=false, int id=0)
ColorSpinorField * CreateCoarse(const int *geoblockSize, int spinBlockSize, int Nvec, QudaFieldLocation location=QUDA_INVALID_FIELD_LOCATION)
void wuppertalStep(ColorSpinorField &out, const ColorSpinorField &in, int parity, const GaugeField &U, double A, double B)
enum QudaFieldLocation_s QudaFieldLocation
char aux_string[TuneKey::aux_n]
cpuColorSpinorField * out
int ghostOffset[QUDA_MAX_DIM][2]
void createGhostZone(int nFace, bool spin_project=true) const
const void * V() const
void copyExtendedColorSpinor(ColorSpinorField &dst, const ColorSpinorField &src, QudaFieldLocation location, const int parity, void *Dst, void *Src, void *dstNorm, void *srcNorm)
void backup() const
Backs up the cudaColorSpinorField.
enum QudaGammaBasis_s QudaGammaBasis
Main header file for the QUDA library.
void fill(ColorSpinorParam &) const
size_t ComponentNormBytes() const
static void * ghost_recv_buffer_d[2]
static const int aux_n
Definition: tune_key.h:12
int ghostFace[QUDA_MAX_DIM+1]
#define printfQuda(...)
Definition: util_quda.h:84
void backup() const
Backs up the cudaColorSpinorField.
QudaTwistFlavorType twistFlavor
void allocateGhostBuffer(int nFace) const
Allocate the ghost buffers.
static __inline__ dim3 dim3 void size_t cudaStream_t int enum cudaTextureReadMode readMode static __inline__ const struct texture< T, dim, readMode > & tex
QudaSiteOrder SiteOrder() const
QudaTwistFlavorType TwistFlavor() const
CompositeColorSpinorField & Components() const
void LatticeIndex(int *y, int i) const
void pack(int nFace, int parity, int dagger, int stream_idx, MemoryLocation location[], MemoryLocation location_label, double a=0, double b=0)
QudaTwistFlavorType twist_flavor
Definition: test_util.cpp:1649
const int * GhostFace() const
size_t ComponentRealLength() const
const void * c
enum QudaFieldCreate_s QudaFieldCreate
const int * X() const
void packGhostExtended(const int nFace, const int R[], const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, cudaStream_t *stream, bool zero_copy=false)
void *const * Ghost() const
virtual const void * Ghost2() const
cudaColorSpinorField(const cudaColorSpinorField &)
#define QUDA_MAX_DIM
Maximum number of dimensions supported by QUDA. In practice, no routines make use of more than 5...
ColorSpinorParam(void *V, QudaInvertParam &inv_param, const int *X, const bool pc_solution, QudaFieldLocation location=QUDA_CPU_FIELD_LOCATION)
int GhostNormOffset(const int i) const
void * ghost_buf[2 *QUDA_MAX_DIM]
static __inline__ size_t size_t d
void scatter(int nFace, int dagger, int dir, cudaStream_t *stream_p)
void recvStart(int nFace, int dir, int dagger=0, cudaStream_t *stream_p=nullptr, bool gdr=false)
Initiate halo communication receive.
QudaParity parity
Definition: covdev_test.cpp:53
QudaPrecision precision
static size_t ghostFaceBytes[QUDA_MAX_DIM]
#define a
QudaFieldOrder FieldOrder() const
void packGhost(const int nFace, const QudaParity parity, const int dim, const QudaDirection dir, const int dagger, cudaStream_t *stream, MemoryLocation location[2 *QUDA_MAX_DIM], MemoryLocation location_label, double a=0, double b=0)
Packs the cudaColorSpinorField&#39;s ghost zone.
ColorSpinorField * even
CompositeColorSpinorFieldDescriptor(const CompositeColorSpinorFieldDescriptor &descr)
cpuColorSpinorField * spinor
Definition: covdev_test.cpp:41
void restore()
Restores the cudaColorSpinorField.
ColorSpinorField & operator=(const ColorSpinorField &)
enum QudaTwistFlavorType_s QudaTwistFlavorType