From f53dbd547684343a561499ea53e2add945a9c917 Mon Sep 17 00:00:00 2001 From: Ferenc Pittler Date: Sun, 19 Mar 2023 21:47:16 +0200 Subject: [PATCH 1/5] using one struct for all the global parameters --- include/PLEGMA_Correlator.h | 18 ++-- include/PLEGMA_FT.h | 14 +-- include/PLEGMA_Field.h | 10 +- include/PLEGMA_Hprobing.h | 16 ++-- include/PLEGMA_ScattCorrelator.h | 8 +- include/PLEGMA_Vector.h | 4 +- include/PLEGMA_io.h | 16 ++-- include/global/PLEGMA_Options.h | 5 +- include/global/PLEGMA_global_constants.h | 76 ++++----------- include/global/PLEGMA_prints.hpp | 1 - include/global/PLEGMA_structs.h | 72 +++++++++++--- include/io/PLEGMA_hdf5.h | 42 ++++----- include/io/PLEGMA_lime.h | 46 ++++----- include/target/hip/PLEGMA_hipBLAS.h | 24 ++--- lib/kernels/PLEGMA_kernel_getSet.cuh | 114 +++++++++++------------ utils/PLEGMA_utils.cpp | 20 ++-- utils/QUDA_interface.cpp | 14 +-- 17 files changed, 256 insertions(+), 244 deletions(-) diff --git a/include/PLEGMA_Correlator.h b/include/PLEGMA_Correlator.h index 8ff7a189..b02227b2 100644 --- a/include/PLEGMA_Correlator.h +++ b/include/PLEGMA_Correlator.h @@ -41,8 +41,8 @@ namespace plegma { bool hasSource(int dir) const { // Tells if the source is included in the local lattice for the given direction if(dir<0 || dir>N_DIMS) return false; - return ((HGC_procPosition[dir]*HGC_localL[dir]) <= source[dir]) - && (source[dir] < ((HGC_procPosition[dir]+1)*HGC_localL[dir])); + return ((HGC.procPosition[dir]*HGC.localL[dir]) <= source[dir]) + && (source[dir] < ((HGC.procPosition[dir]+1)*HGC.localL[dir])); } bool hasSource() const { bool ret=true; @@ -53,15 +53,15 @@ namespace plegma { int startT() const { // Returns the starting point in time of the correlator wrt the source. // Zero is returned if the local time slice is not used. - int start=(HGC_procPosition[DIM_T] * HGC_localL[DIM_T] + HGC_totalL[DIM_T] - source[DIM_T] ) - % HGC_totalL[DIM_T]; + int start=(HGC.procPosition[DIM_T] * HGC.localL[DIM_T] + HGC.totalL[DIM_T] - source[DIM_T] ) + % HGC.totalL[DIM_T]; return (start>=totalT) ? 0 : start; } int endT() const { // Returns the end point int start = startT(); if(start>0) - return std::min(totalT, HGC_localL[DIM_T]+start); + return std::min(totalT, HGC.localL[DIM_T]+start); else return 0; } @@ -71,18 +71,18 @@ namespace plegma { // When the source is in the local lattice we may have two pieces: // |--> s | from startT to endT // | s-->| from the source to the end - int t_source = source[DIM_T]%HGC_localL[DIM_T]; - return endT() - startT() + std::min(totalT, HGC_localL[DIM_T]-t_source); + int t_source = source[DIM_T]%HGC.localL[DIM_T]; + return endT() - startT() + std::min(totalT, HGC.localL[DIM_T]-t_source); } else { return endT() - startT(); } } - PLEGMA_Correlator(CORR_SPACE corr_space, site source, int Q2_max = 0, int totalT=HGC_totalL[DIM_T]): + PLEGMA_Correlator(CORR_SPACE corr_space, site source, int Q2_max = 0, int totalT=HGC.totalL[DIM_T]): source(source), totalT(totalT), corr_space(corr_space), corr_pos_space(nullptr), corr_mom_space(corr_space==MOMENTUM_SPACE ? new PLEGMA_FT(Q2_max, 3, false, localT()) : nullptr), - comm(new MPI_Comm(HGC_fullComm)) { } + comm(new MPI_Comm(HGC.fullComm)) { } ~PLEGMA_Correlator() {} diff --git a/include/PLEGMA_FT.h b/include/PLEGMA_FT.h index b7b7bd0d..7f9d364c 100644 --- a/include/PLEGMA_FT.h +++ b/include/PLEGMA_FT.h @@ -55,7 +55,7 @@ namespace plegma { @params bool accum = false: In case we want to accumulation results from each transformation on the class buffer @params bool dimT = HGC_localL[DIM_T]: Size of the time dimension in case we want to transform only part of the vector **/ - PLEGMA_FT(int Q2_max, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT(int Q2_max, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); /** @brief Constructor of the FT class with specific momentum vector @params std::vector mom: Momentum vector, either 3 or 4 components based on the choice of D3D4 @@ -63,17 +63,17 @@ namespace plegma { @params bool accum = false: In case we want to accumulation results from each transformation on the class buffer @params bool dimT = HGC_localL[DIM_T]: Size of the time dimension in case we want to transform only part of the vector **/ - PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); - PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); - PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); - PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); - PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT(std::vector mom, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); - PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC_localL[DIM_T]); + PLEGMA_FT( std::vector> &moms, int D3D4 = 3, bool accum = false, int dimT = HGC.localL[DIM_T]); ~PLEGMA_FT() {}; diff --git a/include/PLEGMA_Field.h b/include/PLEGMA_Field.h index 4e41ac66..26516d70 100644 --- a/include/PLEGMA_Field.h +++ b/include/PLEGMA_Field.h @@ -90,7 +90,7 @@ namespace plegma { @param isPinnedHost: see "isPinnedHost" @param checkErr: see "checkErr" */ - PLEGMA_Field(ALLOCATION_FLAG alloc_flag, int site_size, size_t localV = HGC_localVolume, GHOST_FLAG ghost_flag=NO_GHOSTS, bool isPinnedHost = false, bool checkErr = true); + PLEGMA_Field(ALLOCATION_FLAG alloc_flag, int site_size, size_t localV = HGC.localVolume, GHOST_FLAG ghost_flag=NO_GHOSTS, bool isPinnedHost = false, bool checkErr = true); /** @brief virtual destructor responsible for freeing memory. Virtual because it could be called from an instance of a derived class through a pointer to base class */ @@ -393,7 +393,7 @@ namespace plegma { } virtual bool includesActiveTimeSlice() const{return true;} - virtual bool is4D() const{assert(Total_length()==HGC_localVolume); return true;} + virtual bool is4D() const{assert(Total_length()==HGC.localVolume); return true;} }; @@ -409,11 +409,11 @@ namespace plegma { PLEGMA_Field3D(ALLOCATION_FLAG alloc_flag, CLASS_ENUM classT, GHOST_FLAG ghost_flag=NO_GHOSTS, bool isPinnedHost = false, bool checkErr = true) : PLEGMA_Field(alloc_flag, classT, ghost_flag, isPinnedHost, checkErr), activeTimeSlice(false) { } PLEGMA_Field3D(ALLOCATION_FLAG alloc_flag, int site_size, GHOST_FLAG ghost_flag=NO_GHOSTS, bool isPinnedHost = false, bool checkErr = true) : - PLEGMA_Field(alloc_flag, site_size, HGC_localVolume3D, ghost_flag, isPinnedHost, checkErr), activeTimeSlice(false) { } - PLEGMA_Field3D() : PLEGMA_Field(NONE, 0, HGC_localVolume3D), activeTimeSlice(false) { } + PLEGMA_Field(alloc_flag, site_size, HGC.localVolume3D, ghost_flag, isPinnedHost, checkErr), activeTimeSlice(false) { } + PLEGMA_Field3D() : PLEGMA_Field(NONE, 0, HGC.localVolume3D), activeTimeSlice(false) { } virtual bool includesActiveTimeSlice() const{return activeTimeSlice;} - virtual bool is4D() const{assert(this->Total_length()==HGC_localVolume3D); return false;} + virtual bool is4D() const{assert(this->Total_length()==HGC.localVolume3D); return false;} template void copy(PLEGMA_Field3D &f, ALLOCATION_FLAG where=DEVICE) { diff --git a/include/PLEGMA_Hprobing.h b/include/PLEGMA_Hprobing.h index bb7c5f44..4c6ee697 100644 --- a/include/PLEGMA_Hprobing.h +++ b/include/PLEGMA_Hprobing.h @@ -61,11 +61,11 @@ namespace plegma { int* arrlc; // array to hold the elementary coloring block void createElemColBlock(){for(int i = 0; i < Nc; i++) arrlc[i]=i;} void createColLattice(){ - std::vector lL = {HGC_localL[0], HGC_localL[1], HGC_localL[2], HGC_localL[3]}; + std::vector lL = {HGC.localL[0], HGC.localL[1], HGC.localL[2], HGC.localL[3]}; std::vector lu = {Lu,Lu,Lu,Lu}; std::vector bx(d); std::vector lx(d); - for(size_t i=0; i < HGC_localVolume; i++){ + for(size_t i=0; i < HGC.localVolume; i++){ std::vector x = getIndToVec(i,lL); for(int j = 0 ; j < d; j++) bx[j] = x[j]/lu[j]; int eo=0; @@ -78,7 +78,7 @@ namespace plegma { // void checkColoring(); public: PLEGMA_Hprobing(int k_probing, int d=4):k(k_probing),Nc(0),d(d),D(0),Lu(0),h_arrVc(nullptr),d_arrVc(nullptr),arrlc(nullptr){ - if(!HGC_init_PLEGMA_flag){ fprintf(stderr, "Error PLEGMA should be initialized before use this class"); exit(-1);} + if(!HGC.init_PLEGMA_flag){ fprintf(stderr, "Error PLEGMA should be initialized before use this class"); exit(-1);} if(d != 4) PLEGMA_error("Hierarchical probing supports only 4D coloring up to now"); if(k<=0) PLEGMA_error("The index of the Hprobing should greater than zero"); Nc = 2*std::pow(2,d*(k-1)); @@ -88,12 +88,12 @@ namespace plegma { PLEGMA_printf("Distance of neigbors is %d\n",D); PLEGMA_printf("The extent of the elementary symmetric color block is %d\n",Lu); for(int i = 0 ; i < d ; i++){ - if(D >= HGC_localL[i]) PLEGMA_error("The coloring distance is larger than the lattice extent in direction %d\n",i); - if( (HGC_localL[i] % (2*Lu)) != 0 ) + if(D >= HGC.localL[i]) PLEGMA_error("The coloring distance is larger than the lattice extent in direction %d\n",i); + if( (HGC.localL[i] % (2*Lu)) != 0 ) PLEGMA_error("2*Lu cannot fit in the local lattice extent in direction %d. Try to increase local size in this direction",i); } try{ - h_arrVc = new int[HGC_localVolume]; + h_arrVc = new int[HGC.localVolume]; arrlc = new int[Nc]; } catch (const std::bad_alloc& err) { @@ -102,9 +102,9 @@ namespace plegma { createElemColBlock(); createColLattice(); // if(check)checkColoring(); - d_arrVc=(int*)device_malloc(HGC_localVolume*sizeof(int)); + d_arrVc=(int*)device_malloc(HGC.localVolume*sizeof(int)); // checkQudaError(); - qudaMemcpy(d_arrVc, h_arrVc, HGC_localVolume*sizeof(int), qudaMemcpyHostToDevice); + qudaMemcpy(d_arrVc, h_arrVc, HGC.localVolume*sizeof(int), qudaMemcpyHostToDevice); // checkQudaError(); } ~PLEGMA_Hprobing(){ diff --git a/include/PLEGMA_ScattCorrelator.h b/include/PLEGMA_ScattCorrelator.h index f85b27d4..aef546aa 100644 --- a/include/PLEGMA_ScattCorrelator.h +++ b/include/PLEGMA_ScattCorrelator.h @@ -35,13 +35,13 @@ namespace plegma { public: // these constructors does NOT ALLOCATE the memory PLEGMA_ScattCorrelator here, because // the dimension is not provided. It will be allocated when used. - PLEGMA_ScattCorrelator(site source, int Q2_max, int totalT=HGC_totalL[DIM_T]); + PLEGMA_ScattCorrelator(site source, int Q2_max, int totalT=HGC.totalL[DIM_T]); - PLEGMA_ScattCorrelator(site source, std::vector fixMomVec, int totalT=HGC_totalL[DIM_T]); + PLEGMA_ScattCorrelator(site source, std::vector fixMomVec, int totalT=HGC.totalL[DIM_T]); - PLEGMA_ScattCorrelator(site source, std::vector> fixMomsVec, int totalT=HGC_totalL[DIM_T]); + PLEGMA_ScattCorrelator(site source, std::vector> fixMomsVec, int totalT=HGC.totalL[DIM_T]); - PLEGMA_ScattCorrelator(site source, momList &listmom, int totalT=HGC_totalL[DIM_T]); + PLEGMA_ScattCorrelator(site source, momList &listmom, int totalT=HGC.totalL[DIM_T]); ~PLEGMA_ScattCorrelator(){;} diff --git a/include/PLEGMA_Vector.h b/include/PLEGMA_Vector.h index 81933ceb..2af8eee6 100644 --- a/include/PLEGMA_Vector.h +++ b/include/PLEGMA_Vector.h @@ -155,8 +155,8 @@ namespace plegma { } void pointSource(const site& sourceposition, int spin, int color, ALLOCATION_FLAG alloc_flag=EVERY){ - int my_it = sourceposition[DIM_T] - HGC_procPosition[DIM_T] * HGC_localL[DIM_T]; - this->activeTimeSlice = (my_it >= 0) && ( my_it < HGC_localL[DIM_T] ); + int my_it = sourceposition[DIM_T] - HGC.procPosition[DIM_T] * HGC.localL[DIM_T]; + this->activeTimeSlice = (my_it >= 0) && ( my_it < HGC.localL[DIM_T] ); return ((PLEGMA_Vector*) this)->pointSource(sourceposition,spin,color,alloc_flag); } diff --git a/include/PLEGMA_io.h b/include/PLEGMA_io.h index 69e89021..46bc994f 100644 --- a/include/PLEGMA_io.h +++ b/include/PLEGMA_io.h @@ -53,17 +53,17 @@ namespace plegma { returnT writeFile(std::string filename, FILE_FORMAT format, argsT ... args) const { switch (format) { case ASCII_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to write file %s in ASCII format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to write file %s in ASCII format\n",filename.c_str()); return writeASCII(filename, args...); case HDF5_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to write file %s in HDF5 format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to write file %s in HDF5 format\n",filename.c_str()); return writeHDF5(filename, args...); case LIME_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to write file %s in LIME format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to write file %s in LIME format\n",filename.c_str()); return writeLIME(filename, args...); case DEFAULT_FORMAT: default: - if(HGC_verbosity > 1) PLEGMA_printf("Going to write file %s in DEFAULT format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to write file %s in DEFAULT format\n",filename.c_str()); return writeDEFAULT(filename, args...); } } @@ -91,17 +91,17 @@ namespace plegma { returnT readFile(std::string filename, FILE_FORMAT format, argsT ... args) { switch (format) { case ASCII_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to read file %s in ASCII format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to read file %s in ASCII format\n",filename.c_str()); return readASCII(filename, args...); case HDF5_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to read file %s in HDF5 format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to read file %s in HDF5 format\n",filename.c_str()); return readHDF5(filename, args...); case LIME_FORMAT: - if(HGC_verbosity > 1) PLEGMA_printf("Going to read file %s in LIME format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to read file %s in LIME format\n",filename.c_str()); return readLIME(filename, args...); case DEFAULT_FORMAT: default: - if(HGC_verbosity > 1) PLEGMA_printf("Going to read file %s in DEFAULT format\n",filename.c_str()); + if(HGC.verbosity > 1) PLEGMA_printf("Going to read file %s in DEFAULT format\n",filename.c_str()); return readDEFAULT(filename, args...); } } diff --git a/include/global/PLEGMA_Options.h b/include/global/PLEGMA_Options.h index 4c7a08dc..3e0e3170 100644 --- a/include/global/PLEGMA_Options.h +++ b/include/global/PLEGMA_Options.h @@ -266,9 +266,10 @@ class Options : public Arguments{ args.erase(args.begin()+i); countF++; } - if(countF == 0) { if(visualize>1) print(name,p1,par...); return false; } + if(countF == 0) { //if(visualize>1) print(name,p1,par...); + return false; } else{ - if(visualize)print(name,p1,par...); + //if(visualize)print(name,p1,par...); listSetOpt.push_back(name); if(countF>1) PLEGMA_printf("Warning: [%s] found %d times in the arguments. Last occurance is considered", name.c_str(), countF); return true; diff --git a/include/global/PLEGMA_global_constants.h b/include/global/PLEGMA_global_constants.h index 10042620..dd6e3f9d 100644 --- a/include/global/PLEGMA_global_constants.h +++ b/include/global/PLEGMA_global_constants.h @@ -20,8 +20,9 @@ #else #include #endif -#ifdef ADD_TO_GLOBAL +/* +#ifdef ADD_TO_GLOBAL void *symbolAddress; #define global_host(dtype, name, ...) \ HGC_global_vars.add(#name, \ @@ -36,19 +37,20 @@ void *symbolAddress; (void**) &symbolAddress) #else +*/ #ifdef ALLOCATE #define global_host(dtype, name, ...) \ dtype HGC_##name PARENTHESES(1,__VA_ARGS__); -#if defined ( __NVCC__ ) +#ifdef __NVCC__ #define global_both(dtype, name, ...) \ dtype HGC_##name PARENTHESES(1,__VA_ARGS__); \ - __constant__ dtype DGC_##name PARENTHESES(1,__VA_ARGS__); -#elif defined (__HIP__) + __constant__ dtype DGC_##name PARENTHESES(1,__VA_ARGS__); +#elif defined (__HIP__) \ #define global_both(dtype, name, ...) \ dtype HGC_##name PARENTHESES(1,__VA_ARGS__); \ - __device__ __constant__ dtype DGC_##name PARENTHESES(1,__VA_ARGS__); -#else + __device__ __constant__ dtype DGC_##name PARENTHESES(1,__VA_ARGS__); \ +#else #define global_both(dtype, name, ...) \ dtype HGC_##name PARENTHESES(1,__VA_ARGS__); #endif @@ -57,9 +59,9 @@ void *symbolAddress; #define global_host(dtype, name, ...) \ extern dtype HGC_##name PARENTHESES(1,__VA_ARGS__); -#if defined ( __NVCC__ ) +#ifdef __NVCC__ #define global_both(dtype, name, ...) \ - extern dtype HGC_##name PARENTHESES(1,__VA_ARGS__); \ + extern dtype HGC PARENTHESES(1,__VA_ARGS__); \ extern __constant__ dtype DGC_##name PARENTHESES(1,__VA_ARGS__); #elif defined ( __HIP__ ) #define global_both(dtype, name, ...) \ @@ -70,62 +72,22 @@ void *symbolAddress; extern dtype HGC_##name PARENTHESES(1,__VA_ARGS__); #endif #endif -#endif // ---------------- ADD_FROM_HERE ------------- // -// Global variables -global_host(bool, init_PLEGMA_flag); -global_host(float, deviceMemory); -global_host(int, verbosity); -global_host(long int, used_memory); -global_host(global_vars, global_vars); -global_host(Options *, options); -global_host(bool, hold_exit); + +#pragma message " HGC " +#ifdef ALLOCATE +struct global_vars HGC; +struct global_vars *DGC; +#else +extern struct global_vars HGC; +extern struct global_vars *DGC; +#endif // variables visible on both host and device -global_both(int, localL, N_DIMS); -global_both(int, totalL, N_DIMS); -global_both(int, procPosition, N_DIMS); -global_both(size_t, sideGhost, N_DIMS, DIR_BOTH); -global_both(size_t, cornerGhost, (N_DIMS*(N_DIMS-1))/2*DIR_BOTH*DIR_BOTH); -global_both(size_t, vertexGhost, (N_DIMS*(N_DIMS-1)*(N_DIMS-2))/6*DIR_BOTH*DIR_BOTH*DIR_BOTH); -global_both(size_t, sideGhostVolume); -global_both(size_t, cornerGhostVolume); -global_both(size_t, vertexGhostVolume); -global_both(size_t, sideGhostVolume3D); -global_both(size_t, cornerGhostVolume3D); -global_both(size_t, vertexGhostVolume3D); -global_both(size_t, surface3D, N_DIMS); -global_both(size_t, surface2D, (N_DIMS*(N_DIMS-1))/2); -global_both(size_t, surface1D, (N_DIMS*(N_DIMS-1)*(N_DIMS-2))/6); -global_both(size_t, localVolume); -global_both(size_t, localVolume3D); -global_both(size_t, totalVolume); // for mpi use global variables (host only) -global_both(bool, dimBreak, N_DIMS); -global_host(Topology *, default_topo); -global_host(int, nProc, N_DIMS); -global_host(MPI_Group, fullGroup); -global_host(MPI_Group, spaceGroup); -global_host(MPI_Group, timeGroup); -global_host(MPI_Comm, fullComm); -global_host(MPI_Comm, spaceComm); -global_host(MPI_Comm, timeComm); -global_host(int, fullRank); -global_host(int, fullSize); -global_host(int, spaceRank); -global_host(int, spaceSize); -global_host(int, timeRank); -global_host(int, timeSize); - -// for cublas use -#if defined (__HIP__) -global_host(hipblasHandle_t, hipblas_handle); -#else -global_host(cublasHandle_t, cublas_handle); -#endif #undef global_both #undef global_host diff --git a/include/global/PLEGMA_prints.hpp b/include/global/PLEGMA_prints.hpp index 9c2011a6..7e99d3b6 100644 --- a/include/global/PLEGMA_prints.hpp +++ b/include/global/PLEGMA_prints.hpp @@ -56,7 +56,6 @@ extern class Options * HGC_options; fprintf(getOutputFile(), "%s last kernel called was (name=%s,volume=%s,aux=%s)\n", \ getOutputPrefix(), getLastTuneKey().name, \ getLastTuneKey().volume, getLastTuneKey().aux); \ - HGC_global_vars.print(); \ fflush(getOutputFile()); \ quda::saveTuneCache(true); \ } else { \ diff --git a/include/global/PLEGMA_structs.h b/include/global/PLEGMA_structs.h index 75ed43b5..c88e36ca 100644 --- a/include/global/PLEGMA_structs.h +++ b/include/global/PLEGMA_structs.h @@ -1,12 +1,19 @@ //======== Some custom data struct =========// +#ifdef __HIP__ +#include +#else +#include +#endif + #define HIP_CHECK(error) \ { \ hipError_t localError = error; \ if ((localError != hipSuccess) && (localError != hipErrorPeerAccessAlreadyEnabled)) { \ PLEGMA_printf("Error: %s, Code %d\n", hipGetErrorString(localError), localError); \ - PLEGMA_printf("FILE: %s, LINE %d\n", __FILE__, __LINE__ ); \ - } \ + PLEGMA_printf("FILE: %s, LINE %d\n", __FILE__, __LINE__ ); \ + } \ } + template struct texture; struct site : std::array { @@ -38,7 +45,6 @@ inline std::istream& operator >> (std::istream &i, site &x){ // Global variable for mom list struct tex_mom_list { size_t Nmoms; - #if __HIP__ hipTextureObject_t tex; #else @@ -47,7 +53,6 @@ struct tex_mom_list { void* devPtr; tex_mom_list() : Nmoms(0), tex(), devPtr(nullptr) {} - #ifdef __NVCC__ tex_mom_list(size_t Nmoms, cudaTextureObject_t tex, void* devPtr) : Nmoms(Nmoms), tex(tex), devPtr(devPtr) {} @@ -56,7 +61,6 @@ struct tex_mom_list { Nmoms(Nmoms), tex(tex), devPtr(devPtr) {} #endif - inline __device__ int4 get(const size_t &i) const { #ifdef __NVCC__ return tex1Dfetch(tex,i); @@ -81,8 +85,8 @@ struct pointer_holder { var_name(name), type_name(plegma::type_name()), type_char(plegma::type_char()) { } void copyToDeviceConstant() { - if(devPointer != nullptr) { -#ifdef __NVCC__ + if(devPointer != nullptr) { +#ifdef __NVCC__ cudaError_t err = cudaMemcpyToSymbol( *devPointer, hostPointer, bytes*size); if (err != cudaSuccess) { errorQuda("Failed to copy constant host memory of size to device %zu \n", size); @@ -90,7 +94,7 @@ struct pointer_holder { #else HIP_CHECK(hipMemcpy(*devPointer, hostPointer, bytes*size, hipMemcpyHostToDevice)); #endif - } + } } void copyFromDeviceConstant() { if(false and devPointer != nullptr) { @@ -100,7 +104,7 @@ struct pointer_holder { errorQuda("Failed to copy constant host memory of size to device %zu \n", size); } #else - qudaMemcpy(hostPointer, *devPointer, bytes*size,qudaMemcpyDeviceToHost); + qudaMemcpy(hostPointer, *devPointer, bytes*size,qudaMemcpyDeviceToHost); #endif } } @@ -134,8 +138,54 @@ struct pointer_holder { // here we collect the global variables for then running some default functions on them (print and copy to device) struct global_vars { - std::vector globals; + bool init_PLEGMA_flag; + float deviceMemory; + int verbosity; + long int used_memory; + Options * options; + bool hold_exit; + size_t localVolume; + size_t localVolume3D; + size_t totalVolume; + int localL[N_DIMS]; + int totalL[N_DIMS]; + int procPosition[N_DIMS]; + size_t sideGhost[N_DIMS][DIR_BOTH]; + size_t cornerGhost[(N_DIMS*(N_DIMS-1))/2*DIR_BOTH*DIR_BOTH]; + size_t vertexGhost[(N_DIMS*(N_DIMS-1)*(N_DIMS-2))/6*DIR_BOTH*DIR_BOTH*DIR_BOTH]; + size_t sideGhostVolume; + size_t cornerGhostVolume; + size_t vertexGhostVolume; + size_t sideGhostVolume3D; + size_t cornerGhostVolume3D; + size_t vertexGhostVolume3D; + size_t surface3D[N_DIMS]; + size_t surface2D[(N_DIMS*(N_DIMS-1))/2]; + size_t surface1D[(N_DIMS*(N_DIMS-1)*(N_DIMS-2))/6]; + + bool dimBreak[N_DIMS]; + Topology *default_topo; + int nProc[N_DIMS]; + MPI_Group fullGroup; + MPI_Group spaceGroup; + MPI_Group timeGroup; + MPI_Comm fullComm; + MPI_Comm spaceComm; + MPI_Comm timeComm; + int fullRank; + int fullSize; + int spaceRank; + int spaceSize; + int timeRank; + int timeSize; +// for cublas use +#if defined (__HIP__) + hipblasHandle_t hipblas_handle; +#else + cublasHandle_t cublas_handle; +#endif + /* template void add(const std::string& name, const size_t& size, hostT *host, void ** device = nullptr) { globals.push_back(pointer_holder(name, size, host, device)); @@ -174,5 +224,5 @@ struct global_vars { } } PLEGMA_printf("\n\n"); - } + }*/ }; diff --git a/include/io/PLEGMA_hdf5.h b/include/io/PLEGMA_hdf5.h index 7a6deaca..a4c2cda5 100644 --- a/include/io/PLEGMA_hdf5.h +++ b/include/io/PLEGMA_hdf5.h @@ -112,7 +112,7 @@ class HDF5 { } inline void wait(){ - if(HGC_verbosity > 2) PLEGMA_printf("Waiting...\n"); + if(HGC.verbosity > 2) PLEGMA_printf("Waiting...\n"); MPI_Barrier(comm); } @@ -214,7 +214,7 @@ class HDF5 { if(path_id.empty()) PLEGMA_error("Tried to go back but path_id is empty\n"); H5Gclose(path_id.back()); path_id.pop_back(); - if(HGC_verbosity > 2) PLEGMA_printf("Closed group %s\n", path_str.back().c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Closed group %s\n", path_str.back().c_str()); path_str.pop_back(); } @@ -225,9 +225,9 @@ class HDF5 { // Splitting, cleaning and checking until what point path is the same with the current path inline std::vector prepare_path(std::string path) { - if(HGC_verbosity > 2) PLEGMA_printf("Path before cleaning %s\n", path.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Path before cleaning %s\n", path.c_str()); std::vector vp = clean_path(split_path(path)); - if(HGC_verbosity > 2) PLEGMA_printf("Path after cleaning %s\n", join_path(vp, path[0]=='/').c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Path after cleaning %s\n", join_path(vp, path[0]=='/').c_str()); // checking if starts with '/' if(!path_id.empty() && path[0]=='/') { if(vp.empty() || vp[0] != path_str[0]) go_top(); @@ -272,7 +272,7 @@ class HDF5 { if(exists(dir)){ if(H5Oexists_by_name(current(), dir.c_str(), H5P_DEFAULT)) { path_id.push_back(H5Gopen(current(), dir.c_str(), H5P_DEFAULT)); - if(HGC_verbosity > 2) PLEGMA_printf("Opened group %s\n", dir.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Opened group %s\n", dir.c_str()); } else { PLEGMA_error("A link with dir %s exists but it is not a group\n File: %s\n Path: %s", dir.c_str(), @@ -281,7 +281,7 @@ class HDF5 { } else { path_id.push_back(H5Gcreate(current(), dir.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)); - if(HGC_verbosity > 2) PLEGMA_printf("Created group %s\n", dir.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Created group %s\n", dir.c_str()); } path_str.push_back(dir); } @@ -397,7 +397,7 @@ class HDF5 { for(size_t i=0; i shape[i]) { // then i it's exceeding int exceeding = std::min(lshape[i], start[i] + lshape[i] - shape[i]); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) printf("rank %d: dir %d: exceeds of %d\n", comm_rank(), i, exceeding); exceeding_id.push_back(i); exceeding_shape.push_back(exceeding); @@ -409,7 +409,7 @@ class HDF5 { if(!exceeding_id.empty()) my_n_writings = 1< 2) PLEGMA_printf("%s: %d writing(s) are needed for writing the dataset\n", name.c_str(), n_writings); + if(HGC.verbosity > 2) PLEGMA_printf("%s: %d writing(s) are needed for writing the dataset\n", name.c_str(), n_writings); if(n_writings>1) { std::vector my_writings = {0}; @@ -457,7 +457,7 @@ class HDF5 { shift[id] = tmp_lshape[id]; tmp_lshape[id] = exceeding_shape[id]; tmp_start[id] = 0; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) printf("rank %d: iter %d: shifting id %d, shift[id] = %d, tmp_lshape[id] = %d\n", comm_rank(), i, id, shift[id], tmp_lshape[id]); } @@ -541,7 +541,7 @@ class HDF5 { * i.e. name="./sample.h5/group1/group2" would create the file sample.h5 and * then go to group1 and group2 */ - HDF5(std::string name, MPI_Comm comm=HGC_fullComm) : comm(comm) { + HDF5(std::string name, MPI_Comm comm=HGC.fullComm) : comm(comm) { // Creating filename and path from name std::string path = "/"; // checking if .h5 is given and at the end of file @@ -560,7 +560,7 @@ class HDF5 { } // check if filename is open by another instance - if(HGC_verbosity > 2) PLEGMA_printf("Checking if file is open %s\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Checking if file is open %s\n", filename.c_str()); while( isFileOpen(filename) ) std::this_thread::sleep_for(1ms); @@ -570,15 +570,15 @@ class HDF5 { // checking if file exists or creating it if(access( filename.c_str(), F_OK ) != -1) { file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, fapl_id); - if(HGC_verbosity > 2) PLEGMA_printf("Opened file %s\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Opened file %s\n", filename.c_str()); } else { file_id = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(HGC_verbosity > 2) PLEGMA_printf("Created file %s\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Created file %s\n", filename.c_str()); } H5Pclose(fapl_id); // adding opened file to vector - if(HGC_verbosity > 2) PLEGMA_printf("Adding %s to open files\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Adding %s to open files\n", filename.c_str()); open_files.push_back(filename); if(path != "/") { @@ -598,10 +598,10 @@ class HDF5 { PLEGMA_error("More than one objects open. The closing will hang, so we crash the code here."); } H5Fclose(file_id); - if(HGC_verbosity > 2) PLEGMA_printf("Closed file %s\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Closed file %s\n", filename.c_str()); // remove opened file from vector - if(HGC_verbosity > 2) PLEGMA_printf("Removing %s from open files\n", filename.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Removing %s from open files\n", filename.c_str()); std::vector::iterator posix = std::find(open_files.begin(), open_files.end(), filename); assert(posix != open_files.end()); open_files.erase(posix); @@ -619,14 +619,14 @@ class HDF5 { if(check != std::string::npos) return write_attribute(object.substr(check+1), attr_name, attr_value, path+"/"+object.substr(0,check)); - if(HGC_verbosity > 2) PLEGMA_printf("Going to write attribute %s in path %s \n", attr_name.c_str(), + if(HGC.verbosity > 2) PLEGMA_printf("Going to write attribute %s in path %s \n", attr_name.c_str(), path.c_str()); cd(path); _write_attribute(object, attr_name, attr_value); - if(HGC_verbosity > 2) PLEGMA_printf("%s: written attribute %s: %s\n", object.c_str(), attr_name.c_str(), attr_value.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("%s: written attribute %s: %s\n", object.c_str(), attr_name.c_str(), attr_value.c_str()); cd("-"); } @@ -647,9 +647,9 @@ class HDF5 { if(check != std::string::npos) return write_dataset(name.substr(check+1), buf, shape, lshape, start, (name[0]=='/' ? "/" : path)+"/"+name.substr(0,check)); - if(HGC_verbosity > 2) PLEGMA_printf("Going to write dataset %s in path %s \n", name.c_str(), + if(HGC.verbosity > 2) PLEGMA_printf("Going to write dataset %s in path %s \n", name.c_str(), path.c_str()); - if(HGC_verbosity > 3) printf("RANK(%d) Dataset shape=(%s), lshape=(%s), start=(%s)\n", getRank(), + if(HGC.verbosity > 3) printf("RANK(%d) Dataset shape=(%s), lshape=(%s), start=(%s)\n", getRank(), toString(shape).c_str(), toString(lshape).c_str(), toString(start).c_str()); cd(path); @@ -673,7 +673,7 @@ class HDF5 { else{ _write_dataset_parallel(name,buf,shape,lshape,start); } - if(HGC_verbosity > 2) PLEGMA_printf("Written dataset %s in %s mode\n", name.c_str(), + if(HGC.verbosity > 2) PLEGMA_printf("Written dataset %s in %s mode\n", name.c_str(), (lshape.empty() || comm_size == 1) ? "single" : "parallel"); } cd("-"); diff --git a/include/io/PLEGMA_lime.h b/include/io/PLEGMA_lime.h index 4d70a5a2..2d443d93 100644 --- a/include/io/PLEGMA_lime.h +++ b/include/io/PLEGMA_lime.h @@ -71,13 +71,13 @@ static void print_xlf_info(LimeReader *limereader) { std::string css = lime_data; if(css.empty()) return; std::stringstream ss(css); - if(HGC_verbosity>1) PLEGMA_printf("Begin LIME header,...\n"); + if(HGC.verbosity>1) PLEGMA_printf("Begin LIME header,...\n"); while(ss.good()){ std::string substr; getline( ss, substr, ',' ); - if(HGC_verbosity>1) PLEGMA_printf("%s\n",substr.c_str()); + if(HGC.verbosity>1) PLEGMA_printf("%s\n",substr.c_str()); } - if(HGC_verbosity>1) PLEGMA_printf("End LIME header.\n"); + if(HGC.verbosity>1) PLEGMA_printf("End LIME header.\n"); hostFree(lime_data, lime_data_size+1); } @@ -89,7 +89,7 @@ bool getValueFromXML(std::string str, std::string toMatch, T &value){ while(ss.good()){ std::string line; getline(ss,line,'\n'); - if(HGC_verbosity > 2) PLEGMA_printf("Extract line: %s\n",line.c_str()); + if(HGC.verbosity > 2) PLEGMA_printf("Extract line: %s\n",line.c_str()); if(line.empty()) PLEGMA_error("Problem with extracting from LIME XML\n Message:\n %s",str.c_str()); line = line.substr(line.find_first_not_of(" \t"),line.find_last_not_of(" \t")-line.find_first_not_of(" \t")+1); if(line.find(toMatch) != std::string::npos){ @@ -128,7 +128,7 @@ static void get_ildg_info(LimeReader *limereader, int &prec, int &dof){ for(int i = 0; i < N_DIMS; i++){ passCheck = getValueFromXML(string_lime_data, "l"+xyzt[i], ll); if(!passCheck) PLEGMA_error("LIME: Cannot extract Lattice extend for %s-direction from the ildg format",xyzt[i].c_str()); - if(ll != HGC_totalL[i]) PLEGMA_error("LIME: Read l%s different from HGC_totalL[%d], (%d != %d)\n",xyzt[i].c_str(),i,ll,HGC_totalL[i]); + if(ll != HGC.totalL[i]) PLEGMA_error("LIME: Read l%s different from HGC_totalL[%d], (%d != %d)\n",xyzt[i].c_str(),i,ll,HGC.totalL[i]); } passCheck = getValueFromXML(string_lime_data,"dof",dof); if(!passCheck){ @@ -186,17 +186,17 @@ static void write_binary_to_lime(std::string filename, FILE *fid, LimeWriter *li std::string msg_tmp = "X"; MPI_Offset offset; if(comm_rank() == 0){ - write_lime_header_type(limewriter,header,HGC_totalVolume*dof*2*sizeof(Float),0,0); // make one fake record write to set the offset + write_lime_header_type(limewriter,header,HGC.totalVolume*dof*2*sizeof(Float),0,0); // make one fake record write to set the offset write_lime_header_message(limewriter,msg_tmp); offset = ftell(fid)-1; fclose(fid); } comm_barrier(); - int mpiErr = MPI_Bcast(&offset,sizeof(MPI_Offset),MPI_BYTE,0,HGC_fullComm); + int mpiErr = MPI_Bcast(&offset,sizeof(MPI_Offset),MPI_BYTE,0,HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); Float *ftmp; - long int sizeVec=((long int) dof)*HGC_localVolume; + long int sizeVec=((long int) dof)*HGC.localVolume; hostMalloc(ftmp, sizeVec*2*sizeof(Float)); MPI_Datatype subblock; //MPI-type, (N_DIMS+1)d subarray @@ -204,9 +204,9 @@ static void write_binary_to_lime(std::string filename, FILE *fid, LimeWriter *li MPI_Status status; int sizes[N_DIMS+1], lsizes[N_DIMS+1], starts[N_DIMS+1]; for(int i=0; i 2147483648) PLEGMA_warning("Be careful for possible integer overflow in MPI_File_read_all function"); @@ -289,10 +289,10 @@ static void read_binary_from_lime(std::string filename, FILE *fid, LimeReader *l else PLEGMA_error("Cannot byte swap with this precision"); } - for(size_t i = 0; i < HGC_localVolume; i++) { + for(size_t i = 0; i < HGC.localVolume; i++) { for(int s = 0; s < dof; s++) { - data[(s*HGC_localVolume + i)*2 + 0] = ftmp[((long int) i)*dof*2 +s*2+0]; - data[(s*HGC_localVolume + i)*2 + 1] = ftmp[((long int) i)*dof*2 +s*2+1]; + data[(s*HGC.localVolume + i)*2 + 0] = ftmp[((long int) i)*dof*2 +s*2+0]; + data[(s*HGC.localVolume + i)*2 + 1] = ftmp[((long int) i)*dof*2 +s*2+1]; } } hostFree(ftmp, sizeVec*2*sizeof(Float)); diff --git a/include/target/hip/PLEGMA_hipBLAS.h b/include/target/hip/PLEGMA_hipBLAS.h index 1120795c..79a11b3f 100644 --- a/include/target/hip/PLEGMA_hipBLAS.h +++ b/include/target/hip/PLEGMA_hipBLAS.h @@ -8,13 +8,13 @@ namespace cuBLAS{ template<> inline void axpy(int NN, float val[2], float *x, float *y){ hipblasComplex cu_val(val[0],val[1]); - hipblasStatus_t error = hipblasCaxpy(HGC_hipblas_handle,NN, &cu_val, (hipblasComplex*) x, 1, (hipblasComplex*) y, 1); + hipblasStatus_t error = hipblasCaxpy(HGC.hipblas_handle,NN, &cu_val, (hipblasComplex*) x, 1, (hipblasComplex*) y, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCaxpy failed with error %d", error); } template<> inline void axpy(int NN, double val[2], double *x, double *y){ hipblasDoubleComplex cu_val(val[0],val[1]); - hipblasStatus_t error = hipblasZaxpy(HGC_hipblas_handle, NN, &cu_val,(hipblasDoubleComplex*) x, 1, (hipblasDoubleComplex*) y, 1); + hipblasStatus_t error = hipblasZaxpy(HGC.hipblas_handle, NN, &cu_val,(hipblasDoubleComplex*) x, 1, (hipblasDoubleComplex*) y, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasZaxpy failed with error %d", error); } @@ -23,12 +23,12 @@ namespace cuBLAS{ inline void scal(int NN, const Float val, Float *x); template<> inline void scal(int NN, const float val, float *x){ - hipblasStatus_t error = hipblasCsscal(HGC_hipblas_handle, NN, &val, (hipblasComplex*) x, 1); + hipblasStatus_t error = hipblasCsscal(HGC.hipblas_handle, NN, &val, (hipblasComplex*) x, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCsscal failed with error %d", error); } template<> inline void scal(int NN, const double val, double *x){ - hipblasStatus_t error = hipblasZdscal(HGC_hipblas_handle, NN, &val, (hipblasDoubleComplex*) x, 1); + hipblasStatus_t error = hipblasZdscal(HGC.hipblas_handle, NN, &val, (hipblasDoubleComplex*) x, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasZdscal failed with error %d", error); } //------------------------------------------------------------------ @@ -37,13 +37,13 @@ namespace cuBLAS{ template<> inline void cscal(int NN, const float val[2], float *x){ hipblasComplex cu_val(val[0],val[1]); - hipblasStatus_t error = hipblasCscal(HGC_hipblas_handle, NN, &cu_val, (hipblasComplex*) x, 1); + hipblasStatus_t error = hipblasCscal(HGC.hipblas_handle, NN, &cu_val, (hipblasComplex*) x, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCscal failed with error %d", error); } template<> inline void cscal(int NN, const double val[2], double *x){ hipblasDoubleComplex cu_val(val[0],val[1]); - hipblasStatus_t error = hipblasZscal(HGC_hipblas_handle, NN, &cu_val, (hipblasDoubleComplex*) x, 1); + hipblasStatus_t error = hipblasZscal(HGC.hipblas_handle, NN, &cu_val, (hipblasDoubleComplex*) x, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasZscal failed with error %d", error); } //----------------------------------------------------------------- @@ -52,14 +52,14 @@ namespace cuBLAS{ template<> inline std::complex dot(int NN, const float *x, const float *y){ hipblasComplex cu_res; - hipblasStatus_t error = hipblasCdotc(HGC_hipblas_handle, NN,(hipblasComplex*)x, 1, (hipblasComplex*)y,1,&cu_res); + hipblasStatus_t error = hipblasCdotc(HGC.hipblas_handle, NN,(hipblasComplex*)x, 1, (hipblasComplex*)y,1,&cu_res); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCdotc failed with error %d", error); return std::complex(cu_res.real(),cu_res.imag()); } template<> inline std::complex dot(int NN, const double *x, const double *y){ hipblasDoubleComplex cu_res; - hipblasStatus_t error = hipblasZdotc(HGC_hipblas_handle, NN,(hipblasDoubleComplex*)x, 1, (hipblasDoubleComplex*)y,1,&cu_res); + hipblasStatus_t error = hipblasZdotc(HGC.hipblas_handle, NN,(hipblasDoubleComplex*)x, 1, (hipblasDoubleComplex*)y,1,&cu_res); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasZdotc failed with error %d", error); return std::complex(cu_res.real(),cu_res.imag()); } @@ -78,14 +78,14 @@ namespace cuBLAS{ template<> inline float norm(int NN, const float *x){ float res; - hipblasStatus_t error = hipblasScnrm2(HGC_hipblas_handle, NN, (hipblasComplex*)x, 1, &res); + hipblasStatus_t error = hipblasScnrm2(HGC.hipblas_handle, NN, (hipblasComplex*)x, 1, &res); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCdotc failed with error %d", error); return res; } template<> inline double norm(int NN, const double *x){ double res; - hipblasStatus_t error = hipblasDznrm2(HGC_hipblas_handle, NN, (hipblasDoubleComplex*)x, 1, &res); + hipblasStatus_t error = hipblasDznrm2(HGC.hipblas_handle, NN, (hipblasDoubleComplex*)x, 1, &res); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCdotc failed with error %d", error); return res; } @@ -110,7 +110,7 @@ namespace cuBLAS{ hipblasComplex cu_alpha(alpha[0],alpha[1]); hipblasComplex cu_beta(beta[0],beta[1]); switch(trans){case(NOTRANS): Oper=HIPBLAS_OP_N; break; case(TRANS): Oper=HIPBLAS_OP_T; break; case(DAGGER): Oper=HIPBLAS_OP_C; break;} - hipblasStatus_t error = hipblasCgemv(HGC_hipblas_handle, Oper, m, n, &cu_alpha, (hipblasComplex*) A, m, (hipblasComplex*) x, 1, &cu_beta, (hipblasComplex*) y, 1); + hipblasStatus_t error = hipblasCgemv(HGC.hipblas_handle, Oper, m, n, &cu_alpha, (hipblasComplex*) A, m, (hipblasComplex*) x, 1, &cu_beta, (hipblasComplex*) y, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasCgemv failed with error %d", error); } @@ -120,7 +120,7 @@ namespace cuBLAS{ hipblasDoubleComplex cu_alpha(alpha[0],alpha[1]); hipblasDoubleComplex cu_beta(beta[0],beta[1]); switch(trans){case(NOTRANS): Oper=HIPBLAS_OP_N; break; case(TRANS): Oper=HIPBLAS_OP_T; break; case(DAGGER): Oper=HIPBLAS_OP_C; break;} - hipblasStatus_t error = hipblasZgemv(HGC_hipblas_handle, Oper, m, n, &cu_alpha, (hipblasDoubleComplex*) A, m,(hipblasDoubleComplex*) x, 1, &cu_beta,(hipblasDoubleComplex*) y, 1); + hipblasStatus_t error = hipblasZgemv(HGC.hipblas_handle, Oper, m, n, &cu_alpha, (hipblasDoubleComplex*) A, m,(hipblasDoubleComplex*) x, 1, &cu_beta,(hipblasDoubleComplex*) y, 1); if(error != HIPBLAS_STATUS_SUCCESS) PLEGMA_error("hipblasZgemv failed with error %d", error); } diff --git a/lib/kernels/PLEGMA_kernel_getSet.cuh b/lib/kernels/PLEGMA_kernel_getSet.cuh index b022e7b5..b18058ea 100644 --- a/lib/kernels/PLEGMA_kernel_getSet.cuh +++ b/lib/kernels/PLEGMA_kernel_getSet.cuh @@ -1,34 +1,34 @@ #ifndef PLEGMA_KERNEL_TEXTURE_CUH #define PLEGMA_KERNEL_TEXTURE_CUH -#define GET_ID(sid) {(sid) % DGC_localL[0], \ - ((sid)/DGC_localL[0]) % DGC_localL[1], \ - ((sid)/DGC_localL[0]/DGC_localL[1]) % DGC_localL[2], \ - ((sid)/DGC_localL[0]/DGC_localL[1]/DGC_localL[2]) % DGC_localL[3] } - -#define GET_ID_ZYX(sid) {(sid) % DGC_localL[0], \ - ((sid)/DGC_localL[0]) % DGC_localL[1], \ - ((sid)/DGC_localL[0]/DGC_localL[1]) % DGC_localL[2] } - -#define LEXIC_ID(id) LEXIC(id[3],id[2],id[1],id[0],DGC_localL) -#define LEXIC_3D(i,id)(i==0 ? LEXIC_TZY(id[3],id[2],id[1],DGC_localL) : \ - (i==1 ? LEXIC_TZX(id[3],id[2],id[0],DGC_localL) : \ - (i==2 ? LEXIC_TYX(id[3],id[1],id[0],DGC_localL) : \ - LEXIC_ZYX(id[2],id[1],id[0],DGC_localL)))) -#define LEXIC_NOX(j,id)( j==1 ? LEXIC_TZ(id[3],id[2],DGC_localL) : \ - ( j==2 ? LEXIC_TY(id[3],id[1],DGC_localL) : \ - LEXIC_ZY(id[2],id[1],DGC_localL) ) ) -#define LEXIC_NOY(j,id)( j==0 ? LEXIC_TZ(id[3],id[2],DGC_localL) : \ - ( j==2 ? LEXIC_TX(id[3],id[0],DGC_localL) : \ - LEXIC_ZX(id[2],id[0],DGC_localL) ) ) -#define LEXIC_NOZ(j,id)( j==0 ? LEXIC_TY(id[3],id[1],DGC_localL) : \ - ( j==1 ? LEXIC_TX(id[3],id[0],DGC_localL) : \ - LEXIC_YX(id[1],id[0],DGC_localL) ) ) -#define LEXIC_NOT(j,id)( j==0 ? LEXIC_ZY(id[2],id[1],DGC_localL) : \ - ( j==1 ? LEXIC_ZX(id[2],id[0],DGC_localL) : \ - LEXIC_YX(id[1],id[0],DGC_localL) ) ) - -#define LEXIC_ID_3D4D(id,is4D) (is4D ? LEXIC_ID(id) : LEXIC_ZYX(id[2],id[1],id[0],DGC_localL)) +#define GET_ID(sid) {(sid) % DGC->localL[0], \ + ((sid)/DGC->localL[0]) % DGC->localL[1], \ + ((sid)/DGC->localL[0]/DGC->localL[1]) % DGC->localL[2], \ + ((sid)/DGC->localL[0]/DGC->localL[1]/DGC->localL[2]) % DGC->localL[3] } + +#define GET_ID_ZYX(sid) {(sid) % DGC->localL[0], \ + ((sid)/DGC->localL[0]) % DGC->localL[1], \ + ((sid)/DGC->localL[0]/DGC->localL[1]) % DGC->localL[2] } + +#define LEXIC_ID(id) LEXIC(id[3],id[2],id[1],id[0],DGC->localL) +#define LEXIC_3D(i,id)(i==0 ? LEXIC_TZY(id[3],id[2],id[1],DGC->localL) : \ + (i==1 ? LEXIC_TZX(id[3],id[2],id[0],DGC->localL) : \ + (i==2 ? LEXIC_TYX(id[3],id[1],id[0],DGC->localL) : \ + LEXIC_ZYX(id[2],id[1],id[0],DGC->localL)))) +#define LEXIC_NOX(j,id)( j==1 ? LEXIC_TZ(id[3],id[2],DGC->localL) : \ + ( j==2 ? LEXIC_TY(id[3],id[1],DGC->localL) : \ + LEXIC_ZY(id[2],id[1],DGC->localL) ) ) +#define LEXIC_NOY(j,id)( j==0 ? LEXIC_TZ(id[3],id[2],DGC->localL) : \ + ( j==2 ? LEXIC_TX(id[3],id[0],DGC->localL) : \ + LEXIC_ZX(id[2],id[0],DGC->localL) ) ) +#define LEXIC_NOZ(j,id)( j==0 ? LEXIC_TY(id[3],id[1],DGC->localL) : \ + ( j==1 ? LEXIC_TX(id[3],id[0],DGC->localL) : \ + LEXIC_YX(id[1],id[0],DGC->localL) ) ) +#define LEXIC_NOT(j,id)( j==0 ? LEXIC_ZY(id[2],id[1],DGC->localL) : \ + ( j==1 ? LEXIC_ZX(id[2],id[0],DGC->localL) : \ + LEXIC_YX(id[1],id[0],DGC->localL) ) ) + +#define LEXIC_ID_3D4D(id,is4D) (is4D ? LEXIC_ID(id) : LEXIC_ZYX(id[2],id[1],id[0],DGC->localL)) // assuming i!=j #define LEXIC_2D(i,j,id)( i==0 ? LEXIC_NOX(j,id) : \ @@ -39,30 +39,30 @@ ( i!=1 && j!=1 && k!=1 ? id[1] : \ ( i!=2 && j!=2 && k!=2 ? id[2] : id[3] ))) -#define ID_PLUS(i,id) ((id[i]+1)%DGC_localL[i]) -#define ID_MINUS(i,id) ((id[i]+DGC_localL[i]-1)%DGC_localL[i]) - -#define LEXIC_PLUS(i,id)(i==0 ? LEXIC(id[3],id[2],id[1],ID_PLUS(i,id),DGC_localL) : \ - (i==1 ? LEXIC(id[3],id[2],ID_PLUS(i,id),id[0],DGC_localL) : \ - (i==2 ? LEXIC(id[3],ID_PLUS(i,id),id[1],id[0],DGC_localL) : \ - LEXIC(ID_PLUS(i,id),id[2],id[1],id[0],DGC_localL)))) -#define LEXIC_MINUS(i,id)(i==0 ? LEXIC(id[3],id[2],id[1],ID_MINUS(i,id),DGC_localL) : \ - (i==1 ? LEXIC(id[3],id[2],ID_MINUS(i,id),id[0],DGC_localL) : \ - (i==2 ? LEXIC(id[3],ID_MINUS(i,id),id[1],id[0],DGC_localL) : \ - LEXIC(ID_MINUS(i,id),id[2],id[1],id[0],DGC_localL)))) - -#define LEXIC_3D_PLUS(i,id)(i==0 ? LEXIC_ZYX(id[2],id[1],ID_PLUS(i,id),DGC_localL) : \ - (i==1 ? LEXIC_ZYX(id[2],ID_PLUS(i,id),id[0],DGC_localL) : \ - LEXIC_ZYX(ID_PLUS(i,id),id[1],id[0],DGC_localL))) -#define LEXIC_3D_MINUS(i,id)(i==0 ? LEXIC_ZYX(id[2],id[1],ID_MINUS(i,id),DGC_localL) : \ - (i==1 ? LEXIC_ZYX(id[2],ID_MINUS(i,id),id[0],DGC_localL) : \ - LEXIC_ZYX(ID_MINUS(i,id),id[1],id[0],DGC_localL))) +#define ID_PLUS(i,id) ((id[i]+1)%DGC->localL[i]) +#define ID_MINUS(i,id) ((id[i]+DGC->localL[i]-1)%DGC->localL[i]) + +#define LEXIC_PLUS(i,id)(i==0 ? LEXIC(id[3],id[2],id[1],ID_PLUS(i,id),DGC->localL) : \ + (i==1 ? LEXIC(id[3],id[2],ID_PLUS(i,id),id[0],DGC->localL) : \ + (i==2 ? LEXIC(id[3],ID_PLUS(i,id),id[1],id[0],DGC->localL) : \ + LEXIC(ID_PLUS(i,id),id[2],id[1],id[0],DGC->localL)))) +#define LEXIC_MINUS(i,id)(i==0 ? LEXIC(id[3],id[2],id[1],ID_MINUS(i,id),DGC->localL) : \ + (i==1 ? LEXIC(id[3],id[2],ID_MINUS(i,id),id[0],DGC->localL) : \ + (i==2 ? LEXIC(id[3],ID_MINUS(i,id),id[1],id[0],DGC->localL) : \ + LEXIC(ID_MINUS(i,id),id[2],id[1],id[0],DGC->localL)))) + +#define LEXIC_3D_PLUS(i,id)(i==0 ? LEXIC_ZYX(id[2],id[1],ID_PLUS(i,id),DGC->localL) : \ + (i==1 ? LEXIC_ZYX(id[2],ID_PLUS(i,id),id[0],DGC->localL) : \ + LEXIC_ZYX(ID_PLUS(i,id),id[1],id[0],DGC->localL))) +#define LEXIC_3D_MINUS(i,id)(i==0 ? LEXIC_ZYX(id[2],id[1],ID_MINUS(i,id),DGC->localL) : \ + (i==1 ? LEXIC_ZYX(id[2],ID_MINUS(i,id),id[0],DGC->localL) : \ + LEXIC_ZYX(ID_MINUS(i,id),id[1],id[0],DGC->localL))) #define LEXIC_3D4D_PLUS(i,id,is4D) (is4D ? LEXIC_PLUS(i,id) : LEXIC_3D_PLUS(i,id)) #define LEXIC_3D4D_MINUS(i,id,is4D) (is4D ? LEXIC_MINUS(i,id) : LEXIC_3D_MINUS(i,id)) #define IS_MINUS_GHOST(i,id) (DGC_dimBreak[i] == true && id[i] == 0) -#define IS_PLUS_GHOST(i,id) (DGC_dimBreak[i] == true && id[i] == (DGC_localL[i]-1)) +#define IS_PLUS_GHOST(i,id) (DGC_dimBreak[i] == true && id[i] == (DGC->localL[i]-1)) namespace plegma { @@ -92,7 +92,7 @@ namespace plegma { inline __host__ __device__ size_t sideGhostVolume() const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_sideGhostVolume : DGC_sideGhostVolume3D; + return is4D ? DGC->sideGhostVolume : DGC->sideGhostVolume3D; #else return is4D ? HGC_sideGhostVolume : HGC_sideGhostVolume3D; #endif @@ -100,7 +100,7 @@ namespace plegma { inline __host__ __device__ size_t sideGhostL(const short& dir) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_surface3D[dir] : (DGC_surface3D[dir]/DGC_localL[DIM_T]); + return is4D ? DGC_surface3D[dir] : (DGC_surface3D[dir]/DGC->localL[DIM_T]); #else return is4D ? HGC_surface3D[dir] : (HGC_surface3D[dir]/HGC_localL[DIM_T]); #endif @@ -108,7 +108,7 @@ namespace plegma { inline __host__ __device__ size_t sideGhostShift(const short& dir, const ORIENTATION& sign) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_sideGhost[dir][sign] : (DGC_sideGhost[dir][sign]/DGC_localL[DIM_T]); + return is4D ? DGC->sideGhost[dir][sign] : (DGC->sideGhost[dir][sign]/DGC->localL[DIM_T]); #else return is4D ? HGC_sideGhost[dir][sign] : (HGC_sideGhost[dir][sign]/HGC_localL[DIM_T]); #endif @@ -116,7 +116,7 @@ namespace plegma { inline __host__ __device__ size_t cornerGhostVolume() const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_cornerGhostVolume : DGC_cornerGhostVolume3D; + return is4D ? DGC->cornerGhostVolume : DGC->cornerGhostVolume3D; #else return is4D ? HGC_cornerGhostVolume : HGC_cornerGhostVolume3D; #endif @@ -124,7 +124,7 @@ namespace plegma { inline __host__ __device__ size_t cornerGhostL(const short& dir1, const short& dir2) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_surface2D[OFF2(dir1,dir2)] : (DGC_surface2D[OFF2(dir1,dir2)]/DGC_localL[DIM_T]); + return is4D ? DGC->surface2D[OFF2(dir1,dir2)] : (DGC->surface2D[OFF2(dir1,dir2)]/DGC->localL[DIM_T]); #else return is4D ? HGC_surface2D[OFF2(dir1,dir2)] : (HGC_surface2D[OFF2(dir1,dir2)]/HGC_localL[DIM_T]); #endif @@ -132,7 +132,7 @@ namespace plegma { inline __host__ __device__ size_t vertexGhostL(const short& dir1, const short& dir2, const short& dir3) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_surface1D[OFF3(dir1,dir2,dir3)] : (DGC_surface1D[OFF3(dir1,dir2,dir3)]/DGC_localL[DIM_T]); + return is4D ? DGC->surface1D[OFF3(dir1,dir2,dir3)] : (DGC->surface1D[OFF3(dir1,dir2,dir3)]/DGC->localL[DIM_T]); #else return is4D ? HGC_surface1D[OFF3(dir1,dir2,dir3)] : (HGC_surface1D[OFF3(dir1,dir2,dir3)]/HGC_localL[DIM_T]); #endif @@ -141,7 +141,7 @@ namespace plegma { inline __host__ __device__ size_t cornerGhostShift(const short& dir1, const short& dir2, const ORIENTATION& sign1, const ORIENTATION& sign2) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (DGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/DGC_localL[DIM_T]); + return is4D ? DGC->cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (DGC->cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/DGC->localL[DIM_T]); #else return is4D ? HGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (HGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/HGC_localL[DIM_T]); #endif @@ -150,7 +150,7 @@ namespace plegma { inline __host__ __device__ size_t vertexGhostShift(const short& dir1, const short& dir2, const short& dir3, const ORIENTATION& sign1, const ORIENTATION& sign2, const ORIENTATION& sign3) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (DGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/DGC_localL[DIM_T]); + return is4D ? DGC->vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (DGC->vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/DGC->localL[DIM_T]); #else return is4D ? HGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (HGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/HGC_localL[DIM_T]); #endif @@ -248,7 +248,7 @@ namespace plegma { } template<> inline __device__ void sidStride::shift(const short& dirPlus1, const short& dirPlus2) { - if(dirPlus1 == dirPlus2 && DGC_dimBreak[dirPlus1]) { + if(dirPlus1 == dirPlus2 && DGC->dimBreak[dirPlus1]) { printf(" !!! ERROR: in PlusPlus we cannot access the second neighbour !!!"); } else { size_t id[4] = GET_ID(sid); @@ -270,7 +270,7 @@ namespace plegma { } template<> inline __device__ void sidStride::shift(const short& dirMinus1, const short& dirMinus2) { - if(dirMinus1 == dirMinus2 && DGC_dimBreak[dirMinus1]) { + if(dirMinus1 == dirMinus2 && DGC->dimBreak[dirMinus1]) { printf(" !!! ERROR: in MinusMinus we cannot access the second neighbour !!!"); } else { size_t id[4] = GET_ID(sid); diff --git a/utils/PLEGMA_utils.cpp b/utils/PLEGMA_utils.cpp index c7ff2094..14a31246 100644 --- a/utils/PLEGMA_utils.cpp +++ b/utils/PLEGMA_utils.cpp @@ -14,11 +14,11 @@ using namespace quda; static bool isInitOpt = false; void initializeOptions(int argc, char **argv, bool withQuda, std::vector listOptPLEGMA){ - HGC_options = new Options(argc,argv); + HGC.options = new Options(argc,argv); // initialize QMP/MPI, QUDA comms grid and RNG // we need to do it first for enabling the printing - HGC_options->setForced("procs","Set number of processors (X Y Z T), e.g. 1 1 1 1", 0, + HGC.options->setForced("procs","Set number of processors (X Y Z T), e.g. 1 1 1 1", 0, procs[0], procs[1], procs[2], procs[3]); for(int i=0; i<4; i++) if( procs[i] <= 0 ) @@ -28,10 +28,10 @@ void initializeOptions(int argc, char **argv, bool withQuda, std::vector0) infoQuda(); } @@ -84,7 +84,7 @@ void updateOptions(WHICHFLAVOR fl){ void initializePLEGMA() { if(!isInitOpt){fprintf(stderr,"initializeOptions should be called before initializePLEGMA");exit(EXIT_FAILURE);} - HGC_options->close(); + HGC.options->close(); initQuda(device_number); qudaInitialized=true; // initialize PLEGMA params @@ -93,7 +93,7 @@ void initializePLEGMA() { } void finalize() { - delete HGC_options; + delete HGC.options; PLEGMA_end(); saveTuneCache(false); @@ -241,11 +241,11 @@ template void applyBoundaryConditions(PLEGMA_Gauge &gauge, bool template void applyBoundaryConditions(PLEGMA_Gauge &gauge, bool antiperiodic); std::vector createR2(std::vector &vec){ - if(!HGC_init_PLEGMA_flag) PLEGMA_error("Initialize PLEGMA first"); + if(!HGC.init_PLEGMA_flag) PLEGMA_error("Initialize PLEGMA first"); if(vec.size() != 0) PLEGMA_error("The vector provided is not empty"); - for(int xx = -HGC_totalL[0]/2; xx < HGC_totalL[0]/2; xx++) - for(int yy = -HGC_totalL[1]/2; yy < HGC_totalL[1]/2; yy++) - for(int zz = -HGC_totalL[2]/2; zz < HGC_totalL[2]/2; zz++) + for(int xx = -HGC.totalL[0]/2; xx < HGC.totalL[0]/2; xx++) + for(int yy = -HGC.totalL[1]/2; yy < HGC.totalL[1]/2; yy++) + for(int zz = -HGC.totalL[2]/2; zz < HGC.totalL[2]/2; zz++) vec.push_back(xx*xx + yy*yy + zz*zz); return clearDuplicates(vec); } diff --git a/utils/QUDA_interface.cpp b/utils/QUDA_interface.cpp index caebe769..5453c7f6 100644 --- a/utils/QUDA_interface.cpp +++ b/utils/QUDA_interface.cpp @@ -70,8 +70,8 @@ void finalizeComms() void gFixingLandauOVR_QUDA(PLEGMA_Gauge &gaugeOut,PLEGMA_Gauge &gaugeIn, int type, double overelaxPar,double tolerance, int maxiter, int verbosePerSteps, int reunit_interval, int stop_theta){ - if(type == 3 && HGC_verbosity>1) PLEGMA_printf("Gauge fixing using Coulomb gauge\n"); - if(type == 4 && HGC_verbosity>1) PLEGMA_printf("Gauge fixing using Landau gauge\n"); + if(type == 3 && HGC.verbosity>1) PLEGMA_printf("Gauge fixing using Coulomb gauge\n"); + if(type == 4 && HGC.verbosity>1) PLEGMA_printf("Gauge fixing using Landau gauge\n"); if(type != 3 && type != 4) PLEGMA_error("Choose type 3 for Coulomb and type 4 for Landau\n"); QudaGaugeParam gauge_param = newQudaGaugeParam(); @@ -145,7 +145,7 @@ QUDA_solver::QUDA_solver(double mu) { mg_param.invert_param = &mg_inv_param; setMultigridParam(mg_param); checkMultigridParam(&mg_param); - if(HGC_verbosity > 2) printQudaMultigridParam(&mg_param); + if(HGC.verbosity > 2) printQudaMultigridParam(&mg_param); mg_param.invert_param->mu = mu; #ifdef QUDA_INCLUDES_COMMIT_775a033 @@ -162,7 +162,7 @@ QUDA_solver::QUDA_solver(double mu) { setInvertParam(inv_param); checkInvertParam(&inv_param); - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { printQudaInvertParam(&inv_param); } if(inv_param.gamma_basis != QUDA_UKQCD_GAMMA_BASIS) @@ -197,7 +197,7 @@ QUDA_solver::QUDA_solver(double mu) { solver = Solver::create(*solverParam, *M, *MSloppy, *MPre, *MPre, *profiler); - quda::lat_dim_t X = {HGC_localL[0], HGC_localL[1], HGC_localL[2], HGC_localL[3]}; + quda::lat_dim_t X = {HGC.localL[0], HGC.localL[1], HGC.localL[2], HGC.localL[3]}; ColorSpinorParam cpuParam(NULL, inv_param, X, pc_solution, inv_param.input_location); @@ -433,7 +433,7 @@ QUDA_dirac::QUDA_dirac(QudaDslashType dslashType): if (dParam.gauge == nullptr) PLEGMA_error("Gauge field not allocated"); if (dParam. clover == nullptr && ((inv_param.dslash_type == QUDA_CLOVER_WILSON_DSLASH) || (inv_param.dslash_type == QUDA_TWISTED_CLOVER_DSLASH))) PLEGMA_error("Clover field not allocated"); D = Dirac::create(dParam); - quda::lat_dim_t X = {HGC_localL[0], HGC_localL[1], HGC_localL[2], HGC_localL[3]}; + quda::lat_dim_t X = {HGC.localL[0], HGC.localL[1], HGC.localL[2], HGC.localL[3]}; ColorSpinorParam cpuParam(nullptr, inv_param, X, false, inv_param.input_location); @@ -483,7 +483,7 @@ void QUDA_dirac::apply(Float *dout, Float *din, QudaMassNormalization normType){ apply(); plegma::copyFromQUDA(dout,out); if (normType == QUDA_MASS_NORMALIZATION || normType == QUDA_ASYMMETRIC_MASS_NORMALIZATION) - cuBLAS::scal(N_SPINS*N_COLS*HGC_localVolume, (Float) (1./(2*inv_param.kappa)), dout); + cuBLAS::scal(N_SPINS*N_COLS*HGC.localVolume, (Float) (1./(2*inv_param.kappa)), dout); } template void QUDA_dirac::apply(float *dout, float *din, QudaMassNormalization normType); From 0c4de37d5ae33fb83345350be1503e18dd7c2dde Mon Sep 17 00:00:00 2001 From: Ferenc Pittler Date: Wed, 22 Mar 2023 14:25:33 +0100 Subject: [PATCH 2/5] remove dependence of global constant --- include/PLEGMA_global.h | 17 +- include/global/PLEGMA_global_constants.h | 17 +- include/global/PLEGMA_prints.hpp | 66 +- include/global/PLEGMA_structs.h | 64 +- include/global/PLEGMA_templates.h | 14 +- include/target/cuda/PLEGMA_cuBLAS.h | 24 +- lib/PLEGMA.cu | 186 +-- lib/PLEGMA_Correlator.cu | 52 +- lib/PLEGMA_FT.cu | 64 +- lib/PLEGMA_Field.cu | 208 +-- lib/PLEGMA_Gauge.cu | 12 +- lib/PLEGMA_Propagator.cu | 106 +- lib/PLEGMA_QLoops.cu | 4 +- lib/PLEGMA_ScattCorrelator.cu | 56 +- lib/PLEGMA_U1Gauge.cu | 18 +- lib/PLEGMA_Vector.cu | 120 +- lib/kernels/PLEGMA_FT.cuh | 36 +- lib/kernels/PLEGMA_QWF.cuh | 40 +- lib/kernels/PLEGMA_Random.cuh | 2 +- lib/kernels/PLEGMA_TMDWF.cuh | 20 +- lib/kernels/PLEGMA_WFlow.cuh | 4 +- lib/kernels/PLEGMA_baryons.cuh | 40 +- lib/kernels/PLEGMA_baryons_udsc.cu | 32 +- lib/kernels/PLEGMA_bcud_tetraquarks.cu | 22 +- .../PLEGMA_bcud_tetraquarks_stochastic.cu | 22 +- lib/kernels/PLEGMA_field_utils.cuh | 38 +- lib/kernels/PLEGMA_gFixing.cuh | 2 +- lib/kernels/PLEGMA_gammas_scatt.cuh | 4 +- lib/kernels/PLEGMA_gaussian_smearing.cuh | 8 +- lib/kernels/PLEGMA_heavy_light_tetraquarks.cu | 22 +- ...avy_light_tetraquarks_open_contractions.cu | 20 +- ...EGMA_heavy_light_tetraquarks_stochastic.cu | 22 +- lib/kernels/PLEGMA_kernel_getSet.cuh | 26 +- lib/kernels/PLEGMA_kernel_tuner.cuh | 7 +- lib/kernels/PLEGMA_kernel_utils.cuh | 14 +- lib/kernels/PLEGMA_mesons.cuh | 62 +- lib/kernels/PLEGMA_mesonsAll.cuh | 20 +- lib/kernels/PLEGMA_mesonsNew.cuh | 20 +- lib/kernels/PLEGMA_plaquette.cuh | 4 +- lib/kernels/PLEGMA_plaquetteCorners.cuh | 4 +- lib/kernels/PLEGMA_propagator_utils.cuh | 20 +- lib/kernels/PLEGMA_scattreductions.cuh | 54 +- lib/kernels/PLEGMA_scattreductionsPiPi.cuh | 18 +- lib/kernels/PLEGMA_scattreductionsT1.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsT2.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV2.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV3.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV4.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV5.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV6.cuh | 6 +- lib/kernels/PLEGMA_scattreductionsV6_red.cuh | 6 +- lib/kernels/PLEGMA_su3field.cuh | 2 +- lib/kernels/PLEGMA_threep_local.cu | 20 +- lib/kernels/PLEGMA_threep_noe.cu | 20 +- lib/kernels/PLEGMA_threep_oneD.cu | 20 +- lib/kernels/PLEGMA_threep_qgq.cu | 20 +- lib/kernels/PLEGMA_threep_staple.cu | 20 +- lib/kernels/PLEGMA_threep_threeD_part1.cu | 18 +- lib/kernels/PLEGMA_threep_threeD_part2.cu | 18 +- lib/kernels/PLEGMA_threep_threeD_part3.cu | 18 +- lib/kernels/PLEGMA_threep_threeD_part4.cu | 20 +- lib/kernels/PLEGMA_threep_twoD.cu | 20 +- lib/kernels/PLEGMA_threep_wilsonLine.cu | 20 +- lib/kernels/PLEGMA_topocharge.cuh | 6 +- lib/kernels/PLEGMA_u1gauge_utils.cuh | 2 +- lib/kernels/PLEGMA_vector_utils.cuh | 58 +- plegma/CMakeLists.txt | 2 +- plegma/nucleon_3pt_n_npi.cpp | 1244 +++++++++-------- utils/QUDA_interface.cpp | 1 + 69 files changed, 1580 insertions(+), 1608 deletions(-) diff --git a/include/PLEGMA_global.h b/include/PLEGMA_global.h index 49d9e486..3e500984 100644 --- a/include/PLEGMA_global.h +++ b/include/PLEGMA_global.h @@ -51,25 +51,30 @@ using namespace std::chrono_literals; using namespace quda; namespace plegma { - //======== PLEGMA_printf, PLEGMA_error, PLEGMA_warning =========// + +//======== PLEGMA_printf, PLEGMA_error, PLEGMA_warning =========// #include //======== Enumerations =========// #include - //======== Templated types and functions =========// +//======== Templated types and functions =========// #include - //======== Some custom data struct =========// -#include - - //======== Class for reading options from command line or file =========// +//======== Class for reading options from command line or file =========// #include + //======== Some custom data struct =========// +#include + //======== Global constants on host and device =========// #include + + + + static inline void PLEGMA_memset(void *ptr, int value, size_t count){ return qudaMemset(ptr,value,count); } diff --git a/include/global/PLEGMA_global_constants.h b/include/global/PLEGMA_global_constants.h index dd6e3f9d..2f631cb0 100644 --- a/include/global/PLEGMA_global_constants.h +++ b/include/global/PLEGMA_global_constants.h @@ -78,11 +78,20 @@ void *symbolAddress; #pragma message " HGC " #ifdef ALLOCATE -struct global_vars HGC; -struct global_vars *DGC; +struct global_vars_host HGC; +struct global_vars_both *DGC_ptr; +#if defined (__NVCC__) | (__HIP__) +__constant__ struct global_vars_both DGC_const; +#endif #else -extern struct global_vars HGC; -extern struct global_vars *DGC; +//static __device__ __constant__ volatile struct global_vars_both DGCS; + +//static __device__ volatile struct global_vars_both *DGC; +#if defined (__NVCC__) | (__HIP__) +static __device__ struct global_vars_both *DGC; +#endif +extern struct global_vars_host HGC; +extern struct global_vars_both *DGC_ptr; #endif // variables visible on both host and device diff --git a/include/global/PLEGMA_prints.hpp b/include/global/PLEGMA_prints.hpp index 7e99d3b6..5faefa06 100644 --- a/include/global/PLEGMA_prints.hpp +++ b/include/global/PLEGMA_prints.hpp @@ -3,35 +3,15 @@ * inspired by QUDA. */ #pragma once - -extern bool HGC_hold_exit; // used to hold exit until all the errors have been printed -extern bool HGC_init_PLEGMA_flag; -extern struct global_vars HGC_global_vars; -extern class Options * HGC_options; +//extern struct global_vars_both HGC; +//extern bool HGC.hold_exit; // used to hold exit until all the errors have been printed +//extern bool HGC.init_PLEGMA_flag; +//extern class Options * HGC.options; #define PLEGMA_exit(value) do { \ - if(! HGC_hold_exit) { \ - if (HGC_init_PLEGMA_flag) { \ - comm_abort(value); \ - } else { \ - int init = 0; \ - MPI_Initialized(&init); \ - if(init) { \ - comm_abort(value); \ - } \ - } \ exit(value); \ - } \ } while (0) #define PLEGMA_printf(...) do { \ - if (HGC_init_PLEGMA_flag) { \ - sprintf(getPrintBuffer(), __VA_ARGS__); \ - if (getRankVerbosity()) { \ - fprintf(getOutputFile(), "%s", getOutputPrefix()); \ - fprintf(getOutputFile(), "%s", getPrintBuffer()); \ - fflush(getOutputFile()); \ - } \ - } else { \ int rank = 0; \ MPI_Initialized(&rank); \ if(rank) { \ @@ -42,13 +22,9 @@ extern class Options * HGC_options; } else { \ printf(__VA_ARGS__); \ } \ - } \ } while(0) #define PLEGMA_error(...) do { \ - HGC_hold_exit = true; \ - HGC_options->checkErrors(); \ - if (HGC_init_PLEGMA_flag) { \ fprintf(getOutputFile(), "%sERROR: ", getOutputPrefix()); \ fprintf(getOutputFile(), __VA_ARGS__); \ fprintf(getOutputFile(), " (rank %d, host %s, " __FILE__ ":%d in %s())\n", \ @@ -58,28 +34,10 @@ extern class Options * HGC_options; getLastTuneKey().volume, getLastTuneKey().aux); \ fflush(getOutputFile()); \ quda::saveTuneCache(true); \ - } else { \ - int rank = 0; \ - MPI_Initialized(&rank); \ - if(rank) { \ - MPI_Comm_rank(MPI_COMM_WORLD,&rank); \ - printf( "ERROR: "); \ - printf(__VA_ARGS__); \ - printf(" (rank %d, " __FILE__ ":%d in %s())\n", \ - rank, __LINE__, __func__); \ - } else { \ - printf( "ERROR: "); \ - printf(__VA_ARGS__); \ - printf(" (" __FILE__ ":%d in %s())\n", \ - __LINE__, __func__); \ - } \ - } \ - HGC_hold_exit = false; \ - PLEGMA_exit(1); \ + PLEGMA_exit(1); \ } while(0) #define PLEGMA_warning(...) do { \ - if (HGC_init_PLEGMA_flag) { \ if (getVerbosity() > QUDA_SILENT) { \ sprintf(getPrintBuffer(), __VA_ARGS__); \ if (getRankVerbosity()) { \ @@ -89,20 +47,6 @@ extern class Options * HGC_options; fflush(getOutputFile()); \ } \ } \ - } else { \ - int rank = 0; \ - MPI_Initialized(&rank); \ - if(rank) { \ - MPI_Comm_rank(MPI_COMM_WORLD,&rank); \ - if(rank==0) { \ - printf("WARNING: "); \ - printf(__VA_ARGS__); \ - } \ - } else { \ - printf("WARNING: "); \ - printf(__VA_ARGS__); \ - } \ - } \ } while (0) diff --git a/include/global/PLEGMA_structs.h b/include/global/PLEGMA_structs.h index c88e36ca..76f6afc5 100644 --- a/include/global/PLEGMA_structs.h +++ b/include/global/PLEGMA_structs.h @@ -5,6 +5,7 @@ #include #endif +#ifdef __HIP__ #define HIP_CHECK(error) \ { \ hipError_t localError = error; \ @@ -13,6 +14,17 @@ PLEGMA_printf("FILE: %s, LINE %d\n", __FILE__, __LINE__ ); \ } \ } +#else +#define CUDA_CHECK(error) \ + { \ + cudaError_t localError = error; \ + if ((localError != cudaSuccess) && (localError != cudaErrorPeerAccessAlreadyEnabled)) { \ + PLEGMA_printf("Error: %s, Code %d\n", cudaGetErrorString(localError), localError); \ + PLEGMA_printf("FILE: %s, LINE %d\n", __FILE__, __LINE__ ); \ + } \ + } +#endif + template struct texture; @@ -91,7 +103,7 @@ struct pointer_holder { if (err != cudaSuccess) { errorQuda("Failed to copy constant host memory of size to device %zu \n", size); } -#else +#elif defined (__HIP__) HIP_CHECK(hipMemcpy(*devPointer, hostPointer, bytes*size, hipMemcpyHostToDevice)); #endif } @@ -137,7 +149,7 @@ struct pointer_holder { }; // here we collect the global variables for then running some default functions on them (print and copy to device) -struct global_vars { +struct global_vars_both{ bool init_PLEGMA_flag; float deviceMemory; int verbosity; @@ -162,8 +174,11 @@ struct global_vars { size_t surface3D[N_DIMS]; size_t surface2D[(N_DIMS*(N_DIMS-1))/2]; size_t surface1D[(N_DIMS*(N_DIMS-1)*(N_DIMS-2))/6]; - bool dimBreak[N_DIMS]; +}; + +// here we collect the global variables for then running some default functions on them (print and copy to device) +struct global_vars_host: global_vars_both { Topology *default_topo; int nProc[N_DIMS]; MPI_Group fullGroup; @@ -178,51 +193,12 @@ struct global_vars { int spaceSize; int timeRank; int timeSize; + bool hold_exit; -// for cublas use #if defined (__HIP__) hipblasHandle_t hipblas_handle; #else cublasHandle_t cublas_handle; #endif - /* - template - void add(const std::string& name, const size_t& size, hostT *host, void ** device = nullptr) { - globals.push_back(pointer_holder(name, size, host, device)); - } - void copyToDevice() { - for(size_t i = 0; i != globals.size(); i++) { - globals[i].copyToDeviceConstant(); - } - } - bool check() { - for(size_t i = 0; i < globals.size(); i++) { - if(globals[i].checkDeviceConstant() == false) return false; - } - return true; - } - void print() { - PLEGMA_printf("\nGlobal constants available only on host:\n"); - for(size_t i = 0; i < globals.size(); i++) { - if(globals[i].devPointer != nullptr) continue; - std::string line = "HGC_" + globals[i].get_value(); - PLEGMA_printf("%s",line.c_str()); - } - PLEGMA_printf("\nGlobal constants available on both, host and device:\n"); - for(int i = 0; i < globals.size(); i++) { - if(globals[i].devPointer == nullptr) continue; - if(globals[i].checkDeviceConstant()) { - std::string line = "H/DGC_" + globals[i].get_value(); - PLEGMA_printf("%s",line.c_str()); - } else { - PLEGMA_printf("!!!!!! ERROR: HGC_ and DGC_ differ in the following !!!!!!!\n"); - std::string line = "HGC_" + globals[i].get_value(); - PLEGMA_printf("%s",line.c_str()); - globals[i].copyFromDeviceConstant(); - line = "DGC_" + globals[i].get_value(); - PLEGMA_printf("%s",line.c_str()); - } - } - PLEGMA_printf("\n\n"); - }*/ + }; diff --git a/include/global/PLEGMA_templates.h b/include/global/PLEGMA_templates.h index 4a91d67f..af4c115b 100644 --- a/include/global/PLEGMA_templates.h +++ b/include/global/PLEGMA_templates.h @@ -16,7 +16,7 @@ template<> inline MPI_Datatype MPI_Type() { return MPI_UNSIGNED_L template<> inline MPI_Datatype MPI_Type() { return MPI_LONG_LONG_INT; } // hostMalloc and hostFree: functions to use in replace of malloc and free -extern long int HGC_used_memory; +//extern struct global_vars_host HGC; template inline void hostMalloc(T &ptr, size_t size) { #ifdef PLEGMA_HAVE_MEMALIGN ptr = static_cast(memalign(PLEGMA_ALIGNMENT, size)); @@ -24,10 +24,10 @@ template inline void hostMalloc(T &ptr, size_t size) { ptr = static_cast(malloc(size)); #endif if(ptr == static_cast(NULL) ){ - PLEGMA_warning("Bad alloc. Total memory in use: %lu\n", HGC_used_memory); +// PLEGMA_warning("Bad alloc. Total memory in use: %lu\n", HGC.used_memory); throw( std::bad_alloc() ); } - HGC_used_memory += sizeof(T)*size; +// HGC.used_memory += sizeof(T)*size; } template inline T* hostMalloc(size_t size) { T* ptr; @@ -37,7 +37,7 @@ template inline T* hostMalloc(size_t size) { template inline void hostFree(T &ptr, size_t size) { free(ptr); ptr=NULL; - HGC_used_memory -= sizeof(T)*size; + //HGC.used_memory -= sizeof(T)*size; } template inline void hostFree(T &ptr) { hostFree(ptr,0); @@ -51,7 +51,7 @@ template inline void hostMallocPinned(T &ptr, size_t size){ //if (err != cudaSuccess) { // errorQuda("Failed to allocate host memory of size %zu \n", size); //} - HGC_used_memory += size; + //HGC.used_memory += size; } template inline void hostFreePinned(T &ptr, size_t size) { @@ -61,7 +61,7 @@ template inline void hostFreePinned(T &ptr, size_t size) { //} host_free(ptr); //ptr=NULL; - HGC_used_memory -= size; + //HGC.used_memory -= size; } template inline void hostFreePinned(T &ptr) { hostFreePinned(ptr,0); @@ -75,7 +75,7 @@ template inline void hostReAlloc(T &ptr_new, size_t size_new, T &ptr fprintf(stderr,"Cannot reallocate memory of size %lu\n",size_new); exit(-1); } - HGC_used_memory += size_new-size_old; + //HGC.used_memory += size_new-size_old; } // type_char(): identifying char for the variable. It is later used in type_print() diff --git a/include/target/cuda/PLEGMA_cuBLAS.h b/include/target/cuda/PLEGMA_cuBLAS.h index 50d1a584..d69e939d 100644 --- a/include/target/cuda/PLEGMA_cuBLAS.h +++ b/include/target/cuda/PLEGMA_cuBLAS.h @@ -24,13 +24,13 @@ namespace cuBLAS{ template<> inline void axpy(int NN, float val[2], float *x, float *y){ cuComplex cu_val = make_cuComplex(val[0],val[1]); - cublasStatus_t error = cublasCaxpy(HGC_cublas_handle,NN, &cu_val, (cuComplex*) x, 1, (cuComplex*) y, 1); + cublasStatus_t error = cublasCaxpy(HGC.cublas_handle,NN, &cu_val, (cuComplex*) x, 1, (cuComplex*) y, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCaxpy failed with error %d", error); } template<> inline void axpy(int NN, double val[2], double *x, double *y){ cuDoubleComplex cu_val = make_cuDoubleComplex(val[0],val[1]); - cublasStatus_t error = cublasZaxpy(HGC_cublas_handle, NN, &cu_val,(cuDoubleComplex*) x, 1, (cuDoubleComplex*) y, 1); + cublasStatus_t error = cublasZaxpy(HGC.cublas_handle, NN, &cu_val,(cuDoubleComplex*) x, 1, (cuDoubleComplex*) y, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasZaxpy failed with error %d", error); } @@ -39,12 +39,12 @@ namespace cuBLAS{ inline void scal(int NN, const Float val, Float *x); template<> inline void scal(int NN, const float val, float *x){ - cublasStatus_t error = cublasCsscal(HGC_cublas_handle, NN, &val, (cuComplex*) x, 1); + cublasStatus_t error = cublasCsscal(HGC.cublas_handle, NN, &val, (cuComplex*) x, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCsscal failed with error %d", error); } template<> inline void scal(int NN, const double val, double *x){ - cublasStatus_t error = cublasZdscal(HGC_cublas_handle, NN, &val, (cuDoubleComplex*) x, 1); + cublasStatus_t error = cublasZdscal(HGC.cublas_handle, NN, &val, (cuDoubleComplex*) x, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasZdscal failed with error %d", error); } //------------------------------------------------------------------ @@ -53,13 +53,13 @@ namespace cuBLAS{ template<> inline void cscal(int NN, const float val[2], float *x){ cuComplex cu_val = make_cuComplex(val[0],val[1]); - cublasStatus_t error = cublasCscal(HGC_cublas_handle, NN, &cu_val, (cuComplex*) x, 1); + cublasStatus_t error = cublasCscal(HGC.cublas_handle, NN, &cu_val, (cuComplex*) x, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCscal failed with error %d", error); } template<> inline void cscal(int NN, const double val[2], double *x){ cuDoubleComplex cu_val = make_cuDoubleComplex(val[0],val[1]); - cublasStatus_t error = cublasZscal(HGC_cublas_handle, NN, &cu_val, (cuDoubleComplex*) x, 1); + cublasStatus_t error = cublasZscal(HGC.cublas_handle, NN, &cu_val, (cuDoubleComplex*) x, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasZscal failed with error %d", error); } //----------------------------------------------------------------- @@ -68,14 +68,14 @@ namespace cuBLAS{ template<> inline std::complex dot(int NN, const float *x, const float *y){ cuComplex cu_res; - cublasStatus_t error = cublasCdotc(HGC_cublas_handle, NN,(cuComplex*)x, 1, (cuComplex*)y,1,&cu_res); + cublasStatus_t error = cublasCdotc(HGC.cublas_handle, NN,(cuComplex*)x, 1, (cuComplex*)y,1,&cu_res); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCdotc failed with error %d", error); return std::complex(cu_res.x,cu_res.y); } template<> inline std::complex dot(int NN, const double *x, const double *y){ cuDoubleComplex cu_res; - cublasStatus_t error = cublasZdotc(HGC_cublas_handle, NN,(cuDoubleComplex*)x, 1, (cuDoubleComplex*)y,1,&cu_res); + cublasStatus_t error = cublasZdotc(HGC.cublas_handle, NN,(cuDoubleComplex*)x, 1, (cuDoubleComplex*)y,1,&cu_res); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasZdotc failed with error %d", error); return std::complex(cu_res.x,cu_res.y); } @@ -94,14 +94,14 @@ namespace cuBLAS{ template<> inline float norm(int NN, const float *x){ float res; - cublasStatus_t error = cublasScnrm2(HGC_cublas_handle, NN, (cuComplex*)x, 1, &res); + cublasStatus_t error = cublasScnrm2(HGC.cublas_handle, NN, (cuComplex*)x, 1, &res); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCdotc failed with error %d", error); return res; } template<> inline double norm(int NN, const double *x){ double res; - cublasStatus_t error = cublasDznrm2(HGC_cublas_handle, NN, (cuDoubleComplex*)x, 1, &res); + cublasStatus_t error = cublasDznrm2(HGC.cublas_handle, NN, (cuDoubleComplex*)x, 1, &res); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCdotc failed with error %d", error); return res; } @@ -126,7 +126,7 @@ namespace cuBLAS{ cuComplex cu_alpha = make_cuComplex(alpha[0],alpha[1]); cuComplex cu_beta = make_cuComplex(beta[0],beta[1]); switch(trans){case(NOTRANS): Oper=CUBLAS_OP_N; break; case(TRANS): Oper=CUBLAS_OP_T; break; case(DAGGER): Oper=CUBLAS_OP_C; break;} - cublasStatus_t error = cublasCgemv(HGC_cublas_handle, Oper, m, n, &cu_alpha, (cuComplex*) A, m, (cuComplex*) x, 1, &cu_beta, (cuComplex*) y, 1); + cublasStatus_t error = cublasCgemv(HGC.cublas_handle, Oper, m, n, &cu_alpha, (cuComplex*) A, m, (cuComplex*) x, 1, &cu_beta, (cuComplex*) y, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasCgemv failed with error %d", error); } @@ -136,7 +136,7 @@ namespace cuBLAS{ cuDoubleComplex cu_alpha = make_cuDoubleComplex(alpha[0],alpha[1]); cuDoubleComplex cu_beta = make_cuDoubleComplex(beta[0],beta[1]); switch(trans){case(NOTRANS): Oper=CUBLAS_OP_N; break; case(TRANS): Oper=CUBLAS_OP_T; break; case(DAGGER): Oper=CUBLAS_OP_C; break;} - cublasStatus_t error = cublasZgemv(HGC_cublas_handle, Oper, m, n, &cu_alpha, (cuDoubleComplex*) A, m,(cuDoubleComplex*) x, 1, &cu_beta,(cuDoubleComplex*) y, 1); + cublasStatus_t error = cublasZgemv(HGC.cublas_handle, Oper, m, n, &cu_alpha, (cuDoubleComplex*) A, m,(cuDoubleComplex*) x, 1, &cu_beta,(cuDoubleComplex*) y, 1); if(error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("cublasZgemv failed with error %d", error); } diff --git a/lib/PLEGMA.cu b/lib/PLEGMA.cu index cd933b59..8d7c30cb 100644 --- a/lib/PLEGMA.cu +++ b/lib/PLEGMA.cu @@ -21,65 +21,65 @@ Communicator &get_current_communicator(); void plegma::PLEGMA_init(int localL[4], int nProcs[4], int verbosity){ - HGC_hold_exit = false; - HGC_options->checkErrors(); + HGC.hold_exit = false; + HGC.options->checkErrors(); #define ADD_TO_GLOBAL -#include +//#include #undef ADD_TO_GLOBAL - if(HGC_init_PLEGMA_flag == false){ + if(HGC.init_PLEGMA_flag == false){ for(int i = 0 ; i < N_DIMS ; i++) - HGC_localL[i] = localL[i]; + HGC.localL[i] = localL[i]; -// HGC_default_topo = get_current_communicator().comm_default_topology();//default_tcomm_default_topology();//get_current_communicator().default_topo;//default_topo;// get_current_communicator().default_topo; - HGC_verbosity = verbosity; +// HGC.default_topo = get_current_communicator().comm_default_topology();//default_tcomm_default_topology();//get_current_communicator().default_topo;//default_topo;// get_current_communicator().default_topo; + HGC.verbosity = verbosity; for(int i = 0 ; i < N_DIMS ; i++) { - HGC_nProc[i] = nProcs[i]; - if(HGC_nProc[i] != comm_dim(i)) + HGC.nProc[i] = nProcs[i]; + if(HGC.nProc[i] != comm_dim(i)) PLEGMA_error("nProcs and comm_dim do not match for dim %d",i); } for(int i = 0 ; i < N_DIMS ; i++){ // take local and total lattice - HGC_totalL[i] = HGC_nProc[i] * HGC_localL[i]; + HGC.totalL[i] = HGC.nProc[i] * HGC.localL[i]; } for(int i = 0 ; i < N_DIMS ; i++){ - if( HGC_localL[i] < HGC_totalL[i]) - HGC_dimBreak[i] = true; + if( HGC.localL[i] < HGC.totalL[i]) + HGC.dimBreak[i] = true; else - HGC_dimBreak[i] = false; + HGC.dimBreak[i] = false; } - HGC_localVolume = 1; - HGC_totalVolume = 1; + HGC.localVolume = 1; + HGC.totalVolume = 1; for(int i = 0 ; i < N_DIMS ; i++){ - HGC_localVolume *= HGC_localL[i]; - HGC_totalVolume *= HGC_totalL[i]; + HGC.localVolume *= HGC.localL[i]; + HGC.totalVolume *= HGC.totalL[i]; } - HGC_localVolume3D = HGC_localVolume/HGC_localL[3]; + HGC.localVolume3D = HGC.localVolume/HGC.localL[3]; for (int i=0; i 2) { + if(HGC.init_PLEGMA_flag == false) PLEGMA_error("You must initialize init_PLEGMA first"); +// if(HGC.global_vars.check() == false) PLEGMA_error("Global variables do not match between host and device.\n"); + if(HGC.verbosity > 2) { PLEGMA_printf("Number of colors is %d\n",N_COLS); PLEGMA_printf("Number of spins is %d\n",N_SPINS); PLEGMA_printf("Number of dimensions is %d\n",N_DIMS); - HGC_global_vars.print(); +// HGC.global_vars.print(); } } void plegma::PLEGMA_end() { // TODO: here we should destroy everything is created in init. - //cublasStatus_t error = cublasDestroy(HGC_cublas_handle); + //cublasStatus_t error = cublasDestroy(HGC.cublas_handle); //if (error != CUBLAS_STATUS_SUCCESS) PLEGMA_error("\nError indestroying cublas context, error code = %d\n", error); if(HDF5::isWriting()) { PLEGMA_printf("Waiting for HDF5 to finish the writing\n"); while(HDF5::isWriting()) sleep(0.001); } - if(HGC_fullComm != MPI_COMM_NULL) MPI_Comm_free(&HGC_fullComm); - if(HGC_spaceComm != MPI_COMM_NULL) MPI_Comm_free(&HGC_spaceComm); - if(HGC_timeComm != MPI_COMM_NULL) MPI_Comm_free(&HGC_timeComm); + if(HGC.fullComm != MPI_COMM_NULL) MPI_Comm_free(&HGC.fullComm); + if(HGC.spaceComm != MPI_COMM_NULL) MPI_Comm_free(&HGC.spaceComm); + if(HGC.timeComm != MPI_COMM_NULL) MPI_Comm_free(&HGC.timeComm); } diff --git a/lib/PLEGMA_Correlator.cu b/lib/PLEGMA_Correlator.cu index 3c6a32c8..7fcb5df6 100644 --- a/lib/PLEGMA_Correlator.cu +++ b/lib/PLEGMA_Correlator.cu @@ -26,14 +26,14 @@ using namespace plegma; template void PLEGMA_Correlator:: initialize() { - comm.reset(new MPI_Comm(HGC_fullComm), [](MPI_Comm* ptr){MPI_Comm_free(ptr); delete ptr;}); - MPI_Comm_dup( HGC_fullComm, comm.get() ); + comm.reset(new MPI_Comm(HGC.fullComm), [](MPI_Comm* ptr){MPI_Comm_free(ptr); delete ptr;}); + MPI_Comm_dup( HGC.fullComm, comm.get() ); if(corr_space == MOMENTUM_SPACE) { corr_mom_space.reset(new PLEGMA_FT(*corr_mom_space)); corr_mom_space->checkAllocation(getSiteSize()); } else if(corr_space == POSITION_SPACE) { - corr_pos_space.reset(new PLEGMA_Field(HOST, getSiteSize(), HGC_localVolume3D*localT(), + corr_pos_space.reset(new PLEGMA_Field(HOST, getSiteSize(), HGC.localVolume3D*localT(), NO_GHOSTS)); } else { @@ -198,7 +198,7 @@ contractBaryonsUDSC(PLEGMA_Propagator &propUP, } } - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { PLEGMA_printf("contractBaryonsUDSC is going to run: "); for(auto name: datasets) PLEGMA_printf("%s, ", name.c_str()); @@ -254,7 +254,7 @@ contractTetraquarks(PLEGMA_Propagator &propLT, } } - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { PLEGMA_printf("contractTetraquarks is going to run: "); for(auto name: datasets) PLEGMA_printf("%s, ", name.c_str()); @@ -316,7 +316,7 @@ contractTetraquarksBCUD(PLEGMA_Propagator &propLT, } } - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { PLEGMA_printf("contractTetraquarksBCUD is going to run: "); for(auto name: datasets) PLEGMA_printf("%s, ", name.c_str()); @@ -375,7 +375,7 @@ contractTetraquarksStochastic(PLEGMA_Propagator &propLT1, } } - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { PLEGMA_printf("contractTetraquarksStochastic is going to run: "); for(auto name: datasets) PLEGMA_printf("%s, ", name.c_str()); @@ -438,7 +438,7 @@ contractTetraquarksStochasticBCUD(PLEGMA_Propagator &propLT1, } } - if(HGC_verbosity > 2) { + if(HGC.verbosity > 2) { PLEGMA_printf("contractTetraquarksStochasticBCUD is going to run: "); for(auto name: datasets) PLEGMA_printf("%s, ", name.c_str()); @@ -860,18 +860,18 @@ writeASCII(std::string filename_out) const { size_t g_vol_size = getVolSize(); int rank; - if(corr_space == MOMENTUM_SPACE && (HGC_timeRank > HGC_nProc[3] || HGC_timeRank <0 )) + if(corr_space == MOMENTUM_SPACE && (HGC.timeRank > HGC.nProc[3] || HGC.timeRank <0 )) return; switch(corr_space) { case MOMENTUM_SPACE: - g_vol_size *= HGC_nProc[3]; - comm = HGC_timeComm; - rank = HGC_timeRank; + g_vol_size *= HGC.nProc[3]; + comm = HGC.timeComm; + rank = HGC.timeRank; break; case POSITION_SPACE: - g_vol_size *= HGC_nProc[0]*HGC_nProc[1]*HGC_nProc[2]*HGC_nProc[3]; - comm = HGC_fullComm; + g_vol_size *= HGC.nProc[0]*HGC.nProc[1]*HGC.nProc[2]*HGC.nProc[3]; + comm = HGC.fullComm; rank = comm_rank(); PLEGMA_error("WriteASCII do not support writing in position space.\n"); break; @@ -889,18 +889,18 @@ writeASCII(std::string filename_out) const { int site_sizeR=getSiteSize()/(nDatasets()*nGroups()); - for(int it=0; itNmoms(); std::vector> momV = corr_mom_space->MomList(); - for(int it=0; it &shape, std::vector &lshape, std::v descr += "/t/z/y/x"; // Volume for(int i=N_DIMS-1; i>=0; i--) { - shape.push_back(i==DIM_T ? totalT : HGC_totalL[i]); - lshape.push_back(i==DIM_T ? localT() : HGC_localL[i]); - start.push_back(i==DIM_T ? startT() : ((HGC_procPosition[i]*HGC_localL[i] + HGC_totalL[i] - source[i]) % HGC_totalL[i])); + shape.push_back(i==DIM_T ? totalT : HGC.totalL[i]); + lshape.push_back(i==DIM_T ? localT() : HGC.localL[i]); + start.push_back(i==DIM_T ? startT() : ((HGC.procPosition[i]*HGC.localL[i] + HGC.totalL[i] - source[i]) % HGC.totalL[i])); } break; default: @@ -1037,15 +1037,15 @@ writeHDF5(std::string filename) const { for(auto l: lshape) writeSize*=l; assert(corrSize==writeSize); - // In case of MOMENTUM_SPACE, all the processes in HGC_spaceComm has the same information. + // In case of MOMENTUM_SPACE, all the processes in HGC.spaceComm has the same information. // All of them will write a different piece - int nWriters = writeSize==0 ? 0 : ((corr_space == MOMENTUM_SPACE) ? HGC_spaceSize : 1); - int id = (corr_space == MOMENTUM_SPACE) ? HGC_spaceRank : 0; + int nWriters = writeSize==0 ? 0 : ((corr_space == MOMENTUM_SPACE) ? HGC.spaceSize : 1); + int id = (corr_space == MOMENTUM_SPACE) ? HGC.spaceRank : 0; size_t corrShift = writeSize==0 ? 0 : use_multiple_writers(shape, lshape, start, nWriters, id); if(id >= nWriters) lshape[0] = 0; // not writing if(nWriters>1) { - if(HGC_verbosity > 3) { + if(HGC.verbosity > 3) { std::string out = "rank: "+std::to_string(id)+ ", shape: ("+str(shape.begin(), shape.end())+ "), lshape: ("+str(lshape.begin(), lshape.end())+ diff --git a/lib/PLEGMA_FT.cu b/lib/PLEGMA_FT.cu index 9e9e6bcb..d8a31de3 100644 --- a/lib/PLEGMA_FT.cu +++ b/lib/PLEGMA_FT.cu @@ -17,7 +17,7 @@ PLEGMA_FT::PLEGMA_FT(int Q2_max, int D3D4, bool accum, int dimT): Q2_max(Q2_max), dof(0), h_elem(nullptr), sizeN(0), dims(D3D4), dimT(D3D4==3?dimT:1), accum(accum){ if(dims!= 3 && dims !=4) PLEGMA_error("This class transforms only 3 and 4 dimensions %d\n",dims); if(Q2_max < 0) PLEGMA_error("The maximum number of Q2 cannot be negative\n"); - if(dimT<0 || dimT>HGC_localL[DIM_T]) PLEGMA_error("The time dimension cannot be negative or larger than local size\n"); + if(dimT<0 || dimT>HGC.localL[DIM_T]) PLEGMA_error("The time dimension cannot be negative or larger than local size\n"); createMom(); } @@ -188,8 +188,8 @@ std::shared_ptr PLEGMA_FT::getTexMomList() { template void PLEGMA_FT::applyNaive(const PLEGMA_Field &f, int sign){ if(dims == 4) PLEGMA_error("This FT implementation is implemented for a 3D transformation only"); - if(f.Total_length() != HGC_localVolume && dims == 4) PLEGMA_error("Cannot do a 4D FT on a 3D field\n"); - if(f.Total_length() != HGC_localVolume) dimT=1; // if the field is 3D + if(f.Total_length() != HGC.localVolume && dims == 4) PLEGMA_error("Cannot do a 4D FT on a 3D field\n"); + if(f.Total_length() != HGC.localVolume) dimT=1; // if the field is 3D checkAllocation(f.Field_length()); field_name = f.Field_name(); site_shape = f.getSiteShape(); @@ -209,8 +209,8 @@ void PLEGMA_FT::applyFFT(const PLEGMA_Field &f, int sign){ template void PLEGMA_FT::applyGEMV(const PLEGMA_Field &f, int sign){ - if(f.Total_length() != HGC_localVolume && dims == 4) PLEGMA_error("Cannot do a 4D FT on a 3D field\n"); - if(f.Total_length() != HGC_localVolume) dimT=1; // if the field is 3D + if(f.Total_length() != HGC.localVolume && dims == 4) PLEGMA_error("Cannot do a 4D FT on a 3D field\n"); + if(f.Total_length() != HGC.localVolume) dimT=1; // if the field is 3D checkAllocation(f.Field_length()); field_name = f.Field_name(); site_shape = f.getSiteShape(); @@ -238,7 +238,7 @@ void PLEGMA_FT::mulConstMomentumPhases(Vint src, int sign){ std::complex *h2 = (std::complex *) h_elem.get(); for(int imom = 0; imom < Nmoms(); imom++){ phase=0.; - for(int i = 0; i < dims; i++) phase += ((Float) src[i] * momList[imom][i])/((Float) HGC_totalL[i]); + for(int i = 0; i < dims; i++) phase += ((Float) src[i] * momList[imom][i])/((Float) HGC.totalL[i]); phase *= 2. * PI; expPhase = (std::complex) { cos(phase), sign*sin(phase) }; for(int idf = 0 ; idf < dof; idf++) @@ -257,21 +257,21 @@ template void PLEGMA_FT::store3DFTs(std::complex *Ts, int timeshift, bool append) const{ if(dims == 4 && timeshift > 0) PLEGMA_error("The temporal dimension has been reduced therefore cannot shift it\n"); if(!h_elem) PLEGMA_error("Memory not allocated cannot write data"); - if(dims == 3 && dimT != HGC_localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in storing (TODO)\n"); + if(dims == 3 && dimT != HGC.localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in storing (TODO)\n"); std::shared_ptr helem_global = h_elem; - if(dimT != 1 && HGC_nProc[3] != 1 && HGC_spaceRank == 0){ - helem_global.reset(new Float[HGC_nProc[DIM_T]*sizeN]); - if(HGC_timeComm == MPI_COMM_NULL) PLEGMA_error("Try to use a NULL communicator for MPI Gather which will give an error"); - int error = MPI_Gather(h_elem.get(), sizeN, MPI_Type(), helem_global.get(), sizeN, MPI_Type(),0,HGC_timeComm); + if(dimT != 1 && HGC.nProc[3] != 1 && HGC.spaceRank == 0){ + helem_global.reset(new Float[HGC.nProc[DIM_T]*sizeN]); + if(HGC.timeComm == MPI_COMM_NULL) PLEGMA_error("Try to use a NULL communicator for MPI Gather which will give an error"); + int error = MPI_Gather(h_elem.get(), sizeN, MPI_Type(), helem_global.get(), sizeN, MPI_Type(),0,HGC.timeComm); if(error != MPI_SUCCESS) PLEGMA_error("MPI_Gather with %d\n",error); } if(comm_rank() == 0){ - int T = (dimT != 1)?HGC_totalL[DIM_T]:1; + int T = (dimT != 1)?HGC.totalL[DIM_T]:1; for(int idf = 0 ; idf < dof; idf++) for(int it = 0 ; it < T; it++){ - int its = (it + timeshift)%HGC_totalL[DIM_T]; + int its = (it + timeshift)%HGC.totalL[DIM_T]; for(int imom = 0; imom < Nmoms(); imom++) Ts[its*dof*Nmoms()+idf*Nmoms()+imom] = std::complex(helem_global.get()[its*dof*Nmoms()*2+idf*Nmoms()*2+imom*2+0], helem_global.get()[its*dof*Nmoms()*2+idf*Nmoms()*2+imom*2+1]); @@ -284,13 +284,13 @@ template void PLEGMA_FT::writeASCII(std::string filename, int timeshift, bool append) const{ if(dims == 4 && timeshift > 0) PLEGMA_error("The temporal dimension has been reduced therefore cannot shift it\n"); if(!h_elem) PLEGMA_error("Memory not allocated cannot write data"); - if(dims == 3 && dimT != HGC_localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in writing (TODO)\n"); + if(dims == 3 && dimT != HGC.localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in writing (TODO)\n"); std::shared_ptr helem_global = h_elem; - if(dimT != 1 && HGC_nProc[3] != 1 && HGC_spaceRank == 0){ - helem_global.reset(new Float[HGC_nProc[DIM_T]*sizeN]); - if(HGC_timeComm == MPI_COMM_NULL) PLEGMA_error("Try to use a NULL communicator for MPI Gather which will give an error"); - int error = MPI_Gather(h_elem.get(), sizeN, MPI_Type(), helem_global.get(), sizeN, MPI_Type(),0,HGC_timeComm); + if(dimT != 1 && HGC.nProc[3] != 1 && HGC.spaceRank == 0){ + helem_global.reset(new Float[HGC.nProc[DIM_T]*sizeN]); + if(HGC.timeComm == MPI_COMM_NULL) PLEGMA_error("Try to use a NULL communicator for MPI Gather which will give an error"); + int error = MPI_Gather(h_elem.get(), sizeN, MPI_Type(), helem_global.get(), sizeN, MPI_Type(),0,HGC.timeComm); if(error != MPI_SUCCESS) PLEGMA_error("MPI_Gather with %d\n",error); } @@ -299,10 +299,10 @@ void PLEGMA_FT::writeASCII(std::string filename, int timeshift, bool appe // Othereise, the order will be messed, and some iterms will be missing. FILE *ptr = append?fopen(filename.c_str(), "a"):fopen(filename.c_str(), "w"); if(ptr == NULL) PLEGMA_error("Cannot open file:%s for writting\n",filename.c_str()); - int T = (dimT != 1)?HGC_totalL[DIM_T]:1; + int T = (dimT != 1)?HGC.totalL[DIM_T]:1; for(int idf = 0 ; idf < dof; idf++) for(int it = 0 ; it < T; it++){ - int its = (it + timeshift)%HGC_totalL[DIM_T]; + int its = (it + timeshift)%HGC.totalL[DIM_T]; for(int imom = 0; imom < Nmoms(); imom++) fprintf(ptr, "%d %d %+d %+d %+d \t %+16.15e %+15.15e\n", idf,it,(int) round(momList[imom][0]),(int) round(momList[imom][1]),(int) round(momList[imom][2]), helem_global.get()[its*dof*Nmoms()*2+idf*Nmoms()*2+imom*2+0], helem_global.get()[its*dof*Nmoms()*2+idf*Nmoms()*2+imom*2+1] ); @@ -319,11 +319,11 @@ fill_H5_shapes(std::vector &shape, std::vector &lshape, std::v std::string descr; // Time - if(dims==3 && dimT == HGC_localL[DIM_T]) { + if(dims==3 && dimT == HGC.localL[DIM_T]) { descr += "/time"; - shape.push_back(HGC_totalL[DIM_T]); - lshape.push_back(HGC_localL[DIM_T]); - start.push_back((HGC_procPosition[DIM_T]*HGC_localL[DIM_T] + HGC_totalL[DIM_T] - timeshift) % HGC_totalL[DIM_T]); + shape.push_back(HGC.totalL[DIM_T]); + lshape.push_back(HGC.localL[DIM_T]); + start.push_back((HGC.procPosition[DIM_T]*HGC.localL[DIM_T] + HGC.totalL[DIM_T] - timeshift) % HGC.totalL[DIM_T]); } else { assert(dimT==1); } @@ -392,7 +392,7 @@ static std::string str(T begin, T end) { template void PLEGMA_FT:: writeHDF5(std::string filename, int timeshift, bool append) const{ - if(dims == 3 && dimT != HGC_localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in writing (TODO)\n"); + if(dims == 3 && dimT != HGC.localL[DIM_T]) PLEGMA_error("Custom time dimension is not supported in writing (TODO)\n"); std::vector shape, lshape, start; std::string descr = fill_H5_shapes(shape, lshape, start, timeshift); @@ -401,16 +401,16 @@ writeHDF5(std::string filename, int timeshift, bool append) const{ assert(sizeN==writeSize); size_t shift = 0; - if(dims==3 && dimT != HGC_localL[DIM_T]) { // then it was a 3D Field. Using timeshift to determine the origin - int my_it = timeshift - HGC_procPosition[DIM_T] * HGC_localL[DIM_T]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[DIM_T] ); + if(dims==3 && dimT != HGC.localL[DIM_T]) { // then it was a 3D Field. Using timeshift to determine the origin + int my_it = timeshift - HGC.procPosition[DIM_T] * HGC.localL[DIM_T]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[DIM_T] ); if(!is_myIt) lshape[0]=0; // not writing } else { - int nWriters = (dims==4) ? HGC_fullSize : HGC_spaceSize; - int id = (dims==4) ? HGC_fullRank : HGC_spaceRank; + int nWriters = (dims==4) ? HGC.fullSize : HGC.spaceSize; + int id = (dims==4) ? HGC.fullRank : HGC.spaceRank; shift = use_multiple_writers(shape, lshape, start, nWriters, id); if(id >= nWriters) lshape[0] = 0; // not writing - if(HGC_verbosity > 3) { + if(HGC.verbosity > 3) { std::string out = "rank: "+std::to_string(id)+ ", shape: ("+str(shape.begin(), shape.end())+ "), lshape: ("+str(lshape.begin(), lshape.end())+ @@ -433,7 +433,7 @@ writeHDF5(std::string filename, int timeshift, bool append) const{ } } - HDF5 writer(filename, HGC_fullComm); + HDF5 writer(filename, HGC.fullComm); writer.write_dataset(dataset, h_elem.get()+shift, shape, lshape, start); writer.write_attribute(dataset, "description", descr); diff --git a/lib/PLEGMA_Field.cu b/lib/PLEGMA_Field.cu index b14e025b..780a651f 100644 --- a/lib/PLEGMA_Field.cu +++ b/lib/PLEGMA_Field.cu @@ -40,7 +40,7 @@ using namespace plegma; template void PLEGMA_Field:: initialize(ALLOCATION_FLAG alloc_flag, int field_l, size_t vol_l) { - if(HGC_init_PLEGMA_flag == false) + if(HGC.init_PLEGMA_flag == false) PLEGMA_error("You must initialize init_PLEGMA first"); field_length = field_l; @@ -52,34 +52,34 @@ initialize(ALLOCATION_FLAG alloc_flag, int field_l, size_t vol_l) { ghost_vertex_length = 0; if(ghost_flag>NO_GHOSTS) { - assert(vol_l==HGC_localVolume || vol_l==HGC_localVolume3D); + assert(vol_l==HGC.localVolume || vol_l==HGC.localVolume3D); - if(vol_l==HGC_localVolume) { + if(vol_l==HGC.localVolume) { for(int i = 0 ; i < N_DIMS ; i++){ - if(ghost_flag >= FIRST_SIDE) ghost_length += 2*HGC_surface3D[i]; + if(ghost_flag >= FIRST_SIDE) ghost_length += 2*HGC.surface3D[i]; for(int j = i+1; j < N_DIMS; j++){ - if(ghost_flag >= FIRST_CORNER) ghost_corner_length += 4*HGC_surface2D[OFF2(i,j)]; + if(ghost_flag >= FIRST_CORNER) ghost_corner_length += 4*HGC.surface2D[OFF2(i,j)]; for(int k = j+1; k < N_DIMS; k++){ - if(ghost_flag >= FIRST_VERTEX) ghost_vertex_length += 8*HGC_surface1D[OFF3(i,j,k)]; + if(ghost_flag >= FIRST_VERTEX) ghost_vertex_length += 8*HGC.surface1D[OFF3(i,j,k)]; } } } - if(ghost_flag >= FIRST_SIDE) assert(ghost_length == HGC_sideGhostVolume); - if(ghost_flag >= FIRST_CORNER) assert(ghost_corner_length == HGC_cornerGhostVolume); - if(ghost_flag >= FIRST_VERTEX) assert(ghost_vertex_length == HGC_vertexGhostVolume); - } else if(vol_l==HGC_localVolume3D) { + if(ghost_flag >= FIRST_SIDE) assert(ghost_length == HGC.sideGhostVolume); + if(ghost_flag >= FIRST_CORNER) assert(ghost_corner_length == HGC.cornerGhostVolume); + if(ghost_flag >= FIRST_VERTEX) assert(ghost_vertex_length == HGC.vertexGhostVolume); + } else if(vol_l==HGC.localVolume3D) { for(int i = 0 ; i < N_DIMS-1 ; i++){ - if(ghost_flag >= FIRST_SIDE) ghost_length += 2*HGC_surface3D[i]/HGC_localL[DIM_T]; + if(ghost_flag >= FIRST_SIDE) ghost_length += 2*HGC.surface3D[i]/HGC.localL[DIM_T]; for(int j = i+1; j < N_DIMS-1; j++){ - if(ghost_flag >= FIRST_CORNER) ghost_corner_length += 4*HGC_surface2D[OFF2(i,j)]/HGC_localL[DIM_T]; + if(ghost_flag >= FIRST_CORNER) ghost_corner_length += 4*HGC.surface2D[OFF2(i,j)]/HGC.localL[DIM_T]; for(int k = j+1; k < N_DIMS-1; k++){ - if(ghost_flag >= FIRST_VERTEX) ghost_vertex_length += 8*HGC_surface1D[OFF3(i,j,k)]/HGC_localL[DIM_T]; + if(ghost_flag >= FIRST_VERTEX) ghost_vertex_length += 8*HGC.surface1D[OFF3(i,j,k)]/HGC.localL[DIM_T]; } } } - if(ghost_flag >= FIRST_SIDE) assert(ghost_length == HGC_sideGhostVolume3D); - if(ghost_flag >= FIRST_CORNER) assert(ghost_corner_length == HGC_cornerGhostVolume3D); - if(ghost_flag >= FIRST_VERTEX) assert(ghost_vertex_length == HGC_vertexGhostVolume3D); + if(ghost_flag >= FIRST_SIDE) assert(ghost_length == HGC.sideGhostVolume3D); + if(ghost_flag >= FIRST_CORNER) assert(ghost_corner_length == HGC.cornerGhostVolume3D); + if(ghost_flag >= FIRST_VERTEX) assert(ghost_vertex_length == HGC.vertexGhostVolume3D); } } @@ -114,62 +114,62 @@ PLEGMA_Field::PLEGMA_Field(ALLOCATION_FLAG alloc_flag, CLASS_ENUM classT, h_elem(NULL), d_elem(NULL), h_ext_ghost_r(NULL), h_ext_ghost_s(NULL), h_ext_ghost_corner_r(NULL), h_ext_ghost_corner_s(NULL), h_ext_ghost_vertex_r(NULL), h_ext_ghost_vertex_s(NULL), randstate_ptr(NULL), ghost_flag(ghost_flag), allocation(alloc_flag),isPinnedHost(isPinnedHost), isAllocHost(false), isAllocDevice(false), checkErr(checkErr), field_type(classT) { - if(HGC_init_PLEGMA_flag == false) + if(HGC.init_PLEGMA_flag == false) PLEGMA_error("You must initialize init_PLEGMA first"); switch(classT){ case SCALAR: - initialize(alloc_flag, 1, HGC_localVolume); + initialize(alloc_flag, 1, HGC.localVolume); field_name = "PLEGMA_SCALAR"; setSiteShape({}); break; case SU3FIELD: - initialize(alloc_flag, N_COLS * N_COLS, HGC_localVolume); + initialize(alloc_flag, N_COLS * N_COLS, HGC.localVolume); field_name = "PLEGMA_SU3FIELD"; setSiteShape({N_COLS, N_COLS}); break; case GAUGE: - initialize(alloc_flag, N_DIMS * N_COLS * N_COLS, HGC_localVolume); + initialize(alloc_flag, N_DIMS * N_COLS * N_COLS, HGC.localVolume); field_name = "PLEGMA_GAUGE"; setSiteShape({N_DIMS, N_COLS, N_COLS}); break; case U1GAUGE: - initialize(alloc_flag, N_DIMS, HGC_localVolume); + initialize(alloc_flag, N_DIMS, HGC.localVolume); field_name = "PLEGMA_U1GAUGE"; setSiteShape({N_DIMS}); break; case GAUGE3D: - initialize(alloc_flag, N_DIMS * N_COLS * N_COLS, HGC_localVolume3D); + initialize(alloc_flag, N_DIMS * N_COLS * N_COLS, HGC.localVolume3D); field_name = "PLEGMA_GAUGE3D"; setSiteShape({N_DIMS, N_COLS, N_COLS}); break; case VECTOR: - initialize(alloc_flag, N_SPINS * N_COLS, HGC_localVolume); + initialize(alloc_flag, N_SPINS * N_COLS, HGC.localVolume); field_name = "PLEGMA_VECTOR"; setSiteShape({N_SPINS, N_COLS}); break; case VECTOR3D: - initialize(alloc_flag, N_SPINS * N_COLS, HGC_localVolume3D); + initialize(alloc_flag, N_SPINS * N_COLS, HGC.localVolume3D); field_name = "PLEGMA_VECTOR3D"; setSiteShape({N_SPINS, N_COLS}); break; case PROPAGATOR: - initialize(alloc_flag, N_SPINS * N_COLS * N_SPINS * N_COLS, HGC_localVolume); + initialize(alloc_flag, N_SPINS * N_COLS * N_SPINS * N_COLS, HGC.localVolume); field_name = "PLEGMA_PROPAGATOR"; setSiteShape({N_SPINS, N_SPINS, N_COLS, N_COLS}); break; case PROPAGATOR3D: - initialize(alloc_flag, N_SPINS * N_COLS * N_SPINS * N_COLS, HGC_localVolume3D); + initialize(alloc_flag, N_SPINS * N_COLS * N_SPINS * N_COLS, HGC.localVolume3D); field_name = "PLEGMA_PROPAGATOR3D"; setSiteShape({N_SPINS, N_SPINS, N_COLS, N_COLS}); break; case QLOOPS: - initialize(alloc_flag, N_SPINS * N_SPINS, HGC_localVolume); + initialize(alloc_flag, N_SPINS * N_SPINS, HGC.localVolume); field_name = "PLEGMA_QLOOPS"; setSiteShape({N_SPINS, N_SPINS}); break; case FMUNU: - initialize(alloc_flag, ((N_SPINS * (N_SPINS-1))/2) * N_COLS * N_COLS, HGC_localVolume); + initialize(alloc_flag, ((N_SPINS * (N_SPINS-1))/2) * N_COLS * N_COLS, HGC.localVolume); field_name = "PLEGMA_FMUNU"; setSiteShape({((N_SPINS * (N_SPINS-1))/2), N_COLS, N_COLS}); break; @@ -236,8 +236,8 @@ void PLEGMA_Field::create_device(){ if(checkErr) checkQudaError(); #ifdef DEVICE_MEMORY_REPORT // device memory in MB - HGC_deviceMemory += Bytes_total_plus_ghost()/(1024.*1024.); - if(HGC_verbosity>1) PLEGMA_printf("Device memory in use is %f MB A PLEGMA \n",HGC_deviceMemory); + HGC.deviceMemory += Bytes_total_plus_ghost()/(1024.*1024.); + if(HGC.verbosity>1) PLEGMA_printf("Device memory in use is %f MB A PLEGMA \n",HGC.deviceMemory); #endif zero_device(); if(ghost_flag >= FIRST_SIDE){ @@ -284,8 +284,8 @@ void PLEGMA_Field::destroy_device(){ if(checkErr) checkQudaError(); d_elem = NULL; #ifdef DEVICE_MEMORY_REPORT - HGC_deviceMemory -= Bytes_total_plus_ghost()/(1024.*1024.); - if(HGC_verbosity>1) PLEGMA_printf("Device memory in use is %f MB D PLEGMA\n",HGC_deviceMemory); + HGC.deviceMemory -= Bytes_total_plus_ghost()/(1024.*1024.); + if(HGC.verbosity>1) PLEGMA_printf("Device memory in use is %f MB D PLEGMA\n",HGC.deviceMemory); #endif if(ghost_flag >= FIRST_SIDE){ #ifdef HAVE_PINNED_GHOST @@ -460,7 +460,7 @@ void PLEGMA_Field::printInfo(){ template void PLEGMA_Field::communicateSideGhost(short dir, ORIENTATION sign, ACTION action){ if(comm_size() == 1) return; - assert(Total_length()==HGC_localVolume || Total_length()==HGC_localVolume3D); + assert(Total_length()==HGC.localVolume || Total_length()==HGC.localVolume3D); if(ghost_flag < FIRST_SIDE) PLEGMA_error("First side ghosts have not been allocated.\n"); @@ -470,22 +470,22 @@ void PLEGMA_Field::communicateSideGhost(short dir, ORIENTATION sign, ACTI PLEGMA_error("Directions should be an orientation enum"); bool isAll = (dir<0) ? true:false; - bool runT = Total_length()==HGC_localVolume; - size_t scaleT = runT ? 1 : HGC_localL[DIM_T]; + bool runT = Total_length()==HGC.localVolume; + size_t scaleT = runT ? 1 : HGC.localL[DIM_T]; if(action==START || action==DO_ALL) for(short i=0; i(*this), i, s); - Float *pointer_receive = h_ext_ghost_r+HGC_sideGhost[i][s]/scaleT*field_length*2; - Float *pointer_send = h_ext_ghost_s+HGC_sideGhost[i][s]/scaleT*field_length*2; - Float *pointer_device = d_elem+(HGC_sideGhost[i][s]/scaleT+total_length)*field_length*2; + Float *pointer_receive = h_ext_ghost_r+HGC.sideGhost[i][s]/scaleT*field_length*2; + Float *pointer_send = h_ext_ghost_s+HGC.sideGhost[i][s]/scaleT*field_length*2; + Float *pointer_device = d_elem+(HGC.sideGhost[i][s]/scaleT+total_length)*field_length*2; int disp; - size_t nbytes = HGC_surface3D[i]/scaleT*field_length*2*sizeof(Float); + size_t nbytes = HGC.surface3D[i]/scaleT*field_length*2*sizeof(Float); qudaMemcpy(pointer_send, pointer_device, nbytes, qudaMemcpyDeviceToHost); if(checkErr) checkQudaError(); @@ -512,12 +512,12 @@ void PLEGMA_Field::communicateSideGhost(short dir, ORIENTATION sign, ACTI if(checkErr) checkQudaError(); } else { for(short i=0; i::communicateSideGhost(short dir, ORIENTATION sign, ACTI template void PLEGMA_Field::communicateCornerGhost(short dir, ORIENTATION sign, ACTION action){ if(comm_size() == 1) return; - assert(Total_length()==HGC_localVolume || Total_length()==HGC_localVolume3D); + assert(Total_length()==HGC.localVolume || Total_length()==HGC.localVolume3D); if(ghost_flag < FIRST_CORNER) PLEGMA_error("First corner ghosts have not been allocated.\n"); @@ -538,26 +538,26 @@ void PLEGMA_Field::communicateCornerGhost(short dir, ORIENTATION sign, AC PLEGMA_error("Directions should be an orientation enum"); bool isAll = (dir<0) ? true:false; - bool runT = Total_length()==HGC_localVolume; - size_t scaleT = runT ? 1 : HGC_localL[DIM_T]; + bool runT = Total_length()==HGC.localVolume; + size_t scaleT = runT ? 1 : HGC.localL[DIM_T]; std::vector messages; if(action==START || action==DO_ALL) for(short i=0; i(*this), i, j, s1, s2); - Float *pointer_receive = h_ext_ghost_corner_r + HGC_cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT*field_length*2; - Float *pointer_send = h_ext_ghost_corner_s + HGC_cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT*field_length*2; - Float *pointer_device = d_elem + (HGC_cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT+total_length+ghost_length)*field_length*2; + Float *pointer_receive = h_ext_ghost_corner_r + HGC.cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT*field_length*2; + Float *pointer_send = h_ext_ghost_corner_s + HGC.cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT*field_length*2; + Float *pointer_device = d_elem + (HGC.cornerGhost[OFF2SIGN(i,j,s1,s2)]/scaleT+total_length+ghost_length)*field_length*2; int disp[N_DIMS] = {0}; - size_t nbytes = HGC_surface2D[OFF2(i,j)]/scaleT*field_length*2*sizeof(Float); + size_t nbytes = HGC.surface2D[OFF2(i,j)]/scaleT*field_length*2*sizeof(Float); qudaMemcpy(pointer_send, pointer_device, nbytes, qudaMemcpyDeviceToHost); if(checkErr) checkQudaError(); @@ -589,13 +589,13 @@ void PLEGMA_Field::communicateCornerGhost(short dir, ORIENTATION sign, AC } else { for(short i=0; i::communicateCornerGhost(short dir, ORIENTATION sign, AC template void PLEGMA_Field::communicateVertexGhost(short dir, ORIENTATION sign, ACTION action){ if(comm_size() == 1) return; - assert(Total_length()==HGC_localVolume || Total_length()==HGC_localVolume3D); + assert(Total_length()==HGC.localVolume || Total_length()==HGC.localVolume3D); if(ghost_flag < FIRST_VERTEX) PLEGMA_error("First vertex ghosts have not been allocated.\n"); @@ -614,8 +614,8 @@ void PLEGMA_Field::communicateVertexGhost(short dir, ORIENTATION sign, AC PLEGMA_error("Directions should be in [-1,%d] range with -1 all directions",N_DIMS); bool isAll = (dir<0) ? true:false; - bool runT = Total_length()==HGC_localVolume; - size_t scaleT = runT ? 1 : HGC_localL[DIM_T]; + bool runT = Total_length()==HGC.localVolume; + size_t scaleT = runT ? 1 : HGC.localL[DIM_T]; std::vector messages; @@ -623,7 +623,7 @@ void PLEGMA_Field::communicateVertexGhost(short dir, ORIENTATION sign, AC for(short i=0; i::communicateVertexGhost(short dir, ORIENTATION sign, AC // collecting elements from device copy_vertex_to_ghost(toField2(*this), i, j, k, s1, s2, s3); - Float *pointer_receive = h_ext_ghost_vertex_r + HGC_vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT*field_length*2; - Float *pointer_send = h_ext_ghost_vertex_s + HGC_vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT*field_length*2; - Float *pointer_device = d_elem + (HGC_vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT+total_length+ghost_length+ghost_corner_length)*field_length*2; + Float *pointer_receive = h_ext_ghost_vertex_r + HGC.vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT*field_length*2; + Float *pointer_send = h_ext_ghost_vertex_s + HGC.vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT*field_length*2; + Float *pointer_device = d_elem + (HGC.vertexGhost[OFF3SIGN(i,j,k,s1,s2,s3)]/scaleT+total_length+ghost_length+ghost_corner_length)*field_length*2; int disp[N_DIMS] = {0}; - size_t nbytes = HGC_surface1D[OFF3(i,j,k)]/scaleT*field_length*2*sizeof(Float); + size_t nbytes = HGC.surface1D[OFF3(i,j,k)]/scaleT*field_length*2*sizeof(Float); qudaMemcpy(pointer_send, pointer_device, nbytes, qudaMemcpyDeviceToHost); if(checkErr) checkQudaError(); @@ -670,14 +670,14 @@ void PLEGMA_Field::communicateVertexGhost(short dir, ORIENTATION sign, AC for(short i=0; i::mulMomentumPhases(std::vector mom, int sign) if(!isAllocDevice) PLEGMA_error("This function needs allocation on the device to work\n"); if(sign != +1 && sign != -1) PLEGMA_error("Sign should be either +1 or -1\n"); if(mom.size() != 3 && mom.size() != 4) PLEGMA_error("Momentum size vector should be either 3 or 4\n"); - if(total_length == HGC_localVolume && mom.size() != 4 ) PLEGMA_error("A 4D field needs a 4D momentum vector\n"); - if( (total_length == HGC_localVolume3D) && mom.size() != 3 ) PLEGMA_error("A 3D field needs a 3D momentum vector\n"); + if(total_length == HGC.localVolume && mom.size() != 4 ) PLEGMA_error("A 4D field needs a 4D momentum vector\n"); + if( (total_length == HGC.localVolume3D) && mom.size() != 3 ) PLEGMA_error("A 3D field needs a 3D momentum vector\n"); int D3D4 = mom.size(); - int V = D3D4 == 3 ? HGC_localVolume3D : HGC_localVolume; + int V = D3D4 == 3 ? HGC.localVolume3D : HGC.localVolume; Float2 *x; x=(Float2 *)device_malloc(V*2*sizeof(Float)); //cudaMalloc((void**)&x, V*2*sizeof(Float)); @@ -830,12 +830,12 @@ template std::complex PLEGMA_Field::dot(PLEGMA_Field &fieldIn){ if(field_length != fieldIn.Field_length()) PLEGMA_error("The d.o.f of the fields do not match\n"); if(total_length != fieldIn.Total_length()) PLEGMA_error("The lattice points of the fields do not match\n"); - return cuBLAS::dot(total_length*field_length, d_elem, fieldIn.D_elem(), HGC_fullComm); + return cuBLAS::dot(total_length*field_length, d_elem, fieldIn.D_elem(), HGC.fullComm); } template Float PLEGMA_Field::norm(){ - return cuBLAS::norm(total_length*field_length, d_elem, HGC_fullComm); + return cuBLAS::norm(total_length*field_length, d_elem, HGC.fullComm); } template @@ -896,7 +896,7 @@ void PLEGMA_Field::copy(PLEGMA_Field &f, ALLOCATION_FLAG wher template void PLEGMA_Field::applyHpropColoring4D(PLEGMA_Field &fin,PLEGMA_Hprobing &hprob, int ih, std::vector indDof){ - if(total_length != HGC_localVolume || fin.Total_length() != HGC_localVolume) PLEGMA_error("Probing for now works only for 4D fields"); + if(total_length != HGC.localVolume || fin.Total_length() != HGC.localVolume) PLEGMA_error("Probing for now works only for 4D fields"); if(ih >= hprob.get_NHad()) PLEGMA_error("You have exceeded the size of the Hadamard matrix"); copy(fin,DEVICE); for(int i = 0 ; i < Field_length(); i++){ @@ -910,17 +910,17 @@ void PLEGMA_Field::applyHpropColoring4D(PLEGMA_Field &fin,PLEGMA_H // field4D <- field3D template void PLEGMA_Field::absorb(const PLEGMA_Field3D &field, int global_it, bool forcetozero){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); assert(field.Field_length() == this->Field_length()); if (forcetozero == true){ this->zero_where(allocation); } - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); - size_t V4 = HGC_localVolume*2; - size_t V3 = HGC_localVolume3D*2; + size_t V4 = HGC.localVolume*2; + size_t V3 = HGC.localVolume3D*2; { Float2 *tempquda=(Float2 *)device_malloc(V3 * sizeof(Float)); PLEGMA_memcpy(tempquda,tempquda,V3 * sizeof(Float),qudaMemcpyDeviceToDevice); @@ -940,7 +940,7 @@ void PLEGMA_Field::absorb(const PLEGMA_Field3D &field, int global_ template void PLEGMA_Field::writeLIME(std::string filename, bool unloadFromDev) const{ - if(total_length != HGC_localVolume) PLEGMA_error("Writing of 3D fields is not supported"); + if(total_length != HGC.localVolume) PLEGMA_error("Writing of 3D fields is not supported"); FILE *fid; LimeWriter *limewriter = (LimeWriter*)NULL; if(unloadFromDev) unload(); @@ -955,7 +955,7 @@ void PLEGMA_Field::writeLIME(std::string filename, bool unloadFromDev) co oss << lime_version_header() << "" << Field_name() << "\n" << "" << Precision()*8 << "\n"; oss << "" << field_length << "\n"; std::vector xyzt = {"x","y","z","t"}; - for(int i = 0 ; i < N_DIMS; i++) oss << "" << HGC_totalL[i] << "\n"; + for(int i = 0 ; i < N_DIMS; i++) oss << "" << HGC.totalL[i] << "\n"; oss << ""; write_lime_header(limewriter,"ildg-format",oss.str(),1,0); } @@ -1003,22 +1003,22 @@ fill_H5_shapes(std::vector &shape, std::vector &lshape, std::v } } - if(total_length == HGC_localVolume3D) { + if(total_length == HGC.localVolume3D) { descr += "/z/y/x"; // Volume for(int i=N_DIMS-2; i>=0; i--) { - shape.push_back(HGC_totalL[i]); - lshape.push_back(HGC_localL[i]); - start.push_back(HGC_procPosition[i]*HGC_localL[i]); + shape.push_back(HGC.totalL[i]); + lshape.push_back(HGC.localL[i]); + start.push_back(HGC.procPosition[i]*HGC.localL[i]); } if(not includesActiveTimeSlice()) lshape[0]=0; } else { descr += "/t/z/y/x"; // Volume for(int i=N_DIMS-1; i>=0; i--) { - shape.push_back(HGC_totalL[i]); - lshape.push_back(HGC_localL[i]); - start.push_back(HGC_procPosition[i]*HGC_localL[i]); + shape.push_back(HGC.totalL[i]); + lshape.push_back(HGC.localL[i]); + start.push_back(HGC.procPosition[i]*HGC.localL[i]); } } @@ -1034,7 +1034,7 @@ fill_H5_shapes(std::vector &shape, std::vector &lshape, std::v template void PLEGMA_Field::writeHDF5(std::string filename, bool unloadFromDev) const{ - if(total_length != HGC_localVolume && total_length != HGC_localVolume3D) + if(total_length != HGC.localVolume && total_length != HGC.localVolume3D) PLEGMA_error("Writing of 3D fields is not supported"); assert(isAllocHost); if(unloadFromDev) unload(); @@ -1054,7 +1054,7 @@ void PLEGMA_Field::writeHDF5(std::string filename, bool unloadFromDev) co } } - HDF5 writer(filename, HGC_fullComm); + HDF5 writer(filename, HGC.fullComm); writer.write_dataset(dataset, h_elem, shape, lshape, start); writer.write_attribute(dataset, "description", descr); @@ -1065,15 +1065,15 @@ void PLEGMA_Field::absorbTimeslice(PLEGMA_Field &srcfield, int glo if(!this->isAllocDevice) PLEGMA_error("This function needs allocation on the device to work\n"); if(!srcfield.IsAllocDevice()) PLEGMA_error("This function needs allocation of input field on the device to work\n"); - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); if( this->field_name.compare(srcfield.Field_name()) != 0) PLEGMA_error("Fields types does not match %s %s \n",this->field_name.c_str(),srcfield.Field_name().c_str()); //check dimensions - int my_it = global_it - comm_coord(3) * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + int my_it = global_it - comm_coord(3) * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; @@ -1135,12 +1135,12 @@ template void PLEGMA_Field::mulMomentumPhases(std::vector void PLEGMA_Field3D::absorb(const PLEGMA_Field &field, int global_it, bool broadcast){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); assert(field.Field_length() == this->Field_length()); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - this->activeTimeSlice = (my_it >= 0) && ( my_it < HGC_localL[3] ); - size_t V3 = HGC_localVolume3D*2; - size_t V4 = HGC_localVolume*2; + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + this->activeTimeSlice = (my_it >= 0) && ( my_it < HGC.localL[3] ); + size_t V3 = HGC.localVolume3D*2; + size_t V4 = HGC.localVolume*2; Float *pointer_src = NULL; Float *pointer_dst = NULL; @@ -1169,10 +1169,10 @@ void PLEGMA_Field3D::absorb(const PLEGMA_Field &field, int global_ PLEGMA_memcpy(pointer_dst, pointer_src, V3 * sizeof(Float), qudaMemcpyDeviceToDevice); } if (broadcast == true){ - int time_rank=global_it/HGC_localL[3]; + int time_rank=global_it/HGC.localL[3]; Float *temp=(Float *)malloc(sizeof(Float)*V3); PLEGMA_memcpy(temp, pointer_dst, V3* sizeof(Float), qudaMemcpyDeviceToHost); - MPI_Bcast(temp, V3 , MPI_Type(), time_rank, HGC_timeComm); + MPI_Bcast(temp, V3 , MPI_Type(), time_rank, HGC.timeComm); PLEGMA_memcpy(pointer_dst, temp, V3* sizeof(Float), qudaMemcpyHostToDevice); free(temp); } @@ -1187,9 +1187,9 @@ void PLEGMA_Field3D::absorb(const PLEGMA_Field &field, int global_ template std::complex PLEGMA_Field3D::dot(PLEGMA_Field3D &fieldIn){ // TODO: need to think about appropriate communicator - if (HGC_localVolume != HGC_totalVolume) + if (HGC.localVolume != HGC.totalVolume) PLEGMA_warning("3D Vector dot might not work with multiple MPI ranks\n"); - return cuBLAS::dot(this->total_length*this->field_length, this->d_elem, fieldIn.D_elem(), HGC_fullComm); + return cuBLAS::dot(this->total_length*this->field_length, this->d_elem, fieldIn.D_elem(), HGC.fullComm); } template class plegma::PLEGMA_Field3D; diff --git a/lib/PLEGMA_Gauge.cu b/lib/PLEGMA_Gauge.cu index 236eafa9..747e655a 100644 --- a/lib/PLEGMA_Gauge.cu +++ b/lib/PLEGMA_Gauge.cu @@ -26,7 +26,7 @@ Float PLEGMA_Gauge::calculateTopo( TOPO_CHARGE_DEF charge_def ){ this->communicateGhost(-1,DIR_BOTH,FIRST_CORNER); auto tex = toTexture(*this); Float Q = calcTopoCharge(*tex, charge_def); - if(HGC_verbosity>0) PLEGMA_printf("Calculated topological charge is %.14f\n",Q); + if(HGC.verbosity>0) PLEGMA_printf("Calculated topological charge is %.14f\n",Q); return Q; } @@ -35,7 +35,7 @@ Float PLEGMA_Gauge::calculatePlaq(){ this->communicateGhost(-1,DIR_BOTH,FIRST_SIDE); auto tex = toTexture(*this); Float plaq = calculatePlaquette>(*tex); - if(HGC_verbosity>0) PLEGMA_printf("Calculated plaquette is %f\n",plaq); + if(HGC.verbosity>0) PLEGMA_printf("Calculated plaquette is %f\n",plaq); return plaq; } @@ -45,7 +45,7 @@ Float PLEGMA_Gauge::calculatePlaqClover(){ auto tex = toTexture(*this); Float plaqClover = calcPlaqClovDef(*tex); Float plaq = calculatePlaquette>(*tex); - if(HGC_verbosity>0) PLEGMA_printf("TEST: Calculated plaquette with clover is %f; diff with reference: %e\n",plaqClover, plaqClover-plaq); + if(HGC.verbosity>0) PLEGMA_printf("TEST: Calculated plaquette with clover is %f; diff with reference: %e\n",plaqClover, plaqClover-plaq); return plaqClover; } @@ -67,7 +67,7 @@ Float PLEGMA_Gauge::calculatePlaqShifts(){ res.path(vspath, u_s, tmp); resV += res.sumRtraceU(); } - Float plaqShifts = resV/(HGC_totalVolume*N_COLS*6); + Float plaqShifts = resV/(HGC.totalVolume*N_COLS*6); this->communicateGhost(-1,DIR_BOTH,FIRST_SIDE); auto tex = toTexture(*this); @@ -90,7 +90,7 @@ Float PLEGMA_Gauge::calculatePlaqStaples(){ auto tex = toTexture(*this); Float plaq = calculatePlaquette>(*tex); - if(HGC_verbosity>0) PLEGMA_printf("TEST: Calculated plaquette using staples is %f; diff with reference: %e\n", plaqStaples, plaqStaples-plaq); + if(HGC.verbosity>0) PLEGMA_printf("TEST: Calculated plaquette using staples is %f; diff with reference: %e\n", plaqStaples, plaqStaples-plaq); return plaqStaples; } @@ -176,7 +176,7 @@ template void PLEGMA_Gauge::momPhase(Float phase[N_DIMS],int mom[N_DIMS]){ std::complex scale[N_DIMS]; for(int d=0; d &vec, int nu, int c2){ for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ pointProp_host = (this->h_elem + - mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume*2 + - nu*N_COLS*N_COLS*HGC_localVolume*2 + - c1*N_COLS*HGC_localVolume*2 + - c2*HGC_localVolume*2); - pointVec_dev = vec.D_elem() + mu*N_COLS*HGC_localVolume*2 + c1*HGC_localVolume*2; - qudaMemcpy(pointProp_host,pointVec_dev,HGC_localVolume*2*sizeof(Float),qudaMemcpyDeviceToHost); + mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume*2 + + nu*N_COLS*N_COLS*HGC.localVolume*2 + + c1*N_COLS*HGC.localVolume*2 + + c2*HGC.localVolume*2); + pointVec_dev = vec.D_elem() + mu*N_COLS*HGC.localVolume*2 + c1*HGC.localVolume*2; + qudaMemcpy(pointProp_host,pointVec_dev,HGC.localVolume*2*sizeof(Float),qudaMemcpyDeviceToHost); } checkQudaError(); } @@ -37,12 +37,12 @@ void PLEGMA_Propagator::absorb(PLEGMA_Vector &vec, int nu, int c2) for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ pointProp_dev = (this->d_elem + - mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume*2 + - nu*N_COLS*N_COLS*HGC_localVolume*2 + - c1*N_COLS*HGC_localVolume*2 + - c2*HGC_localVolume*2); - pointVec_dev = vec.D_elem() + mu*N_COLS*HGC_localVolume*2 + c1*HGC_localVolume*2; - qudaMemcpy(pointProp_dev,pointVec_dev,HGC_localVolume*2*sizeof(Float), + mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume*2 + + nu*N_COLS*N_COLS*HGC.localVolume*2 + + c1*N_COLS*HGC.localVolume*2 + + c2*HGC.localVolume*2); + pointVec_dev = vec.D_elem() + mu*N_COLS*HGC.localVolume*2 + c1*HGC.localVolume*2; + qudaMemcpy(pointProp_dev,pointVec_dev,HGC.localVolume*2*sizeof(Float), qudaMemcpyDeviceToDevice); } checkQudaError(); @@ -51,11 +51,11 @@ void PLEGMA_Propagator::absorb(PLEGMA_Vector &vec, int nu, int c2) // Prop4D <- Vec4D (it) template void PLEGMA_Propagator::absorb(PLEGMA_Vector &vec, int global_it, int nu, int c2){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; static bool init_prop4D_vec4D = false; @@ -83,11 +83,11 @@ void PLEGMA_Propagator::absorb(PLEGMA_Vector &vec, int global_it, //Prop4D <- Vec3D template void PLEGMA_Propagator::absorb(PLEGMA_Vector3D &vec, int global_it, int nu, int c2){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; static bool init_prop4D_vec3D = false; @@ -135,7 +135,7 @@ void PLEGMA_Propagator::pack_propagator_as_sink(PLEGMA_Propagator vector1.absorb(in, sinktimeslice, isc/3, isc%3,true); for (int dt=0; dt::rotateToPhysicalBase_host(int sign_int){ imag_unit.real(0.0); imag_unit.imag(1.0); - for(int iv = 0 ; iv < HGC_localVolume ; iv++) + for(int iv = 0 ; iv < HGC.localVolume ; iv++) for(int c1 = 0 ; c1 < 3 ; c1++) for(int c2 = 0 ; c2 < 3 ; c2++){ for(int mu = 0 ; mu < 4 ; mu++) for(int nu = 0 ; nu < 4 ; nu++){ - //P[mu][nu].real() = this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + nu*N_COLS*N_COLS*HGC_localVolume + c1*N_COLS*HGC_localVolume + c2*HGC_localVolume + iv)*2 + 0]; - //P[mu][nu].imag() = this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + nu*N_COLS*N_COLS*HGC_localVolume + c1*N_COLS*HGC_localVolume + c2*HGC_localVolume + iv)*2 + 1] - P[mu][nu].real(this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + - nu*N_COLS*N_COLS*HGC_localVolume + - c1*N_COLS*HGC_localVolume + - c2*HGC_localVolume + iv)*2 + 0]); - P[mu][nu].imag(this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + - nu*N_COLS*N_COLS*HGC_localVolume + - c1*N_COLS*HGC_localVolume + - c2*HGC_localVolume + iv)*2 + 1]); + //P[mu][nu].real() = this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + nu*N_COLS*N_COLS*HGC.localVolume + c1*N_COLS*HGC.localVolume + c2*HGC.localVolume + iv)*2 + 0]; + //P[mu][nu].imag() = this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + nu*N_COLS*N_COLS*HGC.localVolume + c1*N_COLS*HGC.localVolume + c2*HGC.localVolume + iv)*2 + 1] + P[mu][nu].real(this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + + nu*N_COLS*N_COLS*HGC.localVolume + + c1*N_COLS*HGC.localVolume + + c2*HGC.localVolume + iv)*2 + 0]); + P[mu][nu].imag(this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + + nu*N_COLS*N_COLS*HGC.localVolume + + c1*N_COLS*HGC.localVolume + + c2*HGC.localVolume + iv)*2 + 1]); } PT[0][0] = coeff * (P[0][0] + sign * ( imag_unit * P[0][2] ) + sign * ( imag_unit * P[2][0] ) - P[2][2]); @@ -227,14 +227,14 @@ void PLEGMA_Propagator::rotateToPhysicalBase_host(int sign_int){ for(int mu = 0 ; mu < 4 ; mu++) for(int nu = 0 ; nu < 4 ; nu++){ - this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + - nu*N_COLS*N_COLS*HGC_localVolume + - c1*N_COLS*HGC_localVolume + - c2*HGC_localVolume + iv)*2 + 0] = PT[mu][nu].real(); - this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + - nu*N_COLS*N_COLS*HGC_localVolume + - c1*N_COLS*HGC_localVolume + - c2*HGC_localVolume + iv)*2 + 1] = PT[mu][nu].imag(); + this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + + nu*N_COLS*N_COLS*HGC.localVolume + + c1*N_COLS*HGC.localVolume + + c2*HGC.localVolume + iv)*2 + 0] = PT[mu][nu].real(); + this->h_elem[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + + nu*N_COLS*N_COLS*HGC.localVolume + + c1*N_COLS*HGC.localVolume + + c2*HGC.localVolume + iv)*2 + 1] = PT[mu][nu].imag(); } } } @@ -269,7 +269,7 @@ template void PLEGMA_Propagator3D:: absorbTimeSliceFromHost(PLEGMA_Propagator &prop, int timeslice){ - int V3 = HGC_localVolume/HGC_localL[3]; + int V3 = HGC.localVolume/HGC.localL[3]; for(int mu = 0 ; mu < 4 ; mu++) for(int nu = 0 ; nu < 4 ; nu++) @@ -281,10 +281,10 @@ absorbTimeSliceFromHost(PLEGMA_Propagator &prop, nu*N_COLS*N_COLS*V3 + c1*N_COLS*V3 + c2*V3 + iv3)*2 + ipart] = - prop.H_elem()[(mu*N_SPINS*N_COLS*N_COLS*HGC_localVolume + - nu*N_COLS*N_COLS*HGC_localVolume + - c1*N_COLS*HGC_localVolume + - c2*HGC_localVolume + + prop.H_elem()[(mu*N_SPINS*N_COLS*N_COLS*HGC.localVolume + + nu*N_COLS*N_COLS*HGC.localVolume + + c1*N_COLS*HGC.localVolume + + c2*HGC.localVolume + timeslice*V3 + iv3)*2 + ipart]; qudaMemcpy(this->d_elem,this->h_elem, @@ -296,12 +296,12 @@ absorbTimeSliceFromHost(PLEGMA_Propagator &prop, //Prop3D <- Vec4D template void PLEGMA_Propagator3D::absorb(PLEGMA_Vector &vec, int global_it, int nu, int c2){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); this->activeTimeSlice = is_myIt; - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; @@ -332,7 +332,7 @@ void PLEGMA_Propagator3D::absorb(PLEGMA_Vector &vec, int global_it template void PLEGMA_Propagator3D::absorb(PLEGMA_Vector3D &vec, int nu, int c2){ this->activeTimeSlice = vec.includesActiveTimeSlice(); - int V3 = HGC_localVolume/HGC_localL[3]; + int V3 = HGC.localVolume/HGC.localL[3]; Float *pointer_src = NULL; Float *pointer_dst = NULL; for(int mu = 0 ; mu < N_SPINS ; mu++) diff --git a/lib/PLEGMA_QLoops.cu b/lib/PLEGMA_QLoops.cu index ba5fe735..37963f22 100644 --- a/lib/PLEGMA_QLoops.cu +++ b/lib/PLEGMA_QLoops.cu @@ -245,8 +245,8 @@ void PLEGMA_QLoops::oneEnd_trick_wilsonLine(PLEGMA_Vector &x_l, PL std::complex cr; cr.real(val); cr.imag(0.); - if(!(HGC_totalL[0] == HGC_totalL[1] && HGC_totalL[1] == HGC_totalL[2])) PLEGMA_error("Spatial total volume should be symmetric for this to work"); - int L=HGC_totalL[0]; + if(!(HGC.totalL[0] == HGC.totalL[1] && HGC.totalL[1] == HGC.totalL[2])) PLEGMA_error("Spatial total volume should be symmetric for this to work"); + int L=HGC.totalL[0]; if(L%2 != 0) PLEGMA_error("If spatial extent is not multiple of 2 then it will not work"); int Lo2 = L/2; for(int wilsDir = 0 ; wilsDir < 3; wilsDir++){ diff --git a/lib/PLEGMA_ScattCorrelator.cu b/lib/PLEGMA_ScattCorrelator.cu index 30f725c1..07e40878 100644 --- a/lib/PLEGMA_ScattCorrelator.cu +++ b/lib/PLEGMA_ScattCorrelator.cu @@ -378,15 +378,15 @@ Float *PLEGMA_ScattCorrelator::get_source_time_slice(){ size_timeslice *= 2; } Float *ptr=((Float *)malloc(sizeof(Float)*size_timeslice)); - const int t_source_local= this->source[DIM_T]%HGC_localL[DIM_T]; + const int t_source_local= this->source[DIM_T]%HGC.localL[DIM_T]; memcpy(ptr, this->H_elem()+t_source_local*size_timeslice, sizeof(Float)*size_timeslice); int coords[4]; - for(int i = 0 ; i < N_DIMS; i++) coords[i] = this->getSource()[i] / HGC_localL[i]; + for(int i = 0 ; i < N_DIMS; i++) coords[i] = this->getSource()[i] / HGC.localL[i]; int rankHas = comm_rank_from_coords(coords); - int mpiErr = MPI_Bcast(ptr, size_timeslice, MPI_Type(), rankHas, HGC_fullComm); + int mpiErr = MPI_Bcast(ptr, size_timeslice, MPI_Type(), rankHas, HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); - MPI_Barrier(HGC_fullComm); + MPI_Barrier(HGC.fullComm); // PLEGMA_printf("DEBUG ptr global %e %e\n",ptr[0],ptr[1]); return ptr; } @@ -409,20 +409,20 @@ Float *PLEGMA_ScattCorrelator::get_time_slice(int global_time_index){ size_timeslice *= 2; } Float *ptr=((Float *)malloc(sizeof(Float)*size_timeslice)); - const int t_source_local= global_time_index%HGC_localL[DIM_T]; + const int t_source_local= global_time_index%HGC.localL[DIM_T]; memcpy(ptr, this->H_elem()+t_source_local*size_timeslice, sizeof(Float)*size_timeslice); printf("ptr %e\n",ptr[0]); int coords[4]; for(int i = 0 ; i < (N_DIMS-1); i++) coords[i] = 0; - coords[N_DIMS-1]=global_time_index / HGC_localL[N_DIMS-1]; + coords[N_DIMS-1]=global_time_index / HGC.localL[N_DIMS-1]; int rankHas = comm_rank_from_coords(coords); printf("rankHas %d\n",rankHas); - MPI_Barrier(HGC_fullComm); - int mpiErr = MPI_Bcast(ptr, size_timeslice, MPI_Type(), rankHas, HGC_fullComm); + MPI_Barrier(HGC.fullComm); + int mpiErr = MPI_Bcast(ptr, size_timeslice, MPI_Type(), rankHas, HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); printf("ptrafter %e\n",ptr[0]); fflush(stdout); - MPI_Barrier(HGC_fullComm); + MPI_Barrier(HGC.fullComm); return ptr; } @@ -453,7 +453,7 @@ std::shared_ptr PLEGMA_ScattCorrelator::average_all_time_slices(){ for (int j=0; j::V5V6reduction(PLEGMA_ScattCorrelator auto imap = this->pList().index_map(); std::vector> Phi1; - for (int t=0; tgetPointSource(actualSource,HOST)); } for(int t=0; t < TIME; ++t){ - int global_time_index = t + HGC_procPosition[3] * HGC_localL[3]; + int global_time_index = t + HGC.procPosition[3] * HGC.localL[3]; for (int g2=0 ; g2 < n_gammas_i2 ; ++g2 ){//gi2 Float phi0Aux[N_SPINS*N_COLS*2]; @@ -879,13 +879,13 @@ void PLEGMA_ScattCorrelator::V5V6reduction_matrix(PLEGMA_ScattCorrelator< auto imap = this->pList().index_map(); std::vector> Phi1; - for (int t=0; tgetPointSource(actualSource,HOST)); } for (int t=0; t::M_diagrams( PLEGMA_ScattCorrelator &C Float *sinktimeslice; int globalSinkTimeSlice; if (CorrNucleon.GList.size() >4){ - globalSinkTimeSlice=(this->source[3]+this->getTotalT()-1)%HGC_totalL[3]; + globalSinkTimeSlice=(this->source[3]+this->getTotalT()-1)%HGC.totalL[3]; sinktimeslice=pipi_aux.get_time_slice(globalSinkTimeSlice); //pipi_aux.writeHDF5("testcase"); //PLEGMA_printf("zero component %e %d %d total %d \n",sinktimeslice[0], globalSinkTimeSlice, this->localT(), this->getTotalT()); @@ -3458,8 +3458,8 @@ void PLEGMA_ScattCorrelator::applyBoundaryConditions( bool antiperiodic, if (n_coherent_source >1 && attract_look_up_table==NULL) PLEGMA_error("attract_look_up_table must be created before using this function\n"); for( int t=0; t=maxT) ? (this->source[DIM_T]%HGC_localL[DIM_T]) + t - maxT : t; - int t_global = HGC_procPosition[DIM_T] * HGC_localL[DIM_T] + t_local; + int t_local = (t>=maxT) ? (this->source[DIM_T]%HGC.localL[DIM_T]) + t - maxT : t; + int t_global = HGC.procPosition[DIM_T] * HGC.localL[DIM_T] + t_local; int source_num= n_coherent_source > 1 ? attract_look_up_table[t_global] : this->source[DIM_T]; if( t_global < source_num ){ for( int o_dofs=0; o_dofs::applyBoundaryConditions_3pt( bool antiperiod if (n_coherent_source >1 && attract_look_up_table==NULL) PLEGMA_error("attract_look_up_table must be created before using this function\n"); for( int t=0; t=maxT) ? (this->source[DIM_T]%HGC_localL[DIM_T]) + t - maxT : t; - int t_global = HGC_procPosition[DIM_T] * HGC_localL[DIM_T] + t_local; + int t_local = (t>=maxT) ? (this->source[DIM_T]%HGC.localL[DIM_T]) + t - maxT : t; + int t_global = HGC.procPosition[DIM_T] * HGC.localL[DIM_T] + t_local; int source_num= n_coherent_source > 1 ? attract_look_up_table[t_global] : this->source[DIM_T]; - if( source_num + source_sink_separation > HGC_totalL[3] ){ + if( source_num + source_sink_separation > HGC.totalL[3] ){ for( int o_dofs=0; o_dofsH_elem() + o_dofs*TIME*in_dofs + t*in_dofs + i_dofs) = -*(this->H_elem() + o_dofs*TIME*in_dofs + t*in_dofs + i_dofs); @@ -3513,9 +3513,9 @@ void PLEGMA_ScattCorrelator::apply_phase(){ #pragma omp parallel for for( int i_m=0; i_msource[0]+ - 2*M_PI/(Float)HGC_totalL[1]* mom_list[i_m][1]*this->source[1]+ - 2*M_PI/(Float)HGC_totalL[2]* mom_list[i_m][2]*this->source[2]; + Float phase=2*M_PI/(Float)HGC.totalL[0]* mom_list[i_m][0]*this->source[0]+ + 2*M_PI/(Float)HGC.totalL[1]* mom_list[i_m][1]*this->source[1]+ + 2*M_PI/(Float)HGC.totalL[2]* mom_list[i_m][2]*this->source[2]; Float tmpreim[2]={cos(phase),sin(phase)}; for( int o_dofs=0; o_dofs( this->H_elem() + (o_dofs*N_moms+i_m)*in_dofs, tmpreim, in_dofs/2); @@ -3681,11 +3681,11 @@ void PLEGMA_ScattCorrelator::absorbTimeslice(PLEGMA_ScattCorrelator= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - comm_coord(3) * HGC_localL[3]; + int my_it = global_it - comm_coord(3) * HGC.localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); if (forcetozero == true && !this->labels.empty()){ int tot_size = 2*this->getTotalSize(); @@ -3728,9 +3728,9 @@ void PLEGMA_ScattCorrelator::absorbTimeslice(PLEGMA_ScattCorrelatorH_elem(), in_dofs_src*out_dofs_src , MPI_Type(), rankHas, HGC_fullComm); + int mpiErr = MPI_Bcast(this->H_elem(), in_dofs_src*out_dofs_src , MPI_Type(), rankHas, HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); } diff --git a/lib/PLEGMA_U1Gauge.cu b/lib/PLEGMA_U1Gauge.cu index 687b3c7a..87e5157d 100644 --- a/lib/PLEGMA_U1Gauge.cu +++ b/lib/PLEGMA_U1Gauge.cu @@ -13,7 +13,7 @@ Float PLEGMA_U1Gauge::calculatePlaq(){ this->communicateGhost(-1,DIR_BOTH,FIRST_SIDE); auto tex = toTexture(*this); Float plaq = calculatePlaquette>(*tex); - if(HGC_verbosity>0) PLEGMA_printf("Calculated plaquette is %f\n",plaq); + if(HGC.verbosity>0) PLEGMA_printf("Calculated plaquette is %f\n",plaq); return plaq; } @@ -32,15 +32,15 @@ void PLEGMA_U1Gauge::modifyBoundaries(int mu, int nu, Float exparg){ #endif if(last_node_in_mu){ int x[4]; - for(x[3]=0; x[3] < HGC_localL[3]; x[3]++) - for(x[2]=0; x[2] < HGC_localL[2]; x[2]++) - for(x[1]=0; x[1] < HGC_localL[1]; x[1]++) - for(x[0]=0; x[0] < HGC_localL[0]; x[0]++){ - if(x[mu] == HGC_localL[mu]-1){ - size_t idx=((x[3]*HGC_localL[2]+x[2])*HGC_localL[1]+x[1])*HGC_localL[0]+x[0]; - size_t r=mu*HGC_localVolume+idx; + for(x[3]=0; x[3] < HGC.localL[3]; x[3]++) + for(x[2]=0; x[2] < HGC.localL[2]; x[2]++) + for(x[1]=0; x[1] < HGC.localL[1]; x[1]++) + for(x[0]=0; x[0] < HGC.localL[0]; x[0]++){ + if(x[mu] == HGC.localL[mu]-1){ + size_t idx=((x[3]*HGC.localL[2]+x[2])*HGC.localL[1]+x[1])*HGC.localL[0]+x[0]; + size_t r=mu*HGC.localVolume+idx; if(nu > 0){ - Float val = exparg*HGC_totalL[mu]*(HGC_procPosition[nu]*HGC_localL[nu] + x[nu]); + Float val = exparg*HGC.totalL[mu]*(HGC.procPosition[nu]*HGC.localL[nu] + x[nu]); this->h_elem[2*r+0]=cos(val); this->h_elem[2*r+1]=sin(val); } else{ diff --git a/lib/PLEGMA_Vector.cu b/lib/PLEGMA_Vector.cu index 8d182d4e..871d85d6 100644 --- a/lib/PLEGMA_Vector.cu +++ b/lib/PLEGMA_Vector.cu @@ -126,11 +126,11 @@ void PLEGMA_Vector::rotate_uk_ch_g5g4(){ // vec4D <- Prop3D template void PLEGMA_Vector::absorb(PLEGMA_Propagator3D &prop, int global_it, int nu , int c2){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; static bool init_absorb_vec4D_prop3D = false; @@ -160,11 +160,11 @@ void PLEGMA_Vector::absorb(PLEGMA_Propagator3D &prop, int global_i // vec4D <- prop4D (it) template void PLEGMA_Vector::absorb(PLEGMA_Propagator &prop, int global_it, int nu , int c2){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; for(int mu = 0 ; mu < N_SPINS ; mu++) @@ -183,11 +183,11 @@ void PLEGMA_Vector::absorb(PLEGMA_Propagator &prop, int global_it, //vec4D <- vec3D (it) template void PLEGMA_Vector::absorb(PLEGMA_Vector3D &vec, int global_it, bool broadcast){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; @@ -220,7 +220,7 @@ template void PLEGMA_Vector::absorb(PLEGMA_Propagator &prop, int nu , int c2){ Float *pointer_src = NULL; Float *pointer_dst = NULL; - int V4 = HGC_localVolume; + int V4 = HGC.localVolume; for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ pointer_dst = (this->d_elem + mu*N_COLS*V4*2 + c1*V4*2); @@ -238,8 +238,8 @@ void PLEGMA_Vector::dilutespin(PLEGMA_Vector &vecIn, int spin){ for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ if(mu == spin){ - pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC_localVolume*2); - qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC_localVolume)*2), pointer_src, HGC_localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); + pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC.localVolume*2); + qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC.localVolume)*2), pointer_src, HGC.localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); } } checkQudaError(); @@ -253,8 +253,8 @@ void PLEGMA_Vector::dilutecolor(PLEGMA_Vector &vecIn, int color){ for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ if(c1 == color){ - pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC_localVolume*2); - qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC_localVolume)*2), pointer_src, HGC_localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); + pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC.localVolume*2); + qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC.localVolume)*2), pointer_src, HGC.localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); } } checkQudaError(); @@ -269,8 +269,8 @@ void PLEGMA_Vector::dilutespincolor(PLEGMA_Vector &vecIn, int spin for(int mu = 0 ; mu < N_SPINS ; mu++) for(int c1 = 0 ; c1 < N_COLS ; c1++){ if(c1 == color && mu == spin){ - pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC_localVolume*2); - qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC_localVolume)*2), pointer_src, HGC_localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); + pointer_src = (vecIn.D_elem() + (c1 + mu*N_COLS)*HGC.localVolume*2); + qudaMemcpy((this->d_elem + ((c1 + mu*N_COLS)*HGC.localVolume)*2), pointer_src, HGC.localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); } } checkQudaError(); @@ -282,8 +282,8 @@ void PLEGMA_Vector::diluteSpinDisplace(PLEGMA_Vector &vecIn, int s if( (spin1 >= N_SPINS) || (spin2>=N_SPINS) ) PLEGMA_error("The spin index you provided exceed the total spin content\n"); this->zero_device(); for(int c1 = 0 ; c1 < N_COLS ; c1++){ - pointer_src = (vecIn.D_elem() + (c1 + spin2*N_COLS)*HGC_localVolume*2); - qudaMemcpy((this->d_elem + ((c1 + spin1*N_COLS)*HGC_localVolume)*2), pointer_src, HGC_localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); + pointer_src = (vecIn.D_elem() + (c1 + spin2*N_COLS)*HGC.localVolume*2); + qudaMemcpy((this->d_elem + ((c1 + spin1*N_COLS)*HGC.localVolume)*2), pointer_src, HGC.localVolume*2 * sizeof(Float), qudaMemcpyDeviceToDevice); } checkQudaError(); @@ -300,7 +300,7 @@ void PLEGMA_Vector::pack_fermion_to_sink(std::vector PLEGMA_Vector temporary4D; PLEGMA_Vector3D temporary3D; - for (int timeidx=0; timeidx< HGC_totalL[DIM_T]; ++timeidx){ + for (int timeidx=0; timeidx< HGC.totalL[DIM_T]; ++timeidx){ temporary4D.copy(*stochastic_vector[timeidx], HOST); temporary4D.load(); temporary3D.absorb(temporary4D, sinktime ); @@ -329,7 +329,7 @@ void PLEGMA_Vector::pack_propagator_as_sink(PLEGMA_Vector &in, int vector1.absorb(in, sinktimeslice, true); for (int dt=0; dt::pack_propagator_from_source_to_sink(PLEGMA_Vector void PLEGMA_Vector::pointSource(const site& sourceposition, int spin, int color, ALLOCATION_FLAG where){ if(where == EVERY) where = this->allocation; for(int i = 0; i < N_DIMS; i++) - if(sourceposition[i] >= HGC_totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC_totalL[i]); + if(sourceposition[i] >= HGC.totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC.totalL[i]); this->zero_where(where); int my_src[N_DIMS]; @@ -386,12 +386,12 @@ void PLEGMA_Vector::pointSource(const site& sourceposition, int spin, int } for(int i = N_DIMS-1; i >= 0; i--) { - my_src[i] = (sourceposition[i] - HGC_procPosition[i] * HGC_localL[i]); + my_src[i] = (sourceposition[i] - HGC.procPosition[i] * HGC.localL[i]); // if out of the local lattice we break - if((my_src[i]<0) || (my_src[i]>=HGC_localL[i])) return; + if((my_src[i]<0) || (my_src[i]>=HGC.localL[i])) return; - id = id * HGC_localL[i] + my_src[i]; + id = id * HGC.localL[i] + my_src[i]; } // This make it work also for vector3D id = id % this->Total_length(); @@ -399,7 +399,7 @@ void PLEGMA_Vector::pointSource(const site& sourceposition, int spin, int Float temp[1]; temp[0] = 1.0; if( where == BOTH ){ - this->h_elem[((spin*N_COLS+color)*HGC_localVolume + id)*2] = 1.0; + this->h_elem[((spin*N_COLS+color)*HGC.localVolume + id)*2] = 1.0; PLEGMA_memcpy((this->d_elem + ((spin*N_COLS+color)*this->Total_length() + id)*2), temp,sizeof(Float), qudaMemcpyHostToDevice ); } @@ -420,7 +420,7 @@ std::shared_ptr PLEGMA_Vector::getPointSource( const site& sourcep std::shared_ptr ptr(new Float[N_SPINS*N_COLS*2]); for(int i = 0; i < N_DIMS; i++) - if(sourceposition[i] >= HGC_totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC_totalL[i]); + if(sourceposition[i] >= HGC.totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC.totalL[i]); int my_src[N_DIMS]; @@ -428,9 +428,9 @@ std::shared_ptr PLEGMA_Vector::getPointSource( const site& sourcep size_t id=0; for(int i = N_DIMS-1; i >= 0; i--) { - my_src[i] = (sourceposition[i] - HGC_procPosition[i] * HGC_localL[i]); + my_src[i] = (sourceposition[i] - HGC.procPosition[i] * HGC.localL[i]); - id = id * HGC_localL[i] + my_src[i]; + id = id * HGC.localL[i] + my_src[i]; } @@ -438,24 +438,24 @@ std::shared_ptr PLEGMA_Vector::getPointSource( const site& sourcep id = id % this->Total_length(); int coords[4]; - for(int i = 0 ; i < N_DIMS; i++) coords[i] = sourceposition[i] / HGC_localL[i]; + for(int i = 0 ; i < N_DIMS; i++) coords[i] = sourceposition[i] / HGC.localL[i]; int rankHas = comm_rank_from_coords(coords); if (comm_rank()==rankHas){ for (int spin=0; spinh_elem[((spin*N_COLS+color)*HGC_localVolume + id)*2] ; - ptr.get()[2*(spin*N_COLS+color)+1]=this->h_elem[((spin*N_COLS+color)*HGC_localVolume + id)*2+1] ; + ptr.get()[2*(spin*N_COLS+color)+0]=this->h_elem[((spin*N_COLS+color)*HGC.localVolume + id)*2] ; + ptr.get()[2*(spin*N_COLS+color)+1]=this->h_elem[((spin*N_COLS+color)*HGC.localVolume + id)*2+1] ; } } } - MPI_Barrier(HGC_fullComm); + MPI_Barrier(HGC.fullComm); - int mpiErr = MPI_Bcast(ptr.get(), 2*N_SPINS*N_COLS, MPI_Type(), rankHas, HGC_fullComm); + int mpiErr = MPI_Bcast(ptr.get(), 2*N_SPINS*N_COLS, MPI_Type(), rankHas, HGC.fullComm); - MPI_Barrier(HGC_fullComm); + MPI_Barrier(HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); @@ -515,7 +515,7 @@ namespace plegma{ template void PLEGMA_Vector3D::absorb(PLEGMA_Propagator3D &prop, int nu , int c2){ this->activeTimeSlice = prop.includesActiveTimeSlice(); - int V3 = HGC_localVolume/HGC_localL[3]; + int V3 = HGC.localVolume/HGC.localL[3]; Float *pointer_src = NULL; Float *pointer_dst = NULL; for(int mu = 0 ; mu < N_SPINS ; mu++) @@ -530,12 +530,12 @@ namespace plegma{ // vec3D <- prop4D template void PLEGMA_Vector3D::absorb(PLEGMA_Propagator &prop, int global_it, int nu , int c2, bool broadcast){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); this->activeTimeSlice = is_myIt; - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; static bool init_vector3D_prop4D = false; @@ -559,12 +559,12 @@ namespace plegma{ } if (broadcast == true){ - int time_rank=global_it/HGC_localL[3]; + int time_rank=global_it/HGC.localL[3]; // printf("Time rank %d\n",time_rank); // fflush(stdout); Float *temp=(Float *)malloc(sizeof(Float)*V3*2); PLEGMA_memcpy(temp, pointer_dst, V3*2 * sizeof(Float), qudaMemcpyDeviceToHost); - MPI_Bcast(temp, V3*2 , MPI_Type(), time_rank, HGC_timeComm); + MPI_Bcast(temp, V3*2 , MPI_Type(), time_rank, HGC.timeComm); // printf("Temp 0 %e\n",temp[0]); // fflush(stdout); PLEGMA_memcpy(pointer_dst, temp, V3*2 * sizeof(Float), qudaMemcpyHostToDevice); @@ -582,12 +582,12 @@ namespace plegma{ // vec3D <- vec4D template void PLEGMA_Vector3D::absorb(PLEGMA_Vector &prop, int global_it, bool broadcast){ - if(global_it >= HGC_totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); - int my_it = global_it - HGC_procPosition[3] * HGC_localL[3]; - bool is_myIt = (my_it >= 0) && ( my_it < HGC_localL[3] ); + if(global_it >= HGC.totalL[3]) PLEGMA_error("The global time slice you provided exceed the temporal extent\n"); + int my_it = global_it - HGC.procPosition[3] * HGC.localL[3]; + bool is_myIt = (my_it >= 0) && ( my_it < HGC.localL[3] ); this->activeTimeSlice = is_myIt; - int V3 = HGC_localVolume/HGC_localL[3]; - int V4 = HGC_localVolume; + int V3 = HGC.localVolume/HGC.localL[3]; + int V4 = HGC.localVolume; Float *pointer_src = NULL; Float *pointer_dst = NULL; static bool init_vector3D_vector4D = false; @@ -608,12 +608,12 @@ namespace plegma{ PLEGMA_memcpy(pointer_dst, pointer_src, V3*2 * sizeof(Float), qudaMemcpyDeviceToDevice); } if (broadcast == true){ - int time_rank=global_it/HGC_localL[3]; + int time_rank=global_it/HGC.localL[3]; // printf("Time rank %d\n",time_rank); // fflush(stdout); Float *temp=(Float *)malloc(sizeof(Float)*V3*2); PLEGMA_memcpy(temp, pointer_dst, V3*2 * sizeof(Float), qudaMemcpyDeviceToHost); - MPI_Bcast(temp, V3*2 , MPI_Type(), time_rank, HGC_timeComm); + MPI_Bcast(temp, V3*2 , MPI_Type(), time_rank, HGC.timeComm); // printf("Temp 0 %e\n",temp[0]); // fflush(stdout); PLEGMA_memcpy(pointer_dst, temp, V3*2 * sizeof(Float), qudaMemcpyHostToDevice); @@ -635,19 +635,19 @@ namespace plegma{ std::vector PLEGMA_Vector3D::rms(std::vector listR2, const site& sourceposition) const{ if(listR2.size() <= 0) PLEGMA_error("Provided list of r2 is empty"); for(int i = 0; i < N_DIMS; i++) - if(sourceposition[i] >= HGC_totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC_totalL[i]); + if(sourceposition[i] >= HGC.totalL[i]) PLEGMA_error("Source position component in dir=%d, is %d >= %d the lattice extent", i, sourceposition[i],HGC.totalL[i]); std::vector absPsi_loc(listR2.size(),0.0); std::vector absPsi(listR2.size(),0.0); if(this->includesActiveTimeSlice()) { compute_rms(*this,listR2,absPsi_loc,sourceposition); - int mpiErr = MPI_Allreduce(absPsi_loc.data(), absPsi.data(), listR2.size(), MPI_Type(), MPI_SUM, HGC_spaceComm); + int mpiErr = MPI_Allreduce(absPsi_loc.data(), absPsi.data(), listR2.size(), MPI_Type(), MPI_SUM, HGC.spaceComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Allreduce failed with error %d\n", mpiErr); } int coords[4]; - for(int i = 0 ; i < N_DIMS; i++) coords[i] = sourceposition[i] / HGC_localL[i]; + for(int i = 0 ; i < N_DIMS; i++) coords[i] = sourceposition[i] / HGC.localL[i]; int rankHas = comm_rank_from_coords(coords); - int mpiErr = MPI_Bcast(absPsi.data(), listR2.size(), MPI_Type(), rankHas, HGC_fullComm); + int mpiErr = MPI_Bcast(absPsi.data(), listR2.size(), MPI_Type(), rankHas, HGC.fullComm); if(mpiErr != MPI_SUCCESS) PLEGMA_error("MPI_Bcast failed with error %d\n", mpiErr); return absPsi; } diff --git a/lib/kernels/PLEGMA_FT.cuh b/lib/kernels/PLEGMA_FT.cuh index 40bae8e1..3270cd08 100644 --- a/lib/kernels/PLEGMA_FT.cuh +++ b/lib/kernels/PLEGMA_FT.cuh @@ -15,11 +15,11 @@ struct MomF{ int x[4] = GET_ID(id); #pragma unroll for(int i=0; i<4; i++) - x[i] += DGC_procPosition[i] * DGC_localL[i]; - Float phase = ((Float) momx*x[0]) / ((Float) DGC_totalL[0]) + - ((Float) momy*x[1]) / ((Float) DGC_totalL[1]) + - ((Float) momz*x[2]) / ((Float) DGC_totalL[2]) + - ((Float) momt*x[3]) / ((Float) DGC_totalL[3]); + x[i] += DGC->procPosition[i] * DGC->localL[i]; + Float phase = ((Float) momx*x[0]) / ((Float) DGC->totalL[0]) + + ((Float) momy*x[1]) / ((Float) DGC->totalL[1]) + + ((Float) momz*x[2]) / ((Float) DGC->totalL[2]) + + ((Float) momt*x[3]) / ((Float) DGC->totalL[3]); Float2 &el = (thrust::get<1>(t)); phase *= 2. * PI; el.x = cos(phase); @@ -34,7 +34,7 @@ static void createMomField(Float2 *x, std::vector mom, int D3D4, i else if (D3D4 == 4){ if(mom.size() != 4) PLEGMA_error("A momentum vector in four dimensions need four components\n");} else PLEGMA_error("Not supported"); - int V = (D3D4 == 3) ? HGC_localVolume/HGC_localL[3] : HGC_localVolume; + int V = (D3D4 == 3) ? HGC.localVolume/HGC.localL[3] : HGC.localVolume; thrust::counting_iterator first(0); thrust::counting_iterator last = first + V; thrust::device_ptr > dev_ptr(x); @@ -52,8 +52,8 @@ static void FT_dot(PLEGMA_FT &ft, const PLEGMA_Field &f, std::vect if(sign != +1 && sign != -1) PLEGMA_error("Sign should be either +1 or -1\n"); if(mom.size() == 0) PLEGMA_error("Momentum container is empty"); int Nmom = mom.size(); - int V3 = HGC_localVolume/HGC_localL[3]; - int V = ft.Dims() == 3 ? V3 : HGC_localVolume; + int V3 = HGC.localVolume/HGC.localL[3]; + int V = ft.Dims() == 3 ? V3 : HGC.localVolume; Float2 *x; x=(Float*)device_malloc(V*2*sizeof(Float)); qudaMemset(x,0,V*2*sizeof(Float)); @@ -63,8 +63,8 @@ static void FT_dot(PLEGMA_FT &ft, const PLEGMA_Field &f, std::vect for(int idf = 0 ; idf < f.Field_length(); idf++) for(int it = 0 ; it < ft.DimT(); it++){ Float2 *y = (Float2 *)f.D_elem() + idf*f.Total_length() + it*V3; - std::complex res = cuBLAS::dot((ft.Dims() == 3) ? V3 : HGC_localVolume, (Float*) x,(Float*) y, - (ft.Dims() == 3) ? HGC_spaceComm : HGC_fullComm); + std::complex res = cuBLAS::dot((ft.Dims() == 3) ? V3 : HGC.localVolume, (Float*) x,(Float*) y, + (ft.Dims() == 3) ? HGC.spaceComm : HGC.fullComm); ft.H_elem()[it*f.Field_length()*Nmom*2 + idf*Nmom*2 + imom*2 + 0] += res.real(); ft.H_elem()[it*f.Field_length()*Nmom*2 + idf*Nmom*2 + imom*2 + 1] += res.imag(); } @@ -77,8 +77,8 @@ static void FT_gemv(PLEGMA_FT &ft, const PLEGMA_Field &f, std::vec if(sign != +1 && sign != -1) PLEGMA_error("Sign should be either +1 or -1\n"); if(mom.size() == 0) PLEGMA_error("Momentum container is empty"); int Nmom = mom.size(); - int V3 = HGC_localVolume/HGC_localL[3]; - int V = ft.Dims() == 3 ? V3 : HGC_localVolume; + int V3 = HGC.localVolume/HGC.localL[3]; + int V = ft.Dims() == 3 ? V3 : HGC.localVolume; Float2 *x,*d_res; x=(Float2*)device_malloc(V*2*sizeof(Float)); qudaMemset(x,0,V*2*sizeof(Float)); @@ -89,9 +89,9 @@ static void FT_gemv(PLEGMA_FT &ft, const PLEGMA_Field &f, std::vec Float one[2] = {1.,0.}, zero[2] = {0.,0.}; for(int imom = 0; imom < Nmom; imom++){ createMomField(x,mom[imom],ft.Dims(),sign); - cuBLAS::gemv(TRANS,(ft.Dims() == 3) ? V3 : HGC_localVolume, f.Field_length() * ft.DimT(), one, + cuBLAS::gemv(TRANS,(ft.Dims() == 3) ? V3 : HGC.localVolume, f.Field_length() * ft.DimT(), one, (Float*) f.D_elem(), (Float*) x, zero, (Float*) d_res, (Float*) h_res, - (ft.Dims() == 3) ? HGC_spaceComm : HGC_fullComm); + (ft.Dims() == 3) ? HGC.spaceComm : HGC.fullComm); for(int idf = 0 ; idf < f.Field_length(); idf++) for(int it = 0 ; it < ft.DimT(); it++) h_ft[it*f.Field_length()*Nmom + idf*Nmom + imom] += h_res[idf*ft.DimT()+it]; @@ -105,9 +105,9 @@ static void FT_gemv(PLEGMA_FT &ft, const PLEGMA_Field &f, std::vec template __global__ void fourier_transform_3D_kernel(Float* block, pFloat2 in, tex_mom_list texMomList,int it, int sign){ int vid = blockIdx.x*blockDim.x + threadIdx.x; - int sid = vid + it*DGC_localVolume3D; + int sid = vid + it*DGC->localVolume3D; Float2 *block2 = (Float2 *)block; - if(vid >= DGC_localVolume3D) return; + if(vid >= DGC->localVolume3D) return; Float2 tmp; extern __shared__ int ext_shared_cache[]; Float2 *shared_cache = (Float2 *) ext_shared_cache; @@ -124,7 +124,7 @@ __global__ void fourier_transform_3D_kernel(Float* block, pFloat2 in, tex template static void fourier_transform_3D_k(PLEGMA_FT &ft, const PLEGMA_Field &field, tex_mom_list &texMomList, int it, int sign){ - int SpVol = HGC_localVolume/HGC_localL[3]; + int SpVol = HGC.localVolume/HGC.localL[3]; Float *d_partial_block = NULL; int site_size = field.Field_length(); int shared_size = 2*sizeof(Float); @@ -150,7 +150,7 @@ static void fourier_transform_3D_k(PLEGMA_FT &ft, const PLEGMA_FieldtexProp1, int grid3D = gridDim.x/time_step; int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x; int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[16]; #pragma unroll @@ -18,7 +18,7 @@ __global__ void contract_TMDWF_mesons_trick_zfac_device(propTextexProp1, accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); Float2 staple[N_COLS][N_COLS]; @@ -52,9 +52,9 @@ __global__ void contract_TMDWF_mesons_trick_zfac_device(propTextexProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, 16, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < 16; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*16 + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*16 + ip] = accum[ip]; } } } @@ -68,8 +68,8 @@ __global__ void contract_TMDWF_mesons_zfac_device(propTextexProp1, int grid3D = gridDim.x/time_step; int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x; int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[16]; #pragma unroll @@ -77,7 +77,7 @@ __global__ void contract_TMDWF_mesons_zfac_device(propTextexProp1, accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -119,9 +119,9 @@ __global__ void contract_TMDWF_mesons_zfac_device(propTextexProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, 16, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < 16; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*16 + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*16 + ip] = accum[ip]; } } } @@ -141,7 +141,7 @@ void contract_TMDWF_mesons_trick_zfac_host( ProfileStruct &ps,PLEGMA_Propagator< auto moms = corr.getTexMomList(); int site_size = corr.getSiteSize()/extra; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -215,7 +215,7 @@ void contract_TMDWF_mesons_zfac_host( ProfileStruct &ps,PLEGMA_Propagator 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -294,18 +294,18 @@ static void contract_TMDWF_mesons_trick_zfac(PLEGMA_Propagator& prop1,PL else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_TMDWF_mesons_trick_zfac", contract_TMDWF_mesons_trick_zfac_host, ps, prop1, corr, staple, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } @@ -329,18 +329,18 @@ static void contract_TMDWF_mesons_zfac(PLEGMA_Propagator& prop1,PLEGMA_P else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_TMDWF_mesons_zfac", contract_TMDWF_mesons_zfac_host, ps, prop1, prop2, corr, staple, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } diff --git a/lib/kernels/PLEGMA_Random.cuh b/lib/kernels/PLEGMA_Random.cuh index a7080ad5..3c7345c3 100644 --- a/lib/kernels/PLEGMA_Random.cuh +++ b/lib/kernels/PLEGMA_Random.cuh @@ -32,7 +32,7 @@ __global__ void random_init_kernel(RNGState *state, int seed, int offset){ void launch_random_init( RNGState *state, int seed, int offset, int rng_size){ dim3 blockDim( THREADS_PER_BLOCK, 1, 1); - //PLEGMA_printf("Number of volume[3]: %d\n", HGC_localVolume * field_deg_free); + //PLEGMA_printf("Number of volume[3]: %d\n", HGC.localVolume * field_deg_free); dim3 gridDim( (rng_size + blockDim.x -1)/blockDim.x , 1 , 1); random_init_kernel<<>>(state, seed, offset ); //cudaDeviceSynchronize(); diff --git a/lib/kernels/PLEGMA_TMDWF.cuh b/lib/kernels/PLEGMA_TMDWF.cuh index bc4e253a..4a422719 100644 --- a/lib/kernels/PLEGMA_TMDWF.cuh +++ b/lib/kernels/PLEGMA_TMDWF.cuh @@ -21,15 +21,15 @@ __global__ void contract_TMDWF_mesons_device( propTex texProp1, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[2*N_TMDWF_MESONS]; for(int i = 0 ; i < 2*N_TMDWF_MESONS ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -65,9 +65,9 @@ __global__ void contract_TMDWF_mesons_device( propTex texProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, 2*N_TMDWF_MESONS, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < 2*N_TMDWF_MESONS ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*2*N_TMDWF_MESONS + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*2*N_TMDWF_MESONS + ip] = accum[ip]; } } } @@ -88,7 +88,7 @@ void contract_TMDWF_mesons_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = 2*N_TMDWF_MESONS; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -156,18 +156,18 @@ static void contract_TMDWF_mesons(PLEGMA_Propagator& prop1, PLEGMA_Propa else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_TMDWF_mesons", contract_TMDWF_mesons_host, ps, prop1, prop2, corr, staple, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } diff --git a/lib/kernels/PLEGMA_WFlow.cuh b/lib/kernels/PLEGMA_WFlow.cuh index 8dfdf333..d4dda726 100644 --- a/lib/kernels/PLEGMA_WFlow.cuh +++ b/lib/kernels/PLEGMA_WFlow.cuh @@ -205,6 +205,6 @@ static FloatG calcPlaqStaplesDef(gauge2 gaugep){ plaquette += h_partial_plaq[i]; free(h_partial_plaq); - MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC_fullComm); - return globalPlaquette/(HGC_totalVolume*N_COLS*24); + MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC.fullComm); + return globalPlaquette/(HGC.totalVolume*N_COLS*24); } diff --git a/lib/kernels/PLEGMA_baryons.cuh b/lib/kernels/PLEGMA_baryons.cuh index 445dcc18..42f823db 100644 --- a/lib/kernels/PLEGMA_baryons.cuh +++ b/lib/kernels/PLEGMA_baryons.cuh @@ -40,15 +40,15 @@ __global__ void contract_baryons_device(propTex texProp1, propTex=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[2*N_SPINS*N_SPINS]; for(int i = 0 ; i < 2*N_SPINS*N_SPINS ; i++){ accum[i]=0; } - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume switch(ip){ case NtoN: contract_NtoN_kernel(texProp1, texProp2, accum, vid); @@ -91,9 +91,9 @@ __global__ void contract_baryons_device(propTex texProp1, propTexlocalVolume3D) for(int i = 0 ; i < 2*N_SPINS*N_SPINS ; i++){ - block2[(tid*DGC_localVolume3D + sid3D)*2*N_SPINS*N_SPINS + i] = accum[i]; + block2[(tid*DGC->localVolume3D + sid3D)*2*N_SPINS*N_SPINS + i] = accum[i]; } } } @@ -107,15 +107,15 @@ __global__ void contract_baryons_wall_device(propTex texProp1, propTex=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[2*N_SPINS*N_SPINS]; for(int i = 0 ; i < 2*N_SPINS*N_SPINS ; i++){ accum[i]=0; } - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume switch(ip){ case NtoN: contract_NtoN_wall_kernel(texProp1, texProp2, texProp3, texProp4, accum, vid); @@ -158,9 +158,9 @@ __global__ void contract_baryons_wall_device(propTex texProp1, propTexlocalVolume3D) for(int i = 0 ; i < 2*N_SPINS*N_SPINS ; i++){ - block2[(tid*DGC_localVolume3D + sid3D)*2*N_SPINS*N_SPINS + i] = accum[i]; + block2[(tid*DGC->localVolume3D + sid3D)*2*N_SPINS*N_SPINS + i] = accum[i]; } } } @@ -181,7 +181,7 @@ static void contract_baryons_host( ProfileStruct &ps, int4 source = corr.getSource(); auto mom_list = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -252,7 +252,7 @@ static void contract_baryons_wall_host( ProfileStruct &ps, int4 source = corr.getSource(); auto mom_list = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -326,11 +326,11 @@ static void contract_baryons(PLEGMA_Propagator& prop1, PLEGMA_Propagator else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; for(int ip=0; ip& prop1, PLEGMA_Propagator if(runFT) { FloatC *corr_ip = corr.H_elem() + ip*corr.getTotalSize()/N_BARYONS*2; MPI_Allreduce(result, corr_ip, corr.getTotalSize()/N_BARYONS*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); } else { result += corr.getTotalSize()/N_BARYONS; } @@ -365,11 +365,11 @@ static void contract_baryons_wall(PLEGMA_Propagator& prop1, PLEGMA_Propa else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; for(int ip=0; ip& prop1, PLEGMA_Propa if(runFT) { FloatC *corr_ip = corr.H_elem() + ip*corr.getTotalSize()/N_BARYONS*2; MPI_Allreduce(result, corr_ip, corr.getTotalSize()/N_BARYONS*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); } else { result += corr.getTotalSize()/N_BARYONS; } diff --git a/lib/kernels/PLEGMA_baryons_udsc.cu b/lib/kernels/PLEGMA_baryons_udsc.cu index f0876fcb..5a3dfc2b 100644 --- a/lib/kernels/PLEGMA_baryons_udsc.cu +++ b/lib/kernels/PLEGMA_baryons_udsc.cu @@ -10,10 +10,10 @@ __global__ void create_prop_product(genericTex *propProd, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -62,7 +62,7 @@ __global__ void contract_prop_prod(genericTex *texPropProd, Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume for(int i = 0; i < size; i++) { int mu = 0; #pragma unroll @@ -78,7 +78,7 @@ __global__ void contract_prop_prod(genericTex *texPropProd, Float2localVolume3D + sid3D] = accum; } } @@ -92,11 +92,11 @@ __global__ void contract_props(propTex texProp1, propTex texProp int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -128,8 +128,8 @@ __global__ void contract_props(propTex texProp1, propTex texProp int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block, &accum, shared_cache, 1, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) - block[tid*DGC_localVolume3D + sid3D] = accum; + if (sid3D < DGC->localVolume3D) + block[tid*DGC->localVolume3D + sid3D] = accum; } } @@ -149,7 +149,7 @@ void contract_baryons_udsc_host(ProfileStruct &ps, size_t volume = volume3D*time_step; auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, ps.tp.aux.x = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, ps.tp.aux.x, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -287,21 +287,21 @@ void contract_baryons_udsc(PLEGMA_Propagator& propUP, PLEGMA_Propagator< PLEGMA_error("Unknown propagator %c", BP_prop_prods[i][j]); } - ProfileStruct ps(HGC_localVolume3D, sizeof(Float2)); + ProfileStruct ps(HGC.localVolume3D, sizeof(Float2)); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; ps.aux_range.x = 2; - if(HGC_verbosity>2) PLEGMA_printf("Running for %s\n", BP_prop_prods[i].c_str()); + if(HGC.verbosity>2) PLEGMA_printf("Running for %s\n", BP_prop_prods[i].c_str()); tuneAndRun(ps, "contract_baryons_size"+std::to_string(BP_prop_prods_count[i].size()), contract_baryons_udsc_host, ps, props, corr, result, i); if(runFT) { FloatC *corr_ip = corr.H_elem() + shift*corr.getVolSize()*2; MPI_Allreduce(result, corr_ip, BP_prop_prods_count[i].size()*corr.getVolSize()*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, BP_prop_prods_count[i].size()*corr.getVolSize()*sizeof(Float2)); } shift+=BP_prop_prods_count[i].size(); diff --git a/lib/kernels/PLEGMA_bcud_tetraquarks.cu b/lib/kernels/PLEGMA_bcud_tetraquarks.cu index 55be1ef0..9f023144 100644 --- a/lib/kernels/PLEGMA_bcud_tetraquarks.cu +++ b/lib/kernels/PLEGMA_bcud_tetraquarks.cu @@ -12,11 +12,11 @@ __global__ void contract_props_bcud(propTex texProp1, propTex te int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -55,8 +55,8 @@ __global__ void contract_props_bcud(propTex texProp1, propTex te int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block, &accum, shared_cache, 1, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) - block[tid*DGC_localVolume3D + sid3D] = accum; + if (sid3D < DGC->localVolume3D) + block[tid*DGC->localVolume3D + sid3D] = accum; } } @@ -75,7 +75,7 @@ void contract_tetraquarks_bcud_host(ProfileStruct &ps, size_t volume = volume3D*time_step; auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, ps.tp.aux.x = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, ps.tp.aux.x, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -196,21 +196,21 @@ void contract_tetraquarks_bcud(PLEGMA_Propagator& propLT, PLEGMA_Propaga PLEGMA_error("Unknown propagator %c", TETRA_bcud_prop_prods[i][j]); } - ProfileStruct ps(HGC_localVolume3D, sizeof(Float2)); + ProfileStruct ps(HGC.localVolume3D, sizeof(Float2)); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; ps.aux_range.x = 1; - if(HGC_verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_bcud_prop_prods[i].c_str()); + if(HGC.verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_bcud_prop_prods[i].c_str()); tuneAndRun(ps, "contract_tetraquarks_bcud_size"+std::to_string(TETRA_bcud_prop_prods_count[i].size()), contract_tetraquarks_bcud_host, ps, props, corr, result, i); if(runFT) { FloatC *corr_ip = corr.H_elem() + shift*corr.getVolSize()*2; MPI_Allreduce(result, corr_ip, TETRA_bcud_prop_prods_count[i].size()*corr.getVolSize()*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, TETRA_bcud_prop_prods_count[i].size()*corr.getVolSize()*sizeof(Float2)); } shift+=TETRA_bcud_prop_prods_count[i].size(); diff --git a/lib/kernels/PLEGMA_bcud_tetraquarks_stochastic.cu b/lib/kernels/PLEGMA_bcud_tetraquarks_stochastic.cu index 5dced21d..f92b251b 100644 --- a/lib/kernels/PLEGMA_bcud_tetraquarks_stochastic.cu +++ b/lib/kernels/PLEGMA_bcud_tetraquarks_stochastic.cu @@ -13,11 +13,11 @@ __global__ void contract_props_bcud_stochastic(propTex texProp1, propTex int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -85,8 +85,8 @@ __global__ void contract_props_bcud_stochastic(propTex texProp1, propTex int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block, &accum, shared_cache, 1, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) - block[tid*DGC_localVolume3D + sid3D] = accum; + if (sid3D < DGC->localVolume3D) + block[tid*DGC->localVolume3D + sid3D] = accum; } } @@ -105,7 +105,7 @@ void contract_tetraquarks_bcud_stochastic_host(ProfileStruct &ps, size_t volume = volume3D*time_step; auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, ps.tp.aux.x = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, ps.tp.aux.x, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -234,21 +234,21 @@ void contract_tetraquarks_bcud_stochastic( PLEGMA_Propagator&propLT1, P PLEGMA_error("Unknown propagator %c", TETRA_bcud_stoch_prop_prods[i][j]);} } - ProfileStruct ps(HGC_localVolume3D, sizeof(Float2)); + ProfileStruct ps(HGC.localVolume3D, sizeof(Float2)); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; ps.aux_range.x = 1; - if(HGC_verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_bcud_stoch_prop_prods[i].c_str()); + if(HGC.verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_bcud_stoch_prop_prods[i].c_str()); tuneAndRun(ps, "contract_tetraquarks_bcud_stochastic_size"+std::to_string(TETRA_bcud_stoch_prop_prods_count[i].size()), contract_tetraquarks_bcud_stochastic_host, ps, props, corr, result, i); if(runFT) { FloatC *corr_ip = corr.H_elem() + shift*corr.getVolSize()*2; MPI_Allreduce(result, corr_ip, TETRA_bcud_stoch_prop_prods_count[i].size()*corr.getVolSize()*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, TETRA_bcud_stoch_prop_prods_count[i].size()*corr.getVolSize()*sizeof(Float2)); } shift+=TETRA_bcud_stoch_prop_prods_count[i].size(); diff --git a/lib/kernels/PLEGMA_field_utils.cuh b/lib/kernels/PLEGMA_field_utils.cuh index 001a84a5..a667ed9e 100644 --- a/lib/kernels/PLEGMA_field_utils.cuh +++ b/lib/kernels/PLEGMA_field_utils.cuh @@ -45,10 +45,10 @@ static __global__ void copy_side_to_ghost_kernel(pFloat2 F, short di #pragma unroll for(int i = 0 ; ilocalL[dir]-1):0; } else { - id[i] = tmp_sid % DGC_localL[i]; - tmp_sid /= DGC_localL[i]; + id[i] = tmp_sid % DGC->localL[i]; + tmp_sid /= DGC->localL[i]; } } size_t vid = LEXIC_ID(id); @@ -61,7 +61,7 @@ static __global__ void copy_side_to_ghost_kernel(pFloat2 F, short di template static void copy_side_to_ghost(pFloat2 F, short dir, short sign){ - if( HGC_dimBreak[dir] ){ + if( HGC.dimBreak[dir] ){ ProfileStruct ps(F.sideGhostL(dir)); tuneAndRun(ps, "copy_side_to_ghost_kernel_size_"+std::to_string(F.site_size), copy_side_to_ghost_kernel, F, dir, sign); } @@ -74,12 +74,12 @@ static __global__ void copy_corner_to_ghost_kernel(pFloat2 F, short size_t id[4], tmp_sid=sid; for(int i = 0 ; ilocalL[dir1]-1):0; } else if(i==dir2) { - id[i] = sign2==DIR_MINUS ? (DGC_localL[dir2]-1):0; + id[i] = sign2==DIR_MINUS ? (DGC->localL[dir2]-1):0; } else { - id[i] = tmp_sid % DGC_localL[i]; - tmp_sid /= DGC_localL[i]; + id[i] = tmp_sid % DGC->localL[i]; + tmp_sid /= DGC->localL[i]; } } size_t vid = LEXIC_ID(id); @@ -92,7 +92,7 @@ static __global__ void copy_corner_to_ghost_kernel(pFloat2 F, short template static void copy_corner_to_ghost(pFloat2 F, short dir1, short dir2, short sign1, short sign2){ - if( (dir1 != dir2 ) && HGC_dimBreak[dir1] && HGC_dimBreak[dir2] ){ + if( (dir1 != dir2 ) && HGC.dimBreak[dir1] && HGC.dimBreak[dir2] ){ ProfileStruct ps(F.cornerGhostL(dir1, dir2)); tuneAndRun(ps, "copy_corner_to_ghost_kernel_size_"+std::to_string(F.site_size), copy_corner_to_ghost_kernel, F, dir1, dir2, sign1, sign2); } @@ -105,14 +105,14 @@ static __global__ void copy_vertex_to_ghost_kernel(pFloat2 F, short size_t id[4], tmp_sid=sid; for(int i = 0 ; ilocalL[dir1]-1):0; } else if(i==dir2) { - id[i] = sign2==DIR_MINUS ? (DGC_localL[dir2]-1):0; + id[i] = sign2==DIR_MINUS ? (DGC->localL[dir2]-1):0; } else if(i==dir3) { - id[i] = sign3==DIR_MINUS ? (DGC_localL[dir3]-1):0; + id[i] = sign3==DIR_MINUS ? (DGC->localL[dir3]-1):0; } else { - id[i] = tmp_sid % DGC_localL[i]; - tmp_sid /= DGC_localL[i]; + id[i] = tmp_sid % DGC->localL[i]; + tmp_sid /= DGC->localL[i]; } } size_t vid = LEXIC_ID(id); @@ -125,7 +125,7 @@ static __global__ void copy_vertex_to_ghost_kernel(pFloat2 F, short template static void copy_vertex_to_ghost(pFloat2 F, short dir1, short dir2, short dir3, short sign1, short sign2, short sign3){ - if( (dir1 != dir2 && dir1 != dir3 && dir3 != dir2 ) && HGC_dimBreak[dir1] && HGC_dimBreak[dir2] && HGC_dimBreak[dir3] ){ + if( (dir1 != dir2 && dir1 != dir3 && dir3 != dir2 ) && HGC.dimBreak[dir1] && HGC.dimBreak[dir2] && HGC.dimBreak[dir3] ){ ProfileStruct ps(F.vertexGhostL(dir1, dir2, dir3)); tuneAndRun(ps, "copy_vertex_to_ghost_kernel_size_"+std::to_string(F.site_size), copy_vertex_to_ghost_kernel, F, dir1, dir2, dir3, sign1, sign2, sign3); } @@ -208,7 +208,7 @@ __global__ void genStochasticUniform_kernel(RNGState *state, int length_field, F int sid = blockIdx.x*blockDim.x + threadIdx.x; if( n < 2) return; - int V = is4D?DGC_localVolume:DGC_localVolume3D; + int V = is4D?DGC->localVolume:DGC->localVolume3D; for( int i = 0; i < length_field; ++i){ Float tmp = PLEGMA_Random(state[sid]); @@ -293,7 +293,7 @@ struct HadCol{ template static void apply_hprob_coloring_4D(Float* d_elems, int *d_colors, int ih){ // make sure before that is not a 3D field - int V = HGC_localVolume; + int V = HGC.localVolume; thrust::device_ptr th_c(d_colors); thrust::device_ptr > th_e((Float2*)d_elems); typedef thrust::tuple, thrust::device_ptr > > tplDIntDFl2; @@ -338,7 +338,7 @@ static void traceMulFmunuSu3FmunuSu3_k(PLEGMA_Field &F, PLEGMA_Fmunu static void __global__ trPmunu_kernel(FloatA *out, gauge2 u, int mu, int nu){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume) return; + if (sid >= DGC->localVolume) return; Float2 *out2 = (Float2 *) out; Float2 U1[N_COLS][N_COLS], U2[N_COLS][N_COLS], U3[N_COLS][N_COLS]; /** @@ -357,7 +357,7 @@ static void __global__ trPmunu_kernel(FloatA *out, gauge2 u, int mu, int template static void __global__ SU3Trace_kernel(FloatA *out, su3_2 su3){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume) return; + if (sid >= DGC->localVolume) return; Float2 *out2 = (Float2 *) out; Float2 SU3[N_COLS][N_COLS]; su3.get(SU3,sid); diff --git a/lib/kernels/PLEGMA_gFixing.cuh b/lib/kernels/PLEGMA_gFixing.cuh index 39fb37f1..8f874fa1 100644 --- a/lib/kernels/PLEGMA_gFixing.cuh +++ b/lib/kernels/PLEGMA_gFixing.cuh @@ -124,7 +124,7 @@ static void gFixingLandau_k(PLEGMA_Gauge &u_gFixed, PLEGMA_Gauge & tr+=tmp.sumRtraceU(); } prec = abs(trold-tr)/abs(tr); - if(HGC_verbosity>1) PLEGMA_printf("Landau Gauge Fixing iter=%d, prec=%+e and trace=%+e\n",iter,prec,tr); + if(HGC.verbosity>1) PLEGMA_printf("Landau Gauge Fixing iter=%d, prec=%+e and trace=%+e\n",iter,prec,tr); trold=tr; iter++; diff --git a/lib/kernels/PLEGMA_gammas_scatt.cuh b/lib/kernels/PLEGMA_gammas_scatt.cuh index 8da53e3d..20b2b502 100644 --- a/lib/kernels/PLEGMA_gammas_scatt.cuh +++ b/lib/kernels/PLEGMA_gammas_scatt.cuh @@ -21,7 +21,7 @@ namespace plegma{ int sid = blockIdx.x*blockDim.x + threadIdx.x; Float2 Sin[N_SPINS][N_COLS]; Float2 Sout[N_SPINS][N_COLS]; - if (sid >= DGC_localVolume) return; + if (sid >= DGC->localVolume) return; vec.get(Sin,sid); gamma_scattV(Sout,Sin,r); vec.set(Sout,sid); @@ -30,7 +30,7 @@ namespace plegma{ template static void apply_gamma_scatt_vector(LEFTRIGHT LR, vector2 inOut, GAMMAS_SCATT r){ dim3 blockDim( THREADS_PER_BLOCK , 1, 1); - dim3 gridDim( (HGC_localVolume + blockDim.x -1)/blockDim.x , 1 , 1); + dim3 gridDim( (HGC.localVolume + blockDim.x -1)/blockDim.x , 1 , 1); switch(LR){ case(LEFT): apply_gamma_scatt_vector_kernel<<>>(inOut, r); diff --git a/lib/kernels/PLEGMA_gaussian_smearing.cuh b/lib/kernels/PLEGMA_gaussian_smearing.cuh index d203758d..ca7d8dbb 100644 --- a/lib/kernels/PLEGMA_gaussian_smearing.cuh +++ b/lib/kernels/PLEGMA_gaussian_smearing.cuh @@ -58,10 +58,10 @@ __global__ void gaussian_smearing_only_ghost_kernel(vectorTexout, #pragma unroll for(int i = 0 ; ilocalL[dir]-1):0; } else { - id[i] = sid % DGC_localL[i]; - sid /= DGC_localL[i]; + id[i] = sid % DGC->localL[i]; + sid /= DGC->localL[i]; } } sid = LEXIC_ID(id); @@ -123,7 +123,7 @@ template static void gaussian_smearing_only_ghost(vectorTex& out, vectorTex& vecInTex, gaugeTex& gaugeTex, FloatOut alpha){ for(int dir = 0; dir < N_DIMS-1; dir++) { - if(HGC_dimBreak[dir]) { + if(HGC.dimBreak[dir]) { ProfileStruct ps(out.sideGhostL(dir)*2); tuneAndRun(ps, "gaussian_smearing_only_ghost_kernel", gaussian_smearing_only_ghost_kernel, out, vecInTex, gaugeTex, alpha, dir); diff --git a/lib/kernels/PLEGMA_heavy_light_tetraquarks.cu b/lib/kernels/PLEGMA_heavy_light_tetraquarks.cu index 1def2abe..d3734512 100644 --- a/lib/kernels/PLEGMA_heavy_light_tetraquarks.cu +++ b/lib/kernels/PLEGMA_heavy_light_tetraquarks.cu @@ -13,11 +13,11 @@ __global__ void contract_props(propTex texProp1, propTex texProp int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -56,8 +56,8 @@ __global__ void contract_props(propTex texProp1, propTex texProp int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block, &accum, shared_cache, 1, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) - block[tid*DGC_localVolume3D + sid3D] = accum; + if (sid3D < DGC->localVolume3D) + block[tid*DGC->localVolume3D + sid3D] = accum; } } @@ -76,7 +76,7 @@ void contract_tetraquarks_host(ProfileStruct &ps, size_t volume = volume3D*time_step; auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, ps.tp.aux.x = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, ps.tp.aux.x, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -197,21 +197,21 @@ void contract_tetraquarks(PLEGMA_Propagator& propLT, PLEGMA_Propagator)); + ProfileStruct ps(HGC.localVolume3D, sizeof(Float2)); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; ps.aux_range.x = 1; - if(HGC_verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_prop_prods[i].c_str()); + if(HGC.verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_prop_prods[i].c_str()); tuneAndRun(ps, "contract_tetraquarks_size"+std::to_string(TETRA_prop_prods_count[i].size()), contract_tetraquarks_host, ps, props, corr, result, i); if(runFT) { FloatC *corr_ip = corr.H_elem() + shift*corr.getVolSize()*2; MPI_Allreduce(result, corr_ip, TETRA_prop_prods_count[i].size()*corr.getVolSize()*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, TETRA_prop_prods_count[i].size()*corr.getVolSize()*sizeof(Float2)); } shift+=TETRA_prop_prods_count[i].size(); diff --git a/lib/kernels/PLEGMA_heavy_light_tetraquarks_open_contractions.cu b/lib/kernels/PLEGMA_heavy_light_tetraquarks_open_contractions.cu index 25618051..eb266e18 100644 --- a/lib/kernels/PLEGMA_heavy_light_tetraquarks_open_contractions.cu +++ b/lib/kernels/PLEGMA_heavy_light_tetraquarks_open_contractions.cu @@ -20,8 +20,8 @@ __global__ void tetraquark_open_index_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; const Float2 (*g)[4]; const short int (*gIn)[4][2]; @@ -35,7 +35,7 @@ __global__ void tetraquark_open_index_device(Float2* block2, accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; prop1Tex.get(prop1,vid); @@ -80,9 +80,9 @@ __global__ void tetraquark_open_index_device(Float2* block2, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size +iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size +iop] = accum[iop]; } } @@ -108,7 +108,7 @@ static void tetraquark_open_index_host(ProfileStruct &ps, Float2 *result listGammas.array= (GAMMAS*) device_malloc(gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -175,11 +175,11 @@ if(gammas.size() != 1) if(corr.getSiteSize() != site_size) PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -193,7 +193,7 @@ if(gammas.size() != 1) if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } // #else diff --git a/lib/kernels/PLEGMA_heavy_light_tetraquarks_stochastic.cu b/lib/kernels/PLEGMA_heavy_light_tetraquarks_stochastic.cu index e8166293..a183b399 100644 --- a/lib/kernels/PLEGMA_heavy_light_tetraquarks_stochastic.cu +++ b/lib/kernels/PLEGMA_heavy_light_tetraquarks_stochastic.cu @@ -13,11 +13,11 @@ __global__ void contract_props_stochastic(propTex texProp1, propTex=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum=0; - if (sid3D < DGC_localVolume3D){ // I work only on the spatial volume + if (sid3D < DGC->localVolume3D){ // I work only on the spatial volume Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -85,8 +85,8 @@ __global__ void contract_props_stochastic(propTex texProp1, propTexlocalVolume3D) + block[tid*DGC->localVolume3D + sid3D] = accum; } } @@ -105,7 +105,7 @@ void contract_tetraquarks_stochastic_host(ProfileStruct &ps, size_t volume = volume3D*time_step; auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, ps.tp.aux.x = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, ps.tp.aux.x, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -232,21 +232,21 @@ void contract_tetraquarks_stochastic(PLEGMA_Propagator&propLT1, PLEGMA_P PLEGMA_error("Unknown propagator %c", TETRA_stoch_prop_prods[i][j]);} } - ProfileStruct ps(HGC_localVolume3D, sizeof(Float2)); + ProfileStruct ps(HGC.localVolume3D, sizeof(Float2)); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; ps.aux_range.x = 1; - if(HGC_verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_stoch_prop_prods[i].c_str()); + if(HGC.verbosity>2) PLEGMA_printf("Running for %s\n", TETRA_stoch_prop_prods[i].c_str()); tuneAndRun(ps, "contract_tetraquarks_stochastic_size"+std::to_string(TETRA_stoch_prop_prods_count[i].size()), contract_tetraquarks_stochastic_host, ps, props, corr, result, i); if(runFT) { FloatC *corr_ip = corr.H_elem() + shift*corr.getVolSize()*2; MPI_Allreduce(result, corr_ip, TETRA_stoch_prop_prods_count[i].size()*corr.getVolSize()*2, MPI_Type(corr_ip), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, TETRA_stoch_prop_prods_count[i].size()*corr.getVolSize()*sizeof(Float2)); } shift+=TETRA_stoch_prop_prods_count[i].size(); diff --git a/lib/kernels/PLEGMA_kernel_getSet.cuh b/lib/kernels/PLEGMA_kernel_getSet.cuh index b18058ea..0c76562f 100644 --- a/lib/kernels/PLEGMA_kernel_getSet.cuh +++ b/lib/kernels/PLEGMA_kernel_getSet.cuh @@ -61,8 +61,8 @@ #define LEXIC_3D4D_PLUS(i,id,is4D) (is4D ? LEXIC_PLUS(i,id) : LEXIC_3D_PLUS(i,id)) #define LEXIC_3D4D_MINUS(i,id,is4D) (is4D ? LEXIC_MINUS(i,id) : LEXIC_3D_MINUS(i,id)) -#define IS_MINUS_GHOST(i,id) (DGC_dimBreak[i] == true && id[i] == 0) -#define IS_PLUS_GHOST(i,id) (DGC_dimBreak[i] == true && id[i] == (DGC->localL[i]-1)) +#define IS_MINUS_GHOST(i,id) (DGC->dimBreak[i] == true && id[i] == 0) +#define IS_PLUS_GHOST(i,id) (DGC->dimBreak[i] == true && id[i] == (DGC->localL[i]-1)) namespace plegma { @@ -84,9 +84,9 @@ namespace plegma { inline __host__ __device__ size_t volume() const { #if defined ( __CUDA_ARCH__ ) || ( __HIP__ ) - return is4D ? DGC_localVolume : DGC_localVolume3D; + return is4D ? DGC->localVolume : DGC->localVolume3D; #else - return is4D ? HGC_localVolume : HGC_localVolume3D; + return is4D ? HGC.localVolume : HGC.localVolume3D; #endif } @@ -94,15 +94,15 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->sideGhostVolume : DGC->sideGhostVolume3D; #else - return is4D ? HGC_sideGhostVolume : HGC_sideGhostVolume3D; + return is4D ? HGC.sideGhostVolume : HGC.sideGhostVolume3D; #endif } inline __host__ __device__ size_t sideGhostL(const short& dir) const { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) - return is4D ? DGC_surface3D[dir] : (DGC_surface3D[dir]/DGC->localL[DIM_T]); + return is4D ? DGC->surface3D[dir] : (DGC->surface3D[dir]/DGC->localL[DIM_T]); #else - return is4D ? HGC_surface3D[dir] : (HGC_surface3D[dir]/HGC_localL[DIM_T]); + return is4D ? HGC.surface3D[dir] : (HGC.surface3D[dir]/HGC.localL[DIM_T]); #endif } @@ -110,7 +110,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->sideGhost[dir][sign] : (DGC->sideGhost[dir][sign]/DGC->localL[DIM_T]); #else - return is4D ? HGC_sideGhost[dir][sign] : (HGC_sideGhost[dir][sign]/HGC_localL[DIM_T]); + return is4D ? HGC.sideGhost[dir][sign] : (HGC.sideGhost[dir][sign]/HGC.localL[DIM_T]); #endif } @@ -118,7 +118,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->cornerGhostVolume : DGC->cornerGhostVolume3D; #else - return is4D ? HGC_cornerGhostVolume : HGC_cornerGhostVolume3D; + return is4D ? HGC.cornerGhostVolume : HGC.cornerGhostVolume3D; #endif } @@ -126,7 +126,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->surface2D[OFF2(dir1,dir2)] : (DGC->surface2D[OFF2(dir1,dir2)]/DGC->localL[DIM_T]); #else - return is4D ? HGC_surface2D[OFF2(dir1,dir2)] : (HGC_surface2D[OFF2(dir1,dir2)]/HGC_localL[DIM_T]); + return is4D ? HGC.surface2D[OFF2(dir1,dir2)] : (HGC.surface2D[OFF2(dir1,dir2)]/HGC.localL[DIM_T]); #endif } @@ -134,7 +134,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->surface1D[OFF3(dir1,dir2,dir3)] : (DGC->surface1D[OFF3(dir1,dir2,dir3)]/DGC->localL[DIM_T]); #else - return is4D ? HGC_surface1D[OFF3(dir1,dir2,dir3)] : (HGC_surface1D[OFF3(dir1,dir2,dir3)]/HGC_localL[DIM_T]); + return is4D ? HGC.surface1D[OFF3(dir1,dir2,dir3)] : (HGC.surface1D[OFF3(dir1,dir2,dir3)]/HGC.localL[DIM_T]); #endif } @@ -143,7 +143,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (DGC->cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/DGC->localL[DIM_T]); #else - return is4D ? HGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (HGC_cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/HGC_localL[DIM_T]); + return is4D ? HGC.cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)] : (HGC.cornerGhost[OFF2SIGN(dir1,dir2,sign1,sign2)]/HGC.localL[DIM_T]); #endif } @@ -152,7 +152,7 @@ namespace plegma { #if defined ( __CUDA_ARCH__) || ( __HIP__ ) return is4D ? DGC->vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (DGC->vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/DGC->localL[DIM_T]); #else - return is4D ? HGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (HGC_vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/HGC_localL[DIM_T]); + return is4D ? HGC.vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)] : (HGC.vertexGhost[OFF3SIGN(dir1,dir2,dir3,sign1,sign2,sign3)]/HGC.localL[DIM_T]); #endif } diff --git a/lib/kernels/PLEGMA_kernel_tuner.cuh b/lib/kernels/PLEGMA_kernel_tuner.cuh index efa0351a..c6c03ba8 100644 --- a/lib/kernels/PLEGMA_kernel_tuner.cuh +++ b/lib/kernels/PLEGMA_kernel_tuner.cuh @@ -199,10 +199,11 @@ public: // ctor PLEGMA_kernel_tuner( ProfileStruct &ps, std::string kname, void (*kernel)(types...), types... kArgs ) : kernel(kernel), args(std::tuple(kArgs...)), ps(ps), onlyTuning(false) { - sprintf(volString, "%lldx%lldx%lldx%lld", HGC_localL[0], HGC_localL[1], HGC_localL[2], HGC_localL[3]); + sprintf(volString, "%lldx%lldx%lldx%lld", HGC.localL[0], HGC.localL[1], HGC.localL[2], HGC.localL[3]); sprintf(aux, "volume=%lld,Ndims=%d,Ncols=%d,maxvolume=%d,aux_range=(%d,%d,%d,%d)", ps.volume, N_DIMS, N_COLS, ps.max_volume, ps.aux_range.x, ps.aux_range.y, ps.aux_range.z, ps.aux_range.w); kernelName = kname + (std::string) typeid(*kernel).name(); // with cupti no longer necessary setPolicyTuning(ps.tune_globally); + qudaMemcpy(&DGC,DGC_ptr, sizeof(void*), qudaMemcpyHostToDevice); } ~PLEGMA_kernel_tuner(){ @@ -251,7 +252,7 @@ void PLEGMA_kernel_tuner::apply(const qudaStream_t &stream){ #else // performing tuning if we need to tune if( !ps.tuned && !activeTuning() && ps.tune_globally ) comm_barrier(); //syncronizing - if( !ps.tuned ) ps.tp = tuneLaunch(*this, getTuning(), (QudaVerbosity) HGC_verbosity); + if( !ps.tuned ) ps.tp = tuneLaunch(*this, getTuning(), (QudaVerbosity) HGC.verbosity); if( !ps.tuned ) qudaGetLastError(); // ensuring that the error state has been clean if( !activeTuning() ) ps.tuned = true; if( onlyTuning && !activeTuning() ) return; @@ -283,7 +284,7 @@ void PLEGMA_kernel_tuner::run(){ if(!ps.tuned) tune(); launchKernel(ps.tp.grid,ps.tp.block,ps.tp.shared_bytes,0); #else - if(!ps.tuned) ps.tp = tuneLaunch(*this, QUDA_TUNE_NO, (QudaVerbosity) HGC_verbosity); + if(!ps.tuned) ps.tp = tuneLaunch(*this, QUDA_TUNE_NO, (QudaVerbosity) HGC.verbosity); launchKernel(ps.tp,device::get_stream(0)); #endif checkQudaError(); diff --git a/lib/kernels/PLEGMA_kernel_utils.cuh b/lib/kernels/PLEGMA_kernel_utils.cuh index 67f7d859..896fa0b9 100644 --- a/lib/kernels/PLEGMA_kernel_utils.cuh +++ b/lib/kernels/PLEGMA_kernel_utils.cuh @@ -828,14 +828,14 @@ namespace plegma { int id[3] = GET_ID_ZYX(sid3D); #pragma unroll for(int i=0; i<3; i++) { - id[i] += DGC_procPosition[i] * DGC_localL[i] - sp[i]; + id[i] += DGC->procPosition[i] * DGC->localL[i] - sp[i]; } Float phase; Float2 expon; for(int imom = 0 ; imom < nMoms ; imom++){ int4 momv = texMomList.get(imom); - phase = momv.x*id[0]/((Float) DGC_totalL[0]) + momv.y*id[1]/((Float) DGC_totalL[1]) + momv.z*id[2]/((Float) DGC_totalL[2]); + phase = momv.x*id[0]/((Float) DGC->totalL[0]) + momv.y*id[1]/((Float) DGC->totalL[1]) + momv.z*id[2]/((Float) DGC->totalL[2]); phase *= 2. * PI; expon.x = cos(phase); expon.y = sign*sin(phase); @@ -874,7 +874,7 @@ namespace plegma { return sin(w)/w; } __inline__ int get_time_step(int grid, int block){ - int nblocks= (HGC_localVolume3D+block-1)/block; + int nblocks= (HGC.localVolume3D+block-1)/block; return grid/nblocks; } @@ -1041,15 +1041,15 @@ namespace plegma { //creating array from fastest to slowest for(int i = 0; i < N_DIMS; ++i){ - TZYX_local[i] = (sid/skipvol) % DGC_localL[i]; - skipvol *= DGC_localL[i]; + TZYX_local[i] = (sid/skipvol) % DGC->localL[i]; + skipvol *= DGC->localL[i]; //TZYX_global[i] = TZYX_local[i]; } for(int i = 0; i < N_DIMS; ++i) - TZYX_global[i] = TZYX_local[i] + DGC_procPosition[i] * DGC_localL[i]; + TZYX_global[i] = TZYX_local[i] + DGC->procPosition[i] * DGC->localL[i]; for(int i = N_DIMS-1; i>=0; i--) - globid = globid * DGC_totalL[i] + TZYX_global[i]; + globid = globid * DGC->totalL[i] + TZYX_global[i]; return globid; } diff --git a/lib/kernels/PLEGMA_mesons.cuh b/lib/kernels/PLEGMA_mesons.cuh index db35dd37..d569d8c1 100644 --- a/lib/kernels/PLEGMA_mesons.cuh +++ b/lib/kernels/PLEGMA_mesons.cuh @@ -20,14 +20,14 @@ __global__ void contract_mesons_device( propTex texProp1, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[2*N_MESONS]; for(int i = 0 ; i < 2*N_MESONS ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -58,9 +58,9 @@ __global__ void contract_mesons_device( propTex texProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, 2*N_MESONS, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < 2*N_MESONS ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*2*N_MESONS + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*2*N_MESONS + ip] = accum[ip]; } } } @@ -78,15 +78,15 @@ __global__ void contract_mesons_fourp_ultralocal_device( propTex texProp int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[16]; for(int i = 0 ; i < 16 ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop3[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -142,9 +142,9 @@ __global__ void contract_mesons_fourp_ultralocal_device( propTex texProp int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, 16, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < 16 ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*16 + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*16 + ip] = accum[ip]; } } } @@ -157,15 +157,15 @@ __global__ void contract_mesons_fourp_ultralocal_oneendtrick_device( propTex=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[16]; for(int i = 0 ; i < 16 ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -206,9 +206,9 @@ __global__ void contract_mesons_fourp_ultralocal_oneendtrick_device( propTexlocalVolume3D) for(int ip = 0 ; ip < 16 ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*16 + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*16 + ip] = accum[ip]; } } } @@ -229,7 +229,7 @@ void contract_mesons_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = 2*N_MESONS; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -275,7 +275,7 @@ void contract_mesons_host( ProfileStruct &ps, } } - //printf("PLEGMA_mesons res %e %e %e t_size = %d, maxT = %d, source.w = %d, HGC_localVolume3D %d time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", result[0].norm2(),result[1].norm2(),result[2].norm(),t_size, maxT, source.w, HGC_localVolume3D, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); + //printf("PLEGMA_mesons res %e %e %e t_size = %d, maxT = %d, source.w = %d, HGC.localVolume3D %d time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", result[0].norm2(),result[1].norm2(),result[2].norm(),t_size, maxT, source.w, HGC.localVolume3D, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); hostFree(h_partial_block, alloc_size*sizeof(FloatC)); device_free(d_partial_block); } @@ -295,7 +295,7 @@ void contract_mesons_fourp_ultralocal_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = 16; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -362,7 +362,7 @@ void contract_mesons_fourp_ultralocal_oneendtrick_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = 16; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -430,18 +430,18 @@ static void contract_mesons(PLEGMA_Propagator& prop1, PLEGMA_Propagator< else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_mesons", contract_mesons_host, ps, prop1, prop2, corr, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } @@ -463,18 +463,18 @@ static void contract_mesons_fourp_ultralocal(PLEGMA_Propagator &prop1, P else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_mesons_fourp_ultralocal", contract_mesons_fourp_ultralocal_host, ps, prop1, prop2, prop3, prop4, corr, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } @@ -496,18 +496,18 @@ static void contract_mesons_fourp_ultralocal_oneendtrick(PLEGMA_Propagator *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_mesons_fourp_ultralocal_oneendtrick", contract_mesons_fourp_ultralocal_oneendtrick_host, ps, prop1, prop2, corr, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } diff --git a/lib/kernels/PLEGMA_mesonsAll.cuh b/lib/kernels/PLEGMA_mesonsAll.cuh index a207af02..56153858 100644 --- a/lib/kernels/PLEGMA_mesonsAll.cuh +++ b/lib/kernels/PLEGMA_mesonsAll.cuh @@ -17,15 +17,15 @@ __global__ void contract_mesons_all_device( propTex texProp1, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_PAIRS]; for(int i = 0 ; i < N_PAIRS ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -88,9 +88,9 @@ __global__ void contract_mesons_all_device( propTex texProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, N_PAIRS, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < N_PAIRS ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*N_PAIRS + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*N_PAIRS + ip] = accum[ip]; } } } @@ -110,7 +110,7 @@ void contract_mesons_all_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = N_PAIRS; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -178,18 +178,18 @@ static void contract_mesons_all(PLEGMA_Propagator& prop1, PLEGMA_Propaga else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_mesons_all", contract_mesons_all_host, ps, prop1, prop2, corr, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } diff --git a/lib/kernels/PLEGMA_mesonsNew.cuh b/lib/kernels/PLEGMA_mesonsNew.cuh index ba8dc460..028c9b71 100644 --- a/lib/kernels/PLEGMA_mesonsNew.cuh +++ b/lib/kernels/PLEGMA_mesonsNew.cuh @@ -14,15 +14,15 @@ __global__ void contract_mesons_new_device( propTex texProp1, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_MESONS]; for(int i = 0 ; i < N_MESONS ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; texProp1.get(prop1,vid); @@ -52,9 +52,9 @@ __global__ void contract_mesons_new_device( propTex texProp1, int source_pos[3] = {source.x, source.y, source.z}; fourier_transform_3D(block2, accum, shared_cache, N_MESONS, sid3D, source_pos, moms, 0, -1, time_step, tid); } else { - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int ip = 0 ; ip < N_MESONS ; ip++){ - block2[(tid*DGC_localVolume3D + sid3D)*N_MESONS + ip] = accum[ip]; + block2[(tid*DGC->localVolume3D + sid3D)*N_MESONS + ip] = accum[ip]; } } } @@ -74,7 +74,7 @@ void contract_mesons_new_host( ProfileStruct &ps, auto moms = corr.getTexMomList(); int site_size = N_MESONS; - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -141,18 +141,18 @@ static void contract_mesons_new(PLEGMA_Propagator& prop1, PLEGMA_Propaga else result = (Float2 *) corr.H_elem(); - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; tuneAndRun( ps, "contract_mesons_new", contract_mesons_new_host, ps, prop1, prop2, corr, result); if(runFT) { - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } } diff --git a/lib/kernels/PLEGMA_plaquette.cuh b/lib/kernels/PLEGMA_plaquette.cuh index 05403eb9..a4813462 100644 --- a/lib/kernels/PLEGMA_plaquette.cuh +++ b/lib/kernels/PLEGMA_plaquette.cuh @@ -120,6 +120,6 @@ static Float calculatePlaquette(TG gTex){ tuneAndRun(ps, nameK, calculatePlaquette_host, ps, gTex, plaquette); Float globalPlaquette = 0.; - MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC_fullComm); - return globalPlaquette/(HGC_totalVolume*normC*6); + MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC.fullComm); + return globalPlaquette/(HGC.totalVolume*normC*6); } diff --git a/lib/kernels/PLEGMA_plaquetteCorners.cuh b/lib/kernels/PLEGMA_plaquetteCorners.cuh index 09e2571a..ebf7fd06 100644 --- a/lib/kernels/PLEGMA_plaquetteCorners.cuh +++ b/lib/kernels/PLEGMA_plaquetteCorners.cuh @@ -125,6 +125,6 @@ static Float calculatePlaquetteCorners(gaugeTex gaugeTex){ tuneAndRun(ps, "calculatePlaquetteCorners", calculatePlaquetteCorners_host, ps, gaugeTex, plaquette); Float globalPlaquette = 0.; - MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC_fullComm); - return globalPlaquette/(HGC_totalVolume*N_COLS*6); + MPI_Allreduce(&plaquette , &globalPlaquette , 1 , MPI_Type(plaquette) , MPI_SUM , HGC.fullComm); + return globalPlaquette/(HGC.totalVolume*N_COLS*6); } diff --git a/lib/kernels/PLEGMA_propagator_utils.cuh b/lib/kernels/PLEGMA_propagator_utils.cuh index e2744966..da91dfc9 100644 --- a/lib/kernels/PLEGMA_propagator_utils.cuh +++ b/lib/kernels/PLEGMA_propagator_utils.cuh @@ -65,15 +65,15 @@ template static __global__ void apply_boundaries_kernel(Float *inOut, int t0){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume) return; - int t = (sid/DGC_localL[0]/DGC_localL[1]/DGC_localL[2]) % DGC_localL[3]; - t += DGC_procPosition[3] * DGC_localL[3]; + if (sid >= DGC->localVolume) return; + int t = (sid/DGC->localL[0]/DGC->localL[1]/DGC->localL[2]) % DGC->localL[3]; + t += DGC->procPosition[3] * DGC->localL[3]; if( t < t0 ) { #pragma unroll for(int i = 0 ; i < N_SPINS*N_SPINS*N_COLS*N_COLS ; i++) { - inOut[(i*DGC_localVolume + sid)*2 + 0] *= -1.; - inOut[(i*DGC_localVolume + sid)*2 + 1] *= -1.; + inOut[(i*DGC->localVolume + sid)*2 + 0] *= -1.; + inOut[(i*DGC->localVolume + sid)*2 + 1] *= -1.; } } } @@ -81,7 +81,7 @@ static __global__ void apply_boundaries_kernel(Float *inOut, int t0){ template void apply_boundaries(Float *inOut, int t0){ dim3 blockDim( THREADS_PER_BLOCK , 1, 1); - dim3 gridDim( (HGC_localVolume + blockDim.x -1)/blockDim.x , 1 , 1); + dim3 gridDim( (HGC.localVolume + blockDim.x -1)/blockDim.x , 1 , 1); apply_boundaries_kernel<<>>(inOut,t0); checkQudaError(); } @@ -90,7 +90,7 @@ template static __global__ void rotateToPhysicalBase_kernel(Float *inOut, int sign){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume) return; + if (sid >= DGC->localVolume) return; Float2 P[4][4], PT[4][4], sign_imag_unit(sign*1., IMAG), *inOut2 = (Float2 *) inOut; @@ -105,7 +105,7 @@ static __global__ void rotateToPhysicalBase_kernel(Float *inOut, int sign){ for(int mu = 0 ; mu < N_SPINS ; mu++) #pragma unroll for(int nu = 0 ; nu < N_SPINS; nu++) - P[mu][nu] = inOut2[(((mu*N_SPINS + nu)*N_COLS + c1)*N_COLS + c2)*DGC_localVolume + sid]; + P[mu][nu] = inOut2[(((mu*N_SPINS + nu)*N_COLS + c1)*N_COLS + c2)*DGC->localVolume + sid]; // shuffling #pragma unroll @@ -119,7 +119,7 @@ static __global__ void rotateToPhysicalBase_kernel(Float *inOut, int sign){ for(int mu = 0 ; mu < N_SPINS ; mu++) #pragma unroll for(int nu = 0 ; nu < N_SPINS; nu++) - inOut2[(((mu*N_SPINS + nu)*N_COLS + c1)*N_COLS + c2)*DGC_localVolume + sid] = PT[mu][nu]; + inOut2[(((mu*N_SPINS + nu)*N_COLS + c1)*N_COLS + c2)*DGC->localVolume + sid] = PT[mu][nu]; } } @@ -127,7 +127,7 @@ static __global__ void rotateToPhysicalBase_kernel(Float *inOut, int sign){ template void rotateToPhysicalBase(Float* inOut, int sign){ dim3 blockDim( THREADS_PER_BLOCK , 1, 1); - dim3 gridDim( (HGC_localVolume + blockDim.x -1)/blockDim.x , 1 , 1); + dim3 gridDim( (HGC.localVolume + blockDim.x -1)/blockDim.x , 1 , 1); rotateToPhysicalBase_kernel<<>>((Float*) inOut,sign); checkQudaError(); } diff --git a/lib/kernels/PLEGMA_scattreductions.cuh b/lib/kernels/PLEGMA_scattreductions.cuh index d15d9cff..01e45237 100644 --- a/lib/kernels/PLEGMA_scattreductions.cuh +++ b/lib/kernels/PLEGMA_scattreductions.cuh @@ -40,7 +40,7 @@ static void V_reductions_host( ProfileStruct &ps, VRED V, PLEGMA_ScattCorrelator //value of some quantities - if(HGC_verbosity > 2){ + if(HGC.verbosity > 2){ PLEGMA_printf("t_size = %d, maxT = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); PLEGMA_printf("size = %d, volume = %d, nblockxt = %d\n", size, N_moms, nblockspert); } @@ -155,11 +155,11 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, hostMalloc(result, Vout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Vout.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="V_reductions_V"+std::to_string(int(V))+"_gammas_"; @@ -171,7 +171,7 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, ps, V, Vout, result, Gammas, *vectorPhi,*vectorPhi,*propS, *propS); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Vout.getTotalSize()*sizeof(Float2)); } @@ -193,11 +193,11 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, hostMalloc(result, Vout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Vout.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="V_reductions_V"+std::to_string(int(V))+"_gammas_"; @@ -210,7 +210,7 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, ps, V, Vout, result, Gammas, *vectorPhi,*vectorPhi, *propS1, *propS2); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Vout.getTotalSize()*sizeof(Float2)); @@ -233,11 +233,11 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, hostMalloc(result, Vout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Vout.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="V_reductions_V"+std::to_string(int(V))+"_gammas_"; @@ -250,7 +250,7 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, ps, V, Vout, result, Gammas, *vectorPhi1,*vectorPhi2, *propS1, *propS1); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Vout.getTotalSize()*sizeof(Float2)); @@ -274,11 +274,11 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, hostMalloc(result, Vout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Vout.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="V_reductions_V"+std::to_string(int(V)); @@ -292,7 +292,7 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, ps, V, Vout, result, Gammas, *vectorPhi1,*vectorPhi2, *propS, *propS); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Vout.getTotalSize()*sizeof(Float2)); @@ -313,12 +313,12 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, hostMalloc(result, Vout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Vout.localT(); int maxLocalT = myLocalT; std::vector Gammas {}; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="V_reductions_V"+std::to_string(int(V)); @@ -336,7 +336,7 @@ static void V_reductions(VRED V, PLEGMA_ScattCorrelator &Vout, ps, V, Vout, result, Gammas, *vectorPhi1,*vectorPhi2,*propS,*propS); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Vout.H_elem(), Vout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Vout.getTotalSize()*sizeof(Float2)); @@ -365,7 +365,7 @@ static void T_reductions_host( ProfileStruct &ps, TRED T, PLEGMA_ScattCorrelator int site_size = Tout.getSiteSize(); int nblockspert = ps.tp.grid.x/time_step; - if(HGC_verbosity > 2){ + if(HGC.verbosity > 2){ PLEGMA_printf("t_size = %d, maxT = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); PLEGMA_printf("size = %d, volume = %d, nblockxt = %d\n", size, N_moms, nblockspert); } @@ -405,7 +405,7 @@ static void T_reductions_host( ProfileStruct &ps, TRED T, PLEGMA_ScattCorrelator qudaMemcpy(listGammas_i.array, gammas_i.data(), gammas_i.size()*sizeof(GAMMAS_SCATT), qudaMemcpyHostToDevice); qudaMemcpy(listGammas_f.array, gammas_f.data(), gammas_f.size()*sizeof(GAMMAS_SCATT), qudaMemcpyHostToDevice); checkQudaError(); - if(HGC_verbosity > 2){ + if(HGC.verbosity > 2){ PLEGMA_printf("site_size= %d\n", listGammas_f.size*listGammas_i.size*N_SPINS*N_SPINS); } for(int it=0; it < t_size; it+=time_step) { @@ -460,11 +460,11 @@ static void T_reductions(TRED T, PLEGMA_ScattCorrelator &Tout, hostMalloc(result, Tout.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = Tout.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="T_reductions_T"+std::to_string(int(T))+"_gammas_i_"; @@ -479,7 +479,7 @@ static void T_reductions(TRED T, PLEGMA_ScattCorrelator &Tout, ps, T, Tout, result, Gammas_i, Gammas_f, *propS1, *propS2, *propS3); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, Tout.H_elem(), Tout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, Tout.H_elem(), Tout.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, Tout.getTotalSize()*sizeof(Float2)); diff --git a/lib/kernels/PLEGMA_scattreductionsPiPi.cuh b/lib/kernels/PLEGMA_scattreductionsPiPi.cuh index 7ed4db34..c65cbe48 100644 --- a/lib/kernels/PLEGMA_scattreductionsPiPi.cuh +++ b/lib/kernels/PLEGMA_scattreductionsPiPi.cuh @@ -13,8 +13,8 @@ __global__ void PhixGxPhi_kernel( vectorTex vectorPhi0, KernelArr=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[16]; for(int i = 0 ; i < 16 ; i++){ @@ -23,7 +23,7 @@ __global__ void PhixGxPhi_kernel( vectorTex vectorPhi0, KernelArrlocalVolume3D){ Float2 phi0[N_SPINS][N_COLS]; Float2 phi1[N_SPINS][N_COLS]; vectorPhi0.get(phi0,vid); @@ -80,7 +80,7 @@ static void PhixGxPhi_host( ProfileStruct &ps, PLEGMA_ScattCorrelator int site_size = corr.getSiteSize(); int nblockspert = ps.tp.grid.x/time_step; - if(HGC_verbosity > 2){ + if(HGC.verbosity > 2){ printf("t_size = %d, maxT = %d, source.w = %d, time_step = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", t_size, maxT, source.w, time_step, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); PLEGMA_printf("size = %d, volume = %d, nblockxt = %d\n", size, N_moms, nblockspert); } @@ -109,7 +109,7 @@ static void PhixGxPhi_host( ProfileStruct &ps, PLEGMA_ScattCorrelator checkQudaError(); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS_SCATT), qudaMemcpyHostToDevice); checkQudaError(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) PLEGMA_printf("site_size= %d\n", listGammas.size*N_SPINS*N_COLS); auto phiTex0 = toTexture(Phi0); @@ -159,11 +159,11 @@ static void PhixGxPhi_k(PLEGMA_ScattCorrelator &corr, hostMalloc(result, corr.getTotalSize()*sizeof(Float2)); //N.B N_moms*Tlocal*site_size //allocation of a number of threads multiple of local3DVolume. the profiler will decide how much. - ProfileStruct ps(HGC_localVolume3D, shared_size); + ProfileStruct ps(HGC.localVolume3D, shared_size); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; std::string kerName="PhixGxPhi_gammas_"; @@ -173,7 +173,7 @@ static void PhixGxPhi_k(PLEGMA_ScattCorrelator &corr, ps, corr, result, Gammas, Phi0, Phi1); //reduction between spaceComm for the sum of Fourier transformation between nodes - MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC_spaceComm); + MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(), MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } diff --git a/lib/kernels/PLEGMA_scattreductionsT1.cuh b/lib/kernels/PLEGMA_scattreductionsT1.cuh index 0141545d..65969a67 100644 --- a/lib/kernels/PLEGMA_scattreductionsT1.cuh +++ b/lib/kernels/PLEGMA_scattreductionsT1.cuh @@ -12,8 +12,8 @@ __global__ void T1_kernel( KernelArr listGammas_i, KernelArr=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; //int site_size = N_GAMMAS_SCATT_I*N_GAMMAS_SCATT_F*N_SPINS*N_SPINS; Float2 accum[N_GAMMAS_SCATT_I*N_GAMMAS_SCATT_F*N_SPINS*N_SPINS]; @@ -22,7 +22,7 @@ __global__ void T1_kernel( KernelArr listGammas_i, KernelArrlocalVolume3D){ Float2 s1[N_SPINS][N_SPINS][N_COLS][N_COLS], s2[N_SPINS][N_SPINS][N_COLS][N_COLS], s3[N_SPINS][N_SPINS][N_COLS][N_COLS]; propS1.get(s1,vid); propS2.get(s2,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsT2.cuh b/lib/kernels/PLEGMA_scattreductionsT2.cuh index 99afba27..53a40225 100644 --- a/lib/kernels/PLEGMA_scattreductionsT2.cuh +++ b/lib/kernels/PLEGMA_scattreductionsT2.cuh @@ -12,8 +12,8 @@ __global__ void T2_kernel( KernelArr listGammas_i, KernelArr=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; //int site_size = N_GAMMAS_SCATT_I*N_GAMMAS_SCATT_F*N_SPINS*N_SPINS; Float2 accum[N_GAMMAS_SCATT_I*N_GAMMAS_SCATT_F*N_SPINS*N_SPINS]; @@ -22,7 +22,7 @@ __global__ void T2_kernel( KernelArr listGammas_i, KernelArrlocalVolume3D){ Float2 s1[N_SPINS][N_SPINS][N_COLS][N_COLS], s2[N_SPINS][N_SPINS][N_COLS][N_COLS], s3[N_SPINS][N_SPINS][N_COLS][N_COLS]; propS1.get(s1,vid); propS2.get(s2,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsV2.cuh b/lib/kernels/PLEGMA_scattreductionsV2.cuh index eacb45cb..5252830d 100644 --- a/lib/kernels/PLEGMA_scattreductionsV2.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV2.cuh @@ -11,8 +11,8 @@ __global__ void V2_kernel( vectorTex vectorPhi, KernelArr int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_GAMMAS_SCATT*N_SPINS*N_SPINS*N_SPINS*N_COLS]; for(int i = 0 ; i vectorPhi, KernelArr } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 s1[N_SPINS][N_SPINS][N_COLS][N_COLS], s2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 phi[N_SPINS][N_COLS]; propS1.get(s1,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsV3.cuh b/lib/kernels/PLEGMA_scattreductionsV3.cuh index 01343a4d..8844b644 100644 --- a/lib/kernels/PLEGMA_scattreductionsV3.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV3.cuh @@ -11,15 +11,15 @@ __global__ void V3_kernel( vectorTex vectorPhi, KernelArr int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_GAMMAS_SCATT*N_SPINS*N_COLS]; for(int i = 0 ; i localVolume3D){ Float2 s[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 phi[N_SPINS][N_COLS]; propS.get(s,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsV4.cuh b/lib/kernels/PLEGMA_scattreductionsV4.cuh index 28815f01..8e01aaa6 100644 --- a/lib/kernels/PLEGMA_scattreductionsV4.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV4.cuh @@ -11,15 +11,15 @@ __global__ void V4_kernel( vectorTex vectorPhi, KernelArr int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_GAMMAS_SCATT*N_SPINS*N_SPINS*N_SPINS*N_COLS]; for(int i = 0 ; i localVolume3D){ Float2 s1[N_SPINS][N_SPINS][N_COLS][N_COLS], s2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 phi[N_SPINS][N_COLS]; propS1.get(s1,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsV5.cuh b/lib/kernels/PLEGMA_scattreductionsV5.cuh index 669ed93c..0c0eaf51 100644 --- a/lib/kernels/PLEGMA_scattreductionsV5.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV5.cuh @@ -11,14 +11,14 @@ __global__ void V5_kernel( vectorTex vectorPhi1, vectorTex vecto int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS*N_COLS]; for(int i = 0 ; i localVolume3D){ Float2 phi1[N_SPINS][N_COLS]; Float2 phi2[N_SPINS][N_COLS]; vectorPhi1.get(phi1,vid); diff --git a/lib/kernels/PLEGMA_scattreductionsV6.cuh b/lib/kernels/PLEGMA_scattreductionsV6.cuh index 5b6691e7..f45ca409 100644 --- a/lib/kernels/PLEGMA_scattreductionsV6.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV6.cuh @@ -11,15 +11,15 @@ __global__ void V6_kernel( vectorTex vectorPhi1, vectorTex vecto int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS*N_SPINS*N_SPINS*N_COLS]; for(int i = 0 ; i < N_SPINS*N_SPINS*N_SPINS*N_SPINS*N_COLS ; i++){ accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 s[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 phi1[N_SPINS][N_COLS]; Float2 phi2[N_SPINS][N_COLS]; diff --git a/lib/kernels/PLEGMA_scattreductionsV6_red.cuh b/lib/kernels/PLEGMA_scattreductionsV6_red.cuh index e3885127..c1ff4471 100644 --- a/lib/kernels/PLEGMA_scattreductionsV6_red.cuh +++ b/lib/kernels/PLEGMA_scattreductionsV6_red.cuh @@ -11,8 +11,8 @@ __global__ void V6_RED_kernel( vectorTex vectorPhi1, vectorTex v int grid3D = gridDim.x/time_step; //n_blocks x timeslice int sid3D = (blockIdx.x % grid3D)*blockDim.x + threadIdx.x;//id of thread int tid = blockIdx.x/grid3D; - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; const unsigned short N_S1C=N_SPINS*N_COLS; @@ -22,7 +22,7 @@ __global__ void V6_RED_kernel( vectorTex vectorPhi1, vectorTex v accum[i] = 0.; } - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 s[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 phi1[N_SPINS][N_COLS]; Float2 phi2[N_SPINS][N_COLS]; diff --git a/lib/kernels/PLEGMA_su3field.cuh b/lib/kernels/PLEGMA_su3field.cuh index ff9d3a53..4c4ac87d 100644 --- a/lib/kernels/PLEGMA_su3field.cuh +++ b/lib/kernels/PLEGMA_su3field.cuh @@ -198,6 +198,6 @@ static Float sumRtraceU_k(PLEGMA_Su3field &su3M){ tuneAndRun(ps, "sum_real_trace_host", sum_real_trace_host, ps, su3M, sum); Float globalSum = 0.; - MPI_Allreduce(&sum , &globalSum , 1 , MPI_Type(sum) , MPI_SUM , HGC_fullComm); + MPI_Allreduce(&sum , &globalSum , 1 , MPI_Type(sum) , MPI_SUM , HGC.fullComm); return globalSum; } diff --git a/lib/kernels/PLEGMA_threep_local.cu b/lib/kernels/PLEGMA_threep_local.cu index 3aa2b4ea..5e938300 100644 --- a/lib/kernels/PLEGMA_threep_local.cu +++ b/lib/kernels/PLEGMA_threep_local.cu @@ -29,15 +29,15 @@ __global__ void threep_local_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS]; // max value of gammas #pragma unroll for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -74,9 +74,9 @@ __global__ void threep_local_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, listGammas.size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < listGammas.size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; } } @@ -105,7 +105,7 @@ static void threep_local_host(ProfileStruct &ps, Float2 *result, listGammas.array=(GAMMAS *)device_malloc( gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -186,11 +186,11 @@ void threep_local(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -206,7 +206,7 @@ void threep_local(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_noe.cu b/lib/kernels/PLEGMA_threep_noe.cu index e9b8cbcc..0764aef7 100644 --- a/lib/kernels/PLEGMA_threep_noe.cu +++ b/lib/kernels/PLEGMA_threep_noe.cu @@ -17,15 +17,15 @@ __global__ void threep_noe_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 noeV[N_DIMS]; #pragma unroll for(int i = 0; i < N_DIMS; i++) noeV[i] = 0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 R[N_SPINS][N_SPINS]; @@ -65,9 +65,9 @@ __global__ void threep_noe_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, noeV, shared_cache, N_DIMS, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int i = 0; i < N_DIMS; i++) - block2[(tid*DGC_localVolume3D + sid3D)*N_DIMS+i] = noeV[i]; + block2[(tid*DGC->localVolume3D + sid3D)*N_DIMS+i] = noeV[i]; } } @@ -87,7 +87,7 @@ static void threep_noe_host(ProfileStruct &ps, Float2 *result, PLEGMA_Co int4 source = corr.getSource(); auto moms = corr.getTexMomList(); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -147,11 +147,11 @@ void threep_noe(PLEGMA_Correlator &corr, PLEGMA_Propagator& prop PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); } - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -165,7 +165,7 @@ void threep_noe(PLEGMA_Correlator &corr, PLEGMA_Propagator& prop if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_oneD.cu b/lib/kernels/PLEGMA_threep_oneD.cu index 55ddda87..7983b21e 100644 --- a/lib/kernels/PLEGMA_threep_oneD.cu +++ b/lib/kernels/PLEGMA_threep_oneD.cu @@ -31,8 +31,8 @@ __global__ void threep_oneD_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_DIMS*N_SPINS*N_SPINS]; @@ -41,7 +41,7 @@ __global__ void threep_oneD_device(Float2* block2, accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -95,9 +95,9 @@ __global__ void threep_oneD_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, N_DIMS*listGammas.size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < N_DIMS*listGammas.size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*N_DIMS*listGammas.size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*N_DIMS*listGammas.size+iop] = accum[iop]; } } @@ -128,7 +128,7 @@ static void threep_oneD_host(ProfileStruct &ps, Float2 *result, PLEGMA_C listGammas.array=(GAMMAS*)device_malloc(gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -211,11 +211,11 @@ void threep_oneD(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = N_DIMS*gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -231,7 +231,7 @@ void threep_oneD(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_qgq.cu b/lib/kernels/PLEGMA_threep_qgq.cu index 1c51aa1f..1859d457 100644 --- a/lib/kernels/PLEGMA_threep_qgq.cu +++ b/lib/kernels/PLEGMA_threep_qgq.cu @@ -25,15 +25,15 @@ __global__ void threep_qgq_kernel(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS]; // max value of gammas #pragma unroll for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 pp1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 pp2[N_SPINS][N_SPINS][N_COLS][N_COLS]; @@ -65,9 +65,9 @@ __global__ void threep_qgq_kernel(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, listGammas.size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < listGammas.size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; } } @@ -97,7 +97,7 @@ static void threep_qgq_host(ProfileStruct &ps, Float2 *result, listGammas.array=(GAMMAS*)device_malloc(gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -178,11 +178,11 @@ void threep_qgq(PLEGMA_Correlator &corr, if(corr.getSiteSize() != site_size) PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -198,7 +198,7 @@ void threep_qgq(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_staple.cu b/lib/kernels/PLEGMA_threep_staple.cu index 698c01dd..3b5d1470 100644 --- a/lib/kernels/PLEGMA_threep_staple.cu +++ b/lib/kernels/PLEGMA_threep_staple.cu @@ -20,15 +20,15 @@ __global__ void threep_staple_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS]; // max value of gammas #pragma unroll for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 su3[N_COLS][N_COLS]; @@ -58,9 +58,9 @@ __global__ void threep_staple_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, listGammas.size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < listGammas.size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; } } @@ -88,7 +88,7 @@ static void threep_staple_host(ProfileStruct &ps, Float2 *result, listGammas.array=(GAMMAS*)device_malloc(gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -171,11 +171,11 @@ void threep_staple(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -191,7 +191,7 @@ void threep_staple(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_threeD_part1.cu b/lib/kernels/PLEGMA_threep_threeD_part1.cu index a7692284..dd09fba4 100644 --- a/lib/kernels/PLEGMA_threep_threeD_part1.cu +++ b/lib/kernels/PLEGMA_threep_threeD_part1.cu @@ -31,8 +31,8 @@ __global__ void threep_threeD_part1_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_SPINS*N_SPINS]; @@ -40,7 +40,7 @@ __global__ void threep_threeD_part1_device(Float2* block2, for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -141,9 +141,9 @@ __global__ void threep_threeD_part1_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size+iop] = accum[iop]; } } @@ -172,7 +172,7 @@ static void threep_threeD_part1_host(ProfileStruct &ps, Float2 *result, listGammas.array=(GAMMAS*)device_malloc(gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -271,11 +271,11 @@ void threep_threeD_part1(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = (Float2 *) corr.H_elem(); diff --git a/lib/kernels/PLEGMA_threep_threeD_part2.cu b/lib/kernels/PLEGMA_threep_threeD_part2.cu index 5ff28170..90230729 100644 --- a/lib/kernels/PLEGMA_threep_threeD_part2.cu +++ b/lib/kernels/PLEGMA_threep_threeD_part2.cu @@ -33,8 +33,8 @@ __global__ void threep_threeD_part2_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_SPINS*N_SPINS]; @@ -42,7 +42,7 @@ __global__ void threep_threeD_part2_device(Float2* block2, for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -139,9 +139,9 @@ __global__ void threep_threeD_part2_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size+iop] = accum[iop]; } } @@ -170,7 +170,7 @@ static void threep_threeD_part2_host(ProfileStruct &ps, Float2 *result, qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -268,11 +268,11 @@ void threep_threeD_part2(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = (Float2 *) corr.H_elem(); diff --git a/lib/kernels/PLEGMA_threep_threeD_part3.cu b/lib/kernels/PLEGMA_threep_threeD_part3.cu index 5f31e940..9b6ff994 100644 --- a/lib/kernels/PLEGMA_threep_threeD_part3.cu +++ b/lib/kernels/PLEGMA_threep_threeD_part3.cu @@ -32,8 +32,8 @@ __global__ void threep_threeD_part3_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_SPINS*N_SPINS]; @@ -41,7 +41,7 @@ __global__ void threep_threeD_part3_device(Float2* block2, for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -138,9 +138,9 @@ __global__ void threep_threeD_part3_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size+iop] = accum[iop]; } } @@ -170,7 +170,7 @@ static void threep_threeD_part3_host(ProfileStruct &ps, Float2 *result, qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -268,11 +268,11 @@ void threep_threeD_part3(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = (Float2 *) corr.H_elem(); diff --git a/lib/kernels/PLEGMA_threep_threeD_part4.cu b/lib/kernels/PLEGMA_threep_threeD_part4.cu index cacef16c..f25c4960 100644 --- a/lib/kernels/PLEGMA_threep_threeD_part4.cu +++ b/lib/kernels/PLEGMA_threep_threeD_part4.cu @@ -32,8 +32,8 @@ __global__ void threep_threeD_part4_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_SPINS*N_SPINS]; @@ -41,7 +41,7 @@ __global__ void threep_threeD_part4_device(Float2* block2, for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; @@ -140,9 +140,9 @@ __global__ void threep_threeD_part4_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size+iop] = accum[iop]; } } @@ -171,7 +171,7 @@ static void threep_threeD_part4_host(ProfileStruct &ps, Float2 *result, // cudaMalloc((void**)&listGammas.array, gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -270,11 +270,11 @@ void threep_threeD_part4(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -289,7 +289,7 @@ void threep_threeD_part4(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_twoD.cu b/lib/kernels/PLEGMA_threep_twoD.cu index 521f5c7a..031c1c41 100644 --- a/lib/kernels/PLEGMA_threep_twoD.cu +++ b/lib/kernels/PLEGMA_threep_twoD.cu @@ -30,8 +30,8 @@ __global__ void threep_twoD_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; bool notZfac = (mu<0) && (nu<0) && (c1<0) && (c2<0); Float2 accum[N_SPINS*N_SPINS]; @@ -39,7 +39,7 @@ __global__ void threep_twoD_device(Float2* block2, for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ local_PorV prop1; local_PorV prop2; Float2 R[N_SPINS][N_SPINS]; @@ -139,9 +139,9 @@ __global__ void threep_twoD_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, site_size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < site_size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*site_size+iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*site_size+iop] = accum[iop]; } } @@ -170,7 +170,7 @@ static void threep_twoD_host(ProfileStruct &ps, Float2 *result, PLEGMA_C // cudaMalloc((void**)&listGammas.array, gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -258,11 +258,11 @@ void threep_twoD(PLEGMA_Correlator &corr, PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); site_size = gammas.size(); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -278,7 +278,7 @@ void threep_twoD(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_threep_wilsonLine.cu b/lib/kernels/PLEGMA_threep_wilsonLine.cu index f54848dd..482c9a27 100644 --- a/lib/kernels/PLEGMA_threep_wilsonLine.cu +++ b/lib/kernels/PLEGMA_threep_wilsonLine.cu @@ -20,15 +20,15 @@ __global__ void threep_wilsonLine_device(Float2* block2, int tid = blockIdx.x/grid3D; // this takes into account the case where the source is in the local lattice // and we need to start from it when we go over maxT - int t=it+tid; if(t>=maxT) t=(source.w%DGC_localL[DIM_T])+t-maxT; - int vid = sid3D + t*DGC_localVolume3D; + int t=it+tid; if(t>=maxT) t=(source.w%DGC->localL[DIM_T])+t-maxT; + int vid = sid3D + t*DGC->localVolume3D; Float2 accum[N_SPINS*N_SPINS]; // max value of gammas #pragma unroll for(int i = 0; i < N_SPINS*N_SPINS; i++) accum[i]=0; - if (sid3D < DGC_localVolume3D){ + if (sid3D < DGC->localVolume3D){ Float2 prop1[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 prop2[N_SPINS][N_SPINS][N_COLS][N_COLS]; Float2 su3[N_COLS][N_COLS]; @@ -51,9 +51,9 @@ __global__ void threep_wilsonLine_device(Float2* block2, Float2 *shared_cache = (Float2 *) ext_shared_cache; fourier_transform_3D(block2, accum, shared_cache, listGammas.size, sid3D, source_pos, moms, 0, +1, time_step, tid); } else{ - if (sid3D < DGC_localVolume3D) + if (sid3D < DGC->localVolume3D) for(int iop = 0; iop < listGammas.size; iop++) - block2[(tid*DGC_localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; + block2[(tid*DGC->localVolume3D + sid3D)*listGammas.size +iop] = accum[iop]; } } @@ -78,7 +78,7 @@ static void threep_wilsonLine_host(ProfileStruct &ps, Float2 *result, listGammas.array=(GAMMAS*)device_malloc( gammas.size()*sizeof(GAMMAS)); qudaMemcpy(listGammas.array, gammas.data(), gammas.size()*sizeof(GAMMAS), qudaMemcpyHostToDevice); - if(HGC_verbosity > 2) + if(HGC.verbosity > 2) if(corr.hasSource()) printf("time_step = %d, t_size = %d, maxT = %d, ps.tp.grid.x = %d, ps.tp.block.x = %d, ps.tp.shared_bytes = %d\n", time_step, t_size, maxT, ps.tp.grid.x, ps.tp.block.x, ps.tp.shared_bytes); @@ -146,11 +146,11 @@ void threep_wilsonLine(PLEGMA_Correlator &corr, if(corr.getSiteSize() != site_size) PLEGMA_error("Correlator siteSize do not match: %d != %d\n", corr.getSiteSize(), site_size); - ProfileStruct ps(HGC_localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); + ProfileStruct ps(HGC.localVolume3D, (runFT==true) ? site_size*sizeof(Float2) : 0); int myLocalT = corr.localT(); int maxLocalT = myLocalT; - MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC_fullComm); - ps.max_volume = HGC_localVolume3D*maxLocalT; + MPI_Allreduce( &myLocalT, &maxLocalT, 1, MPI_Type(maxLocalT), MPI_MAX, HGC.fullComm); + ps.max_volume = HGC.localVolume3D*maxLocalT; ps.tune_globally = true; Float2 *result = NULL; @@ -164,7 +164,7 @@ void threep_wilsonLine(PLEGMA_Correlator &corr, if(runFT) { MPI_Allreduce(result, corr.H_elem(), corr.getTotalSize()*2, MPI_Type(corr.H_elem()), - MPI_SUM, HGC_spaceComm); + MPI_SUM, HGC.spaceComm); hostFree(result, corr.getTotalSize()*sizeof(Float2)); } #else diff --git a/lib/kernels/PLEGMA_topocharge.cuh b/lib/kernels/PLEGMA_topocharge.cuh index b1a74eeb..0c76aa65 100644 --- a/lib/kernels/PLEGMA_topocharge.cuh +++ b/lib/kernels/PLEGMA_topocharge.cuh @@ -206,7 +206,7 @@ static Float calcTopoCharge(gaugeTex gaugeTex, TOPO_CHARGE_DEF charge_de } free(h_partial_Q); - MPI_Allreduce(&Q , &globalQ , 1 , MPI_Type(Q) , MPI_SUM , HGC_fullComm); + MPI_Allreduce(&Q , &globalQ , 1 , MPI_Type(Q) , MPI_SUM , HGC.fullComm); return globalQ/PI/PI/4.; // 8*( 3 indipendent ijkt index order ) /( 32 pi**2) } @@ -265,6 +265,6 @@ static Float calcPlaqClovDef(gaugeTex gaugeTex){ Plaq += h_partial_Plaq[i]; free(h_partial_Plaq); - MPI_Allreduce(&Plaq , &globalPlaq , 1 , MPI_Type(Plaq) , MPI_SUM , HGC_fullComm); - return globalPlaq/(HGC_totalVolume*N_COLS*6); // 6*N_sites Plaquettes(+ 3 colors to normalize the trace ) + MPI_Allreduce(&Plaq , &globalPlaq , 1 , MPI_Type(Plaq) , MPI_SUM , HGC.fullComm); + return globalPlaq/(HGC.totalVolume*N_COLS*6); // 6*N_sites Plaquettes(+ 3 colors to normalize the trace ) } diff --git a/lib/kernels/PLEGMA_u1gauge_utils.cuh b/lib/kernels/PLEGMA_u1gauge_utils.cuh index bbe1e128..1b65753c 100644 --- a/lib/kernels/PLEGMA_u1gauge_utils.cuh +++ b/lib/kernels/PLEGMA_u1gauge_utils.cuh @@ -13,7 +13,7 @@ static __global__ void constField_kernel(u1gauge2 G, int mu, int nu, Floa for(int i =0; i < N_DIMS; i++){ if(i==mu){ Float val; - int xmx0=DGC_procPosition[nu]*DGC_localL[nu]+x[nu] - xnu_0; + int xmx0=DGC->procPosition[nu]*DGC->localL[nu]+x[nu] - xnu_0; val = exparg * xmx0 ; gg.x = cos(val); gg.y = sin(val); } diff --git a/lib/kernels/PLEGMA_vector_utils.cuh b/lib/kernels/PLEGMA_vector_utils.cuh index fe4d090f..9762ca32 100644 --- a/lib/kernels/PLEGMA_vector_utils.cuh +++ b/lib/kernels/PLEGMA_vector_utils.cuh @@ -84,19 +84,19 @@ void apply_gamma5_vector(vector2 vec){ template static __global__ void copy_to_QUDA(FloatIn *in, FloatOut *outEven, FloatOut *outOdd){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume/2) return; + if (sid >= DGC->localVolume/2) return; // take indices on 4d lattice - int half_stride = DGC_localVolume/2; + int half_stride = DGC->localVolume/2; int latt_coord = 2*sid; int r1,r2,x_id,y_id,z_id,t_id; - r1 = latt_coord/(DGC_localL[0]); - r2 = r1/(DGC_localL[1]); - x_id = latt_coord - r1*(DGC_localL[0]); - y_id = r1 - r2*(DGC_localL[1]); - t_id = r2/(DGC_localL[2]); - z_id = r2 - t_id*(DGC_localL[2]); + r1 = latt_coord/(DGC->localL[0]); + r2 = r1/(DGC->localL[1]); + x_id = latt_coord - r1*(DGC->localL[0]); + y_id = r1 - r2*(DGC->localL[1]); + t_id = r2/(DGC->localL[2]); + z_id = r2 - t_id*(DGC->localL[2]); int evenSiteBit = ((x_id+y_id+z_id+t_id) & 1); int oddSiteBit = evenSiteBit ^ 1; Float2 *outEven2 = (Float2 *) outEven; @@ -109,13 +109,13 @@ static __global__ void copy_to_QUDA(FloatIn *in, FloatOut *outEven, FloatOut *ou for(int ic = 0 ; ic < N_COLS ; ic++){ if(outEvenB) { outEven2[(mu*N_COLS + ic)*half_stride + sid] = - in2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + evenSiteBit]; + in2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + evenSiteBit]; } else outEven2[(mu*N_COLS + ic)*half_stride + sid] = 0.; if(outOddB) { outOdd2[(mu*N_COLS + ic)*half_stride + sid] = - in2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + oddSiteBit]; + in2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + oddSiteBit]; } else outOdd2[(mu*N_COLS + ic)*half_stride + sid] = 0.; } @@ -125,7 +125,7 @@ static __global__ void copy_to_QUDA(FloatIn *in, FloatOut *outEven, FloatOut *ou template static void copy_to_QUDA(FloatIn* in,ColorSpinorField &qudaVec, bool isEven){ dim3 blockDim( THREADS_PER_BLOCK , 1, 1); - dim3 gridDim( (HGC_localVolume + blockDim.x -1)/blockDim.x , 1 , 1); + dim3 gridDim( (HGC.localVolume + blockDim.x -1)/blockDim.x , 1 , 1); if( qudaVec.SiteSubset() == QUDA_PARITY_SITE_SUBSET ){ if( isEven ) copy_to_QUDA<<>>(in,(FloatOut*) qudaVec.V(), NULL); @@ -151,18 +151,18 @@ template static __global__ void copy_from_QUDA_kernel(FloatOut *out, FloatIn *inEven, FloatIn *inOdd){ int sid = blockIdx.x*blockDim.x + threadIdx.x; - if (sid >= DGC_localVolume/2) return; + if (sid >= DGC->localVolume/2) return; - int half_stride = DGC_localVolume/2; + int half_stride = DGC->localVolume/2; int latt_coord = 2*sid; int r1,r2,x_id,y_id,z_id,t_id; - r1 = latt_coord/(DGC_localL[0]); - r2 = r1/(DGC_localL[1]); - x_id = latt_coord - r1*(DGC_localL[0]); - y_id = r1 - r2*(DGC_localL[1]); - t_id = r2/(DGC_localL[2]); - z_id = r2 - t_id*(DGC_localL[2]); + r1 = latt_coord/(DGC->localL[0]); + r2 = r1/(DGC->localL[1]); + x_id = latt_coord - r1*(DGC->localL[0]); + y_id = r1 - r2*(DGC->localL[1]); + t_id = r2/(DGC->localL[2]); + z_id = r2 - t_id*(DGC->localL[2]); int evenSiteBit = ((x_id+y_id+z_id+t_id) & 1); int oddSiteBit = evenSiteBit ^ 1; Float2 *inEven2 = (Float2 *) inEven; @@ -174,23 +174,23 @@ static __global__ void copy_from_QUDA_kernel(FloatOut *out, FloatIn *inEven, Flo #pragma unroll for(int ic = 0 ; ic < N_COLS ; ic++) { if(inEvenB) { - out2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + evenSiteBit] = + out2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + evenSiteBit] = inEven2[(mu*N_COLS + ic)*half_stride + sid]; } else - out2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + evenSiteBit] = 0.; + out2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + evenSiteBit] = 0.; if(inOddB) { - out2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + oddSiteBit] = + out2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + oddSiteBit] = inOdd2[(mu*N_COLS + ic)*half_stride + sid]; } else - out2[(mu*N_COLS + ic)*DGC_localVolume + latt_coord + oddSiteBit] = 0.; + out2[(mu*N_COLS + ic)*DGC->localVolume + latt_coord + oddSiteBit] = 0.; } } } template static void copy_from_QUDA(FloatOut* out, ColorSpinorField &qudaVec, bool isEven){ - ProfileStruct ps(HGC_localVolume); + ProfileStruct ps(HGC.localVolume); if( qudaVec.SiteSubset() == QUDA_PARITY_SITE_SUBSET ){ if( isEven ) tuneAndRun(ps, "copy_from_QUDA_kernel", copy_from_QUDA_kernel,out,(FloatIn*) qudaVec.V(), (FloatIn*) NULL); @@ -239,9 +239,9 @@ struct computeRMS{ int x[3] = GET_ID_ZYX(id); #pragma unroll for(int i = 0 ; i < 3 ; i++){ - x[i] += DGC_procPosition[i] * DGC_localL[i]; + x[i] += DGC->procPosition[i] * DGC->localL[i]; x[i] = x[i] >= s[i] ? x[i]-s[i] : s[i] - x[i]; - if(x[i] > DGC_totalL[i]/2) x[i] = DGC_totalL[i] - x[i]; + if(x[i] > DGC->totalL[i]/2) x[i] = DGC->totalL[i] - x[i]; } int r2 = x[0]*x[0] + x[1]*x[1] + x[2]*x[2]; int index_r2 = getIndexElem(r2,list_comp_R2,Nr2); @@ -249,7 +249,7 @@ struct computeRMS{ Float2 e[N_SPINS*N_COLS]; Float2 *w = &(thrust::get<1>(t)); #pragma unroll - for(int i = 0 ; i < N_SPINS*N_COLS; i++) e[i] = *(w+i*DGC_localVolume3D); + for(int i = 0 ; i < N_SPINS*N_COLS; i++) e[i] = *(w+i*DGC->localVolume3D); Float val =0; #pragma unroll for(int i = 0 ; i < N_SPINS*N_COLS ; i++) val += e[i].x*e[i].x + e[i].y*e[i].y; @@ -273,13 +273,13 @@ static void compute_rms(const PLEGMA_Vector3D &vec, std::vector &lis qudaMemset(d_absPsi,0,absPsi.size() * sizeof(Float)); //checkQudaError(); thrust::counting_iterator first(0); - thrust::counting_iterator last = first + HGC_localVolume3D; + thrust::counting_iterator last = first + HGC.localVolume3D; typedef thrust::device_ptr > DpF2; DpF2 y( (Float2*) vec.D_elem()); typedef thrust::tuple,DpF2> tplIntDev2; typedef thrust::zip_iterator zipTplIntDev2; zipTplIntDev2 z1 = thrust::make_zip_iterator(thrust::make_tuple(first,y)); - zipTplIntDev2 z2 = thrust::make_zip_iterator(thrust::make_tuple(last,y+HGC_localVolume3D)); + zipTplIntDev2 z2 = thrust::make_zip_iterator(thrust::make_tuple(last,y+HGC.localVolume3D)); thrust::for_each(z1,z2,computeRMS(sourceposition[0],sourceposition[1],sourceposition[2],listR2.size(),d_listR2,d_absPsi)); qudaMemcpy(absPsi.data(), d_absPsi, absPsi.size() * sizeof(Float), qudaMemcpyDeviceToHost); checkQudaError(); device_free(d_listR2); diff --git a/plegma/CMakeLists.txt b/plegma/CMakeLists.txt index 99544915..199212a1 100644 --- a/plegma/CMakeLists.txt +++ b/plegma/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PLEGMA_LIBS plegma PLEGMAutils ${CMAKE_THREAD_LIBS_INIT} ${QUDA_LIB} /opt/cray/pe/hdf5-parallel/1.12.1.5/gnu/9.1/lib/libhdf5_parallel.so.200 ${MPI_CXX_LIBRARIES} /pfs/lustrep2/projappl/project_462000125/samantao-public/rocm/rocm-5.2.3/hip/lib/libamdhip64.so /pfs/lustrep2/projappl/project_462000125/samantao-public/rocm/rocm-5.2.3/rccl/lib/librccl.so) +set(PLEGMA_LIBS plegma PLEGMAutils ${CMAKE_THREAD_LIBS_INIT} ${QUDA_LIB} ${MPI_CXX_LIBRARIES} ) LIST(APPEND PLEGMA_LIBS ${MPI_CXX_LIBRARIES}) diff --git a/plegma/nucleon_3pt_n_npi.cpp b/plegma/nucleon_3pt_n_npi.cpp index 4b36277a..00260dc0 100644 --- a/plegma/nucleon_3pt_n_npi.cpp +++ b/plegma/nucleon_3pt_n_npi.cpp @@ -1,6 +1,6 @@ #include #include - +#include std::vector runtime; #define TIME(fnc) runtime.push_back(MPI_Wtime()); fnc; \ PLEGMA_printf("TIME for "#fnc" %f sec\n", MPI_Wtime()-runtime.back()); \ @@ -35,7 +35,7 @@ void produceOutput_2pt_packed( PLEGMA_ScattCorrelator source, int *attract_look_up_table){ TIME(source.apply_phase()); TIME(source.apply_sign(diagram_name)); - TIME(source.applyBoundaryConditions( true, n_coherent_source, attract_look_up_table ); + TIME(source.applyBoundaryConditions( true, n_coherent_source, attract_look_up_table )); TIME(source.normalize_nstoch(n_stochastic_samples)); TIME(source.writeHDF5( outputFilename )); @@ -46,11 +46,12 @@ void produceOutput_3pt( PLEGMA_ScattCorrelator source, std::string outputFilename, std::string diagram_name, int n_stochastic_samples, - int source_sink_separation, - int max_source_sink_separation){ + int n_coherent_source, + int *attract_look_up_table, + int source_sink_separation){ TIME(source.apply_phase()); TIME(source.apply_sign(diagram_name)); - TIME(source.applyBoundaryConditions_3pt( true, source_sink_separation, max_source_sink_separation )); + TIME(source.applyBoundaryConditions_3pt( true, n_coherent_source, attract_look_up_table, source_sink_separation )); TIME(source.normalize_nstoch(n_stochastic_samples)); TIME(source.writeHDF5( outputFilename )); @@ -82,12 +83,13 @@ void produceOutput_2pt_packed( PLEGMA_ScattCorrelator source, void produceOutput_3pt( PLEGMA_ScattCorrelator source, std::string outputFilename, std::string diagram_name, - int source_sink_separation, - int max_source_sink_separation + int n_coherent_source, + int *attract_look_up_table, + int source_sink_separation ){ TIME(source.apply_phase()); TIME(source.apply_sign(diagram_name)); - TIME(source.applyBoundaryConditions_3pt( true, source_sink_separation, max_source_sink_separation )); + TIME(source.applyBoundaryConditions_3pt( true,n_coherent_source, attract_look_up_table, source_sink_separation )); TIME(source.writeHDF5( outputFilename )); } @@ -123,19 +125,48 @@ int main(int argc, char **argv) { int n_stochastic_samples; int max_source_sink_separations; + int dotwopoint; + int readStochSamples; + //setVerbosity(QUDA_DEBUG_VERBOSE); + + HGC.options->set("confnumber", "Integer determining the index of the gauge configuration", verbosity, confnumber_int); + HGC.options->set("maxSourceSinkSeparations", "Maximal source sink separations", verbosity, max_source_sink_separations); + HGC.options->set("outdiagramPrefix", "Prefix of the resulting diagrams", verbosity, outdiagramPrefix); + HGC.options->set("nstochSamples", "Number of stochastic samples", verbosity, n_stochastic_samples); + HGC.options->set("seed1", "Seed for initialization of stochastic sources for the oet", verbosity, rand_seed1); + HGC.options->set("seed2", "Seed for intiialization of stochastic sources", verbosity, rand_seed2); + HGC.options->set("dotwopoint", "Doing also the twopoint functions", verbosity,dotwopoint); + HGC.options->set("readStochSamples", "Flag for switching read/building stochastic propagators", verbosity, readStochSamples); - HGC_options->set("confnumber", "Integer determining the index of the gauge configuration", verbosity, confnumber_int); - HGC_options->set("maxSourceSinkSeparations", "Maximal source sink separations", verbosity, max_source_sink_separations); - HGC_options->set("outdiagramPrefix", "Prefix of the resulting diagrams", verbosity, outdiagramPrefix); - HGC_options->set("nstochSamples", "Number of stochastic samples", verbosity, n_stochastic_samples); - HGC_options->set("seed1", "Seed for initialization of stochastic sources for the oet", verbosity, rand_seed1); - HGC_options->set("seed2", "Seed for intiialization of stochastic sources", verbosity, rand_seed2); //=========================================================================================================// initializePLEGMA(); - + /* + FILE *fid; + LimeWriter *limewriter = (LimeWriter*)NULL; + //if(unloadFromDev) unload(); + if(comm_rank() == 0){ + fid=fopen("stochastic_source0.lime","a"); + if(fid==NULL) PLEGMA_error("Error opening file for writing: stochastic_source0.lime\n"); + else printf("Opening was fine\n"); + limewriter = limeCreateWriter(fid); + if(limewriter==(LimeWriter*)NULL) PLEGMA_error("Could not create limeWriter"); + std::string xlf_message = getDateAndTime(); // More xlf-info can be added + write_lime_header(limewriter,"xlf-info",xlf_message,1,1); + std::ostringstream oss; + oss << lime_version_header() << "" << "PLEGMA_Vector" << "\n" << "" << 32 << "\n"; + oss << "" << 12 << "\n"; + std::vector xyzt = {"x","y","z","t"}; + for(int i = 0 ; i < N_DIMS; i++) oss << "" << HGC.totalL[i] << "\n"; + oss << ""; + write_lime_header(limewriter,"ildg-format",oss.str(),1,0); + } +// write_binary_to_lime(filename,fid,limewriter,h_elem,field_length); + limeDestroyWriter(limewriter); + + exit(1);*/ { PLEGMA_Gauge smearedGauge(BOTH); @@ -226,18 +257,18 @@ int main(int argc, char **argv) { - int parallel_sources=HGC_totalL[3]/max_source_sink_separations; + int parallel_sources=HGC.totalL[3]/max_source_sink_separations; std::vector lookuptable_UP; std::vector lookuptable_DN; - for (int i=0; i(HOST)); - stochastic_propagator_2pt_SS.push_back(new PLEGMA_Vector(HOST)); - vectorSource_stochastic.stochastic_Z(nroots); - vectorSource_stochastic.unload(); - stochastic_sources[i]->copy(vectorSource_stochastic,HOST); - - PLEGMA_printf("Save the stochastic source for sample %d\n",i); - std::string nstoch=std::to_string(i); - vectorSource_stochastic.writeHDF5("stochastic_source"+nstoch); - - vectorSource_stochastic.load(); - - + if (dotwopoint==1){ + stochastic_propagator_2pt_SS.push_back(new PLEGMA_Vector(HOST)); + } + if (readStochSamples==0){ + vectorSource_stochastic.stochastic_Z(nroots); + vectorSource_stochastic.unload(); + //PLEGMA_Vector vectorRead(BOTH); + //vectorRead.readFile("stochastic_source0.lime",LIME_FORMAT); + //vectorRead.load(); + //stochastic_sources[i]->copy(vectorRead,HOST); + stochastic_sources[i]->copy(vectorSource_stochastic,HOST); + vectorSource_stochastic.writeLIME("globalTfulltimedilution_source_nstoch"+std::to_string(i)+"_"+confnumber); + //PLEGMA_printf("Save the stochastic source for sample %d\n",i); + //std::string nstoch=std::to_string(i); + //vectorSource_stochastic.writeHDF5("stochastic_source"+nstoch); + vectorSource_stochastic.load(); + } + else{ + std::string inputfilename="globalTfulltimedilution_source_nstoch"+std::to_string(i)+"_"+confnumber; + PLEGMA_printf("Read stochastic source from: %s\n",inputfilename.c_str()); + PLEGMA_Vector vectorRead(BOTH); + vectorRead.readFile(inputfilename,LIME_FORMAT); + stochastic_sources[i]->copy(vectorRead,HOST); + inputfilename="globalTfulltimedilution_propagator_nstoch"+std::to_string(i)+"_"+confnumber; + PLEGMA_Vector vectorFloat(BOTH); + PLEGMA_printf("Read propagator from: %s\n",inputfilename.c_str()); + vectorFloat.readFile(inputfilename,LIME_FORMAT); + stochastic_propagator_2pt_SS[i]->copy(vectorFloat,HOST); + } } /****************************************************** @@ -331,50 +379,59 @@ int main(int argc, char **argv) { * ******************************************************/ - for (int i=0; i vectorInOut, vectorAuxD1,vectorAuxD2; + if ((dotwopoint==1) && (readStochSamples==0)){ + for (int i=0; i vectorInOut, vectorAuxD1,vectorAuxD2; + + vectorAuxD1.copy(*stochastic_sources[i], HOST); + vectorAuxD1.load(); + + //Step(3) Smearing all the time slice + TIME(vectorAuxD2.gaussianSmearing(vectorAuxD1, smearedGauge, nsmearGauss, alphaGauss )); + + //Step(4) We rotate the source to the physical basis + TIME(vectorAuxD1.rotateToPhysicalBasis(vectorAuxD2,+1)); + + //In vectorAuxD2 we store the results for the inversion + vectorAuxD2.scale(0.0); + + PLEGMA_printf("#piNdiagrams: Full time dilution is turned on\n"); + for (int timeidx=0; timeidx< HGC.totalL[DIM_T]; ++timeidx){ + //Step(5) pick out a particular timeslice from the source + // + //PLEGMA_Vector3D vec3D; + //vec3D.absorb(vectorAuxD1, timeidx); + //vectorInOut.absorb(vec3D, timeidx); + //vectorInOut.copy(vectorAuxD1); + vectorInOut.absorbTimeslice(vectorAuxD1, timeidx); + //Step(6) Solve + TIME(solver.solve(vectorInOut, vectorInOut)); + //Step(7) absorbing the particular timeslice to a 4d vector + //vec3D.absorb(vectorInOut, timeidx); + //vectorAuxD2.absorb(vec3D, timeidx, false); + vectorAuxD2.absorbTimeslice(vectorInOut, timeidx, false); + } - vectorAuxD1.copy(*stochastic_sources[i], HOST); - vectorAuxD1.load(); + //Step(6) We rotate back the propagator to the physical basis + TIME(vectorAuxD1.rotateToPhysicalBasis(vectorAuxD2,+1)); - //Step(3) Smearing all the time slice - TIME(vectorAuxD2.gaussianSmearing(vectorAuxD1, smearedGauge, nsmearGauss, alphaGauss )); + //Step(7) Smearing all the time slice in the propagator + TIME(vectorAuxD2.gaussianSmearing(vectorAuxD1, smearedGauge, nsmearGauss, alphaGauss )); - //Step(4) We rotate the source to the physical basis - TIME(vectorAuxD1.rotateToPhysicalBasis(vectorAuxD2,+1)); + //Step(8) Save the propagator to the disk + { + PLEGMA_Vector vectorAuxF; + vectorAuxF.copy(vectorAuxD2); + vectorAuxF.unload(); + vectorAuxF.writeLIME("globalTfulltimedilution_propagator_nstoch"+std::to_string(i)+"_"+confnumber); + } - //In vectorAuxD2 we store the results for the inversion - vectorAuxD2.scale(0.0); + //Step(9) Save the propagator to the host memory + vectorAuxD2.unload(); + stochastic_propagator_2pt_SS[i]->copy(vectorAuxD2,HOST); + vectorAuxD2.load(); - PLEGMA_printf("#piNdiagrams: Full time dilution is turned on\n"); - for (int timeidx=0; timeidx< HGC_totalL[DIM_T]; ++timeidx){ - //Step(5) pick out a particular timeslice from the source - vectorInOut.absorbTimeslice(vectorAuxD1, timeidx); - //Step(6) Solve - TIME(solver.solve(vectorInOut, vectorInOut)); - //Step(7) absorbing the particular timeslice to a 4d vector - vectorAuxD2.absorbTimeslice(vectorInOut, timeidx, false); } - - //Step(6) We rotate back the propagator to the physical basis - TIME(vectorAuxD1.rotateToPhysicalBasis(vectorAuxD2,+1)); - - //Step(7) Smearing all the time slice in the propagator - TIME(vectorAuxD2.gaussianSmearing(vectorAuxD1, smearedGauge, nsmearGauss, alphaGauss )); - - //Step(8) Save the propagator to the disk - { - PLEGMA_Vector vectorAuxF; - vectorAuxF.copy(vectorAuxD2); - vectorAuxF.unload(); - vectorAuxF.writeLIME("globalTfulltimedilution_propagator_nstoch"+std::to_string(i)+"_"+confnumber); - } - - //Step(9) Save the propagator to the host memory - vectorAuxD2.unload(); - stochastic_propagator_2pt_SS[i]->copy(vectorAuxD2,HOST); - vectorAuxD2.load(); - } @@ -391,9 +448,8 @@ int main(int argc, char **argv) { for (int k=0; k smearedGauge3D; smearedGauge3D.absorb(smearedGauge, timeSlice ); for(int i=0; i< n_stochastic_samples; ++i) { @@ -426,9 +482,9 @@ int main(int argc, char **argv) { //TIME(vectorInOut.gaussianSmearing(vectorAuxD1, smearedGauge, nsmearGauss, alphaGauss )); vectorAuxD1.unload(); - PLEGMA_printf("Save the stochastic source for sample %d\n",i); - std::string nstoch=std::to_string(i); - vectorAuxD1.writeHDF5("stochastic_propagators_UP"+nstoch+"_t"+std::to_string(timeSlice)); + //PLEGMA_printf("Save the stochastic source for sample %d\n",i); + //std::string nstoch=std::to_string(i); + //vectorAuxD1.writeHDF5("stochastic_propagators_UP"+nstoch+"_t"+std::to_string(timeSlice)); //writeHDF5(outfilename) stochastic_propags_UP_SL.push_back(new PLEGMA_Vector(HOST)); @@ -455,8 +511,8 @@ int main(int argc, char **argv) { site& source = sourcePositions[isource]; for (int k=0; k smearedGauge3D; smearedGauge3D.absorb(smearedGauge, timeSlice ); for(int i=0; i< n_stochastic_samples; ++i) { @@ -500,7 +556,7 @@ int main(int argc, char **argv) { vectorAuxD1.load(); } - //lookuptable[(source[3]+tSinks[k]+l*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]]=isource*tSinks.size()*parallel_sources+k*parallel_sources+l; + //lookuptable[(source[3]+tSinks[k]+l*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]]=isource*tSinks.size()*parallel_sources+k*parallel_sources+l; lookuptable_DN[timeSlice]=(countindex-1)/n_stochastic_samples; } } @@ -548,9 +604,11 @@ int main(int argc, char **argv) { //double tmp=vector1.norm(); //PLEGMA_printf("Norm of source location %d is %e\n",source_location[3],tmp); TIME(vector2.gaussianSmearing(vector1, smearedGauge3D, nSmear, alphaGauss)); - vectorInOut.absorb(vector2,source_location[DIM_T]); } + //vectorInOut.unload(); + //vectorInOut.writeHDF5("testPointSourceSmeared"); + //vectorInOut.load(); // Inverting PLEGMA_printf("Going to invert %s for component %d\n", fl==LIGHT ? "LIGHT" : (fl == STRANGE ? "STRANGE" : "CHARM"), isc); @@ -596,7 +654,7 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel < parallel_sources;++i_source_parallel){ for (int sink=0; sink propDN_SL; //site source_local = sourcePositions[isource]; - //source_local[3]=(sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + //source_local[3]=(sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; site source_local; source_local[0] = sourcePositions[isource][0]; source_local[1] = sourcePositions[isource][1]; source_local[2] = sourcePositions[isource][2]; - source_local[3] = (sourcePositions[isource][DIM_T]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + source_local[3] = (sourcePositions[isource][DIM_T]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; site source_localPtSinkMtSource; source_localPtSinkMtSource[0] = sourcePositions[isource][0]; source_localPtSinkMtSource[1] = sourcePositions[isource][1]; source_localPtSinkMtSource[2] = sourcePositions[isource][2]; - source_localPtSinkMtSource[3] = (sourcePositions[isource][DIM_T]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + source_localPtSinkMtSource[3] = (sourcePositions[isource][DIM_T]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; site source_local_reduction=site({0,0,0,sourcePositions[isource][DIM_T]}); - source_local_reduction[3]=(sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + source_local_reduction[3]=(sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; PLEGMA_ScattCorrelator corrNP(source_local, list_mpf1_twopt); TIME(corrNP.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_sink_nucleon,"NP")); - PLEGMA_ScattCorrelator corrN0(source_local, list_mpf1_twopt); - TIME(corrN0.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_sink_nucleon,"N0")); +// PLEGMA_ScattCorrelator corrN0(source_local, list_mpf1_twopt); +// TIME(corrN0.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_sink_nucleon,"N0")); // If twop_filename exists we hold the computation of the light props TIME(computePropagator(propUP_SS, propUP_SL, mu_ud, LIGHT, nsmearGauss, source_local, false)); TIME(computePropagator(propDN_SS, propDN_SL, -mu_ud, LIGHT, nsmearGauss, source_local, false)); - //Computing T reductions+recombination - { - PLEGMA_ScattCorrelator reductionsT1N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); - PLEGMA_ScattCorrelator reductionsT2N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); - //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) - TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propUP_SS, propDN_SS, propUP_SS)); - //PLEGMA_printf("Nucleon T2 reduction\n"); - TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propUP_SS, propDN_SS, propUP_SS)); - //PLEGMA_printf("Nucleon T2 reduction ready\n"); - TIME(corrNP.N_diagrams( reductionsT1N, reductionsT2N )); - //PLEGMA_printf("Nucleon diagram ready\n"); - - } + if (dotwopoint==1){ - //Computing T reductions+recombination - { - PLEGMA_ScattCorrelator reductionsT1N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); - PLEGMA_ScattCorrelator reductionsT2N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); - //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) - TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propDN_SS, propUP_SS, propDN_SS)); - //PLEGMA_printf("Nucleon T2 reduction\n"); - TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propDN_SS, propUP_SS, propDN_SS)); - //PLEGMA_printf("Nucleon T2 reduction ready\n"); - TIME(corrN0.N_diagrams( reductionsT1N, reductionsT2N )); - //PLEGMA_printf("Nucleon diagram ready\n"); - } + //Computing T reductions+recombination + { + PLEGMA_ScattCorrelator reductionsT1N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); + PLEGMA_ScattCorrelator reductionsT2N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); + //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) + TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propUP_SS, propDN_SS, propUP_SS)); + //PLEGMA_printf("Nucleon T2 reduction\n"); + TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propUP_SS, propDN_SS, propUP_SS)); + //PLEGMA_printf("Nucleon T2 reduction ready\n"); + TIME(corrNP.N_diagrams( reductionsT1N, reductionsT2N )); + //PLEGMA_printf("Nucleon diagram ready\n"); - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_N"; - TIME( corrN0.apply_phase()); - TIME( corrN0.apply_sign("N")); - TIME( corrN0.applyBoundaryConditions( true )); - TIME( corrN0.writeHDF5(outfilename)); + } - TIME( corrNP.apply_phase() ); - TIME( corrNP.apply_sign("N") ); - TIME( corrNP.applyBoundaryConditions( true ) ); - TIME( corrNP.writeHDF5(outfilename) ); + //Computing T reductions+recombination + /* + { + PLEGMA_ScattCorrelator reductionsT1N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); + PLEGMA_ScattCorrelator reductionsT2N(source_local_reduction, sourcemomentumList_twopt.uniq_p(1)); + //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) + TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propDN_SS, propUP_SS, propDN_SS)); + //PLEGMA_printf("Nucleon T2 reduction\n"); + TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propDN_SS, propUP_SS, propDN_SS)); + //PLEGMA_printf("Nucleon T2 reduction ready\n"); + TIME(corrN0.N_diagrams( reductionsT1N, reductionsT2N )); + //PLEGMA_printf("Nucleon diagram ready\n"); + }*/ + + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_N"; + /*TIME( corrN0.apply_phase()); + TIME( corrN0.apply_sign("N")); + TIME( corrN0.applyBoundaryConditions( true )); + TIME( corrN0.writeHDF5(outfilename));*/ + + TIME( corrNP.apply_phase() ); + TIME( corrNP.apply_sign("N") ); + TIME( corrNP.applyBoundaryConditions( true ) ); + TIME( corrNP.writeHDF5(outfilename) ); + } - { + /*{ PLEGMA_printf("Save propagator for the up and dn quark\n"); PLEGMA_Vector vectorAuxPrint(BOTH); for(int isc = 0 ; isc < 12 ; isc++){ @@ -684,51 +746,67 @@ int main(int argc, char **argv) { vectorAuxPrint.unload(); vectorAuxPrint.writeHDF5("propUPSS_"+spin+"_c"+col+"_t_"+std::to_string(source_local[3])); } - } + for(int isc = 0 ; isc < 12 ; isc++){ + std::string spin=std::to_string(isc/3); + std::string col=std::to_string(isc%3); + + vectorAuxPrint.absorb(propUP_SL,isc/3,isc%3); + vectorAuxPrint.unload(); + vectorAuxPrint.writeHDF5("propUPSL_"+spin+"_c"+col+"_t_"+std::to_string(source_local[3])); + } + + }*/ propUP_SS_packed.pack_propagator_from_source_to_sink(propUP_SS, source_localPtSinkMtSource[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); propDN_SS_packed.pack_propagator_from_source_to_sink(propDN_SS, source_localPtSinkMtSource[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); -// stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(j+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, j == 0 ? true : false); +// stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(j+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, j == 0 ? true : false); propUP_SL_packed.pack_propagator_from_source_to_sink(propUP_SL, source_localPtSinkMtSource[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); propDN_SL_packed.pack_propagator_from_source_to_sink(propDN_SL, source_localPtSinkMtSource[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } //parallel source position + PLEGMA_ScattCorrelator corrNP_packed(source, list_mpf1_twopt); TIME(corrNP_packed.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_sink_nucleon,"NP")); - { - PLEGMA_ScattCorrelator reductionsT1N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); - PLEGMA_ScattCorrelator reductionsT2N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); - //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) - TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propUP_SS_packed)); - //PLEGMA_printf("Nucleon T2 reduction\n"); - TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propUP_SS_packed)); - //PLEGMA_printf("Nucleon T2 reduction ready\n"); - TIME(corrNP_packed.N_diagrams( reductionsT1N, reductionsT2N )); - //PLEGMA_printf("Nucleon diagram ready\n"); + if (dotwopoint==1){ + + { + PLEGMA_ScattCorrelator reductionsT1N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); + PLEGMA_ScattCorrelator reductionsT2N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); + //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) + TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propUP_SS_packed)); + //PLEGMA_printf("Nucleon T2 reduction\n"); + TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propUP_SS_packed)); + //PLEGMA_printf("Nucleon T2 reduction ready\n"); + TIME(corrNP_packed.N_diagrams( reductionsT1N, reductionsT2N )); + //PLEGMA_printf("Nucleon diagram ready\n"); - } + } + } PLEGMA_ScattCorrelator corrN0_packed(source, list_mpf1_twopt); TIME(corrN0_packed.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_sink_nucleon,"N0")); - { - PLEGMA_ScattCorrelator reductionsT1N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); - PLEGMA_ScattCorrelator reductionsT2N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); - //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) - TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propDN_SS_packed, propUP_SS_packed, propDN_SS_packed)); - //PLEGMA_printf("Nucleon T2 reduction\n"); - TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propDN_SS_packed, propUP_SS_packed, propDN_SS_packed)); - //PLEGMA_printf("Nucleon T2 reduction ready\n"); - TIME(corrN0_packed.N_diagrams( reductionsT1N, reductionsT2N )); - //PLEGMA_printf("Nucleon diagram ready\n"); - } + if (dotwopoint==1){ -/* + { + PLEGMA_ScattCorrelator reductionsT1N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); + PLEGMA_ScattCorrelator reductionsT2N(source_reduction, sourcemomentumList_twopt.uniq_p(1)); + //First we compute N+ (proton) (we need for M diagram (N+p+)) and for spin half (N+ pi_0) + TIME(reductionsT1N.T1(glist_source_nucleon, glist_sink_nucleon, propDN_SS_packed, propUP_SS_packed, propDN_SS_packed)); + //PLEGMA_printf("Nucleon T2 reduction\n"); + TIME(reductionsT2N.T2(glist_source_nucleon, glist_sink_nucleon, propDN_SS_packed, propUP_SS_packed, propDN_SS_packed)); + //PLEGMA_printf("Nucleon T2 reduction ready\n"); + TIME(corrN0_packed.N_diagrams( reductionsT1N, reductionsT2N )); + //PLEGMA_printf("Nucleon diagram ready\n"); + } + } + + /* { PLEGMA_printf("Save propagator for the up and dn quark\n"); PLEGMA_Vector vectorAuxPrint(BOTH); @@ -790,13 +868,12 @@ int main(int argc, char **argv) { //phi goes to V2 reduction and xi goes to V3 reduction std::vector*> reductions_UU_V2_GAMMAF1D_U;//implemented - std::vector*> reductions_UU_V2_GAMMAF1D_U_2pt;//implemented + std::vector*> reductions_DD_V2_GAMMAF1U_D_2pt;//implemented std::vector*> reductions_UU_V4_GAMMAF1U_D;//implemented - std::vector*> reductions_UU_V4_GAMMAF1U_D_2pt;//implemented + std::vector*> reductions_DD_V4_GAMMAF1U_D_2pt;//implemented std::vector*> reductions_UU_V3_GAMMAF2U;//implemented - std::vector*> reductions_UU_V3_GAMMAF2U_2pt;//implemented //Here the prefix DD means that reduction is based phi*g5 and xi*g5 @@ -804,22 +881,18 @@ int main(int argc, char **argv) { //phi goes to V3 reduction and xi goes to V2 reduction std::vector*> reductions_DD_V3_GAMMAF2D;//implemented - std::vector*> reductions_DD_V3_GAMMAF2D_2pt;//implemented + std::vector*> reductions_DD_V3_GAMMAF2U_2pt;//implemented std::vector*> reductions_DD_V2_GAMMAF1U_U;//implemented - std::vector*> reductions_DD_V2_GAMMAF1U_U_2pt;//implemented for(int i=0; i< n_stochastic_samples; ++i) { - reductions_UU_V2_GAMMAF1D_U_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf1_twopt)); - reductions_UU_V4_GAMMAF1U_D_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf1_twopt)); - - reductions_DD_V2_GAMMAF1U_U_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf1_twopt)); - - - reductions_UU_V3_GAMMAF2U_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf2_twopt)); - reductions_DD_V3_GAMMAF2D_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf2_twopt)); + if (dotwopoint==1){ + reductions_DD_V2_GAMMAF1U_D_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf1_twopt)); + reductions_DD_V4_GAMMAF1U_D_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf1_twopt)); + reductions_DD_V3_GAMMAF2U_2pt.push_back(new PLEGMA_ScattCorrelator(source_reduction, list_mpf2_twopt)); + } for (int k=0; k< tSinks.size(); ++k){ @@ -841,78 +914,79 @@ int main(int argc, char **argv) { } } + for (int i_sample=0; i_sample stochastic_source; stochastic_source.copy(*stochastic_sources[i_sample],HOST); stochastic_source.load(); + /*if (i_sample==0){ + stochastic_source.unload(); + stochastic_source.writeHDF5("stochastic_vector_source.h5"); + }*/ for (int k=0; k< tSinks.size();++k){ int tsinkMtsource = tSinks[k]; - if(tsinkMtsource >= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); + + PLEGMA_Propagator propUPpacked_to_sink; + PLEGMA_Propagator propDNpacked_to_sink; + + for (int i_source_parallel=0; i_source_parallel stochastic_source_packed; - for (int i_source_parallel=0; i_source_parallel propUPpacked_to_sink; - PLEGMA_Propagator propDNpacked_to_sink; - - for (int i_source_parallel=0; i_source_parallelV2( stochastic_source_packed, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, false)); + TIME(reductions_UU_V2_GAMMAF1D_U[i_sample*tSinks.size()+k]->V2( stochastic_source_packed, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, true)); - if (k==0){ + if (k==0 && (dotwopoint==1)){ PLEGMA_Vector stoch_piece; stoch_piece.unload(); - stoch_piece.copy(*stochastic_propagator_2pt_SS[i_sample], HOST); + stoch_piece.copy(*stochastic_sources[i_sample],HOST); stoch_piece.load(); - TIME(reductions_UU_V2_GAMMAF1D_U_2pt[i_sample]->V2( stoch_piece, glist_sink_nucleon, propDN_SS_packed, propUP_SS_packed, false)); - - TIME(reductions_UU_V4_GAMMAF1U_D_2pt[i_sample]->V4( stoch_piece, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, false)); - - stoch_piece.apply_gamma5(); - TIME(reductions_DD_V3_GAMMAF2D_2pt[i_sample]->V3( stoch_piece, glist_sink_meson, propDN_SS_packed, true)); + TIME(reductions_DD_V2_GAMMAF1U_D_2pt[i_sample]->V2( stoch_piece, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, true)); - stoch_piece.unload(); - stoch_piece.copy(*stochastic_sources[i_sample], HOST); - stoch_piece.load(); + TIME(reductions_DD_V4_GAMMAF1U_D_2pt[i_sample]->V4( stoch_piece, glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, true)); - TIME(reductions_UU_V3_GAMMAF2U_2pt[i_sample]->V3( stoch_piece, glist_sink_meson, propUP_SS_packed, true)); - - stoch_piece.apply_gamma5(); - TIME(reductions_DD_V2_GAMMAF1U_U_2pt[i_sample]->V2( stoch_piece, glist_sink_nucleon, propUP_SS_packed, propUP_SS_packed, false)); + stoch_piece.unload(); + stoch_piece.copy(*stochastic_propagator_2pt_SS[i_sample],HOST); + stoch_piece.load(); + stoch_piece.apply_gamma5(); + stoch_piece.apply_gamma5(); + TIME(reductions_DD_V3_GAMMAF2U_2pt[i_sample]->V3( stoch_piece, glist_sink_meson, propDN_SS_packed, true)); } //B4,B6 //B10,B12 - TIME(reductions_UU_V4_GAMMAF1U_D[i_sample*tSinks.size()+k]->V4( stochastic_source_packed, glist_sink_nucleon, propUPpacked_to_sink, propDNpacked_to_sink, false)); + TIME(reductions_UU_V4_GAMMAF1U_D[i_sample*tSinks.size()+k]->V4( stochastic_source_packed, glist_sink_nucleon, propUPpacked_to_sink, propDNpacked_to_sink, true)); //W5,W6,W7,W8 //W9,W10,W11,W12,W17,W18,W19,W20 @@ -923,12 +997,12 @@ int main(int argc, char **argv) { maxinsertion_local[0] = sourcePositions[isource][0]; maxinsertion_local[1] = sourcePositions[isource][1]; maxinsertion_local[2] = sourcePositions[isource][2]; - maxinsertion_local[3] = (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + maxinsertion_local[3] = (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; site sink_local; sink_local[0] = sourcePositions[isource][0]; sink_local[1] = sourcePositions[isource][1]; sink_local[2] = sourcePositions[isource][2]; - sink_local[3] = (source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + sink_local[3] = (source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; temporary.copy(*stochastic_propags_DN_SL[lookuptable_DN[sink_local[3]]*n_stochastic_samples+i_sample],HOST); temporary.load(); @@ -951,12 +1025,12 @@ int main(int argc, char **argv) { maxinsertion_local[0] = sourcePositions[isource][0]; maxinsertion_local[1] = sourcePositions[isource][1]; maxinsertion_local[2] = sourcePositions[isource][2]; - maxinsertion_local[3] = (sourcePositions[isource][DIM_T]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + maxinsertion_local[3] = (sourcePositions[isource][DIM_T]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; site sink_local; sink_local[0] = sourcePositions[isource][0]; sink_local[1] = sourcePositions[isource][1]; sink_local[2] = sourcePositions[isource][2]; - sink_local[3] = (sourcePositions[isource][DIM_T]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + sink_local[3] = (sourcePositions[isource][DIM_T]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; temporary.unload(); temporary.copy(*stochastic_propags_UP_SL[lookuptable_UP[sink_local[3]]*n_stochastic_samples+i_sample],HOST); @@ -980,13 +1054,13 @@ int main(int argc, char **argv) { //B7,B8 //B1,B2 - TIME(reductions_DD_V2_GAMMAF1U_U[i_sample*tSinks.size()+k]->V2( stochastic_source_packed, glist_sink_nucleon, propUPpacked_to_sink, propUPpacked_to_sink, false)); + TIME(reductions_DD_V2_GAMMAF1U_U[i_sample*tSinks.size()+k]->V2( stochastic_source_packed, glist_sink_nucleon, propUPpacked_to_sink, propUPpacked_to_sink, true)); } //end of for source sink separations } //end of for stochastic samples vectorStoc_source_oet.stochastic_Z(nroots); - PLEGMA_printf("DONE stochastic factors\n"); + //PLEGMA_printf("DONE stochastic factors\n"); #if 1 @@ -1007,15 +1081,15 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel vectortmp1; @@ -1082,7 +1156,7 @@ int main(int argc, char **argv) { //stochastic_oet_prop_u_zero_mom_SS.load(); - PLEGMA_printf("DONE OET zero mom up\n"); + //PLEGMA_printf("DONE OET zero mom up\n"); //Doing for -mu for the DN propagator spin dilution oet if(mu>0) { @@ -1093,15 +1167,15 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel vectortmp1; PLEGMA_Vector vectortmp2; @@ -1163,7 +1237,7 @@ int main(int argc, char **argv) { //stochastic_oet_prop_d_zero_mom_SS.load(); - PLEGMA_printf("DONE OET zero mom dn\n"); + //PLEGMA_printf("DONE OET zero mom dn\n"); #endif /****************************************************** @@ -1224,15 +1298,15 @@ int main(int argc, char **argv) { PLEGMA_Propagator propUPpacked_to_sink; PLEGMA_Propagator propDNpacked_to_sink; int tsinkMtsource = tSinks[k]; - if(tsinkMtsource >= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); for (int i_source_parallel=0; i_source_parallelV2( st_oet_u_zeropacked_to_sink, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, true)); + //TIME(reductionsV2_diluted_STOCHU_DN_UP[k]->writeHDF5("redV2_oet")); + TIME(reductionsV2_diluted_STOCHD_UP_UP[k]->V2( st_oet_d_zeropacked_to_sink, glist_sink_nucleon, propUPpacked_to_sink, propUPpacked_to_sink, true)); + TIME(reductionsV4_diluted_STOCHU_DN_UP[k]->V4( st_oet_u_zeropacked_to_sink, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, true)); - TIME(reductionsV2_diluted_STOCHU_DN_UP[k]->V2( st_oet_u_zeropacked_to_sink, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, false)); - TIME(reductionsV2_diluted_STOCHD_UP_UP[k]->V2( st_oet_d_zeropacked_to_sink, glist_sink_nucleon, propUPpacked_to_sink, propUPpacked_to_sink, false)); - TIME(reductionsV4_diluted_STOCHU_DN_UP[k]->V4( st_oet_u_zeropacked_to_sink, glist_sink_nucleon, propDNpacked_to_sink, propUPpacked_to_sink, false)); - - if (k==0){ + if (k==0 && (dotwopoint==1)){ for (int i_source_parallel=0; i_source_parallel reductionsV2(source_reduction, list_mpf1_threept); PLEGMA_ScattCorrelator reductionsV2_2pt(source_reduction, list_mpf1_twopt); @@ -1331,7 +1403,7 @@ int main(int argc, char **argv) { std::vector> mpi2_filt ; mpi2_filt.assign(mptot_filt.size(),momentum_i2); - PLEGMA_printf("mptot_filt.size() %d\n",mptot_filt.size()); + //PLEGMA_printf("mptot_filt.size() %d\n",mptot_filt.size()); momList list_mpi2ptot(2,{mpi2_filt,mptot_filt},{1,}); PLEGMA_ScattCorrelator corrM( source, filtered_sourcemomentumList_2pt); @@ -1350,7 +1422,7 @@ int main(int argc, char **argv) { PLEGMA_Propagator propTS_SS_packed; PLEGMA_Propagator propTS_SL_packed; - +#if 0 for (int i_source_parallel=0; i_source_parallel < parallel_sources;++i_source_parallel){ PLEGMA_Propagator propTS_SS; @@ -1374,15 +1446,16 @@ int main(int argc, char **argv) { PLEGMA_Vector3D vector1, vector2; vectorAuxF.absorb(propUP_SS_packed, isc/3, isc%3); vectorAuxD.copy(vectorAuxF); - vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); PLEGMA_Gauge3D smearedGauge3D; - smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); + + vector1.mulMomentumPhases(momentum_i2,1); TIME(vector2.gaussianSmearing(vector1, smearedGauge3D, nsmearGauss, alphaGauss)); - vector2.mulMomentumPhases(momentum_i2,1); - vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); } - vectorAuxD2.absorbTimeslice(vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], false); + vectorAuxD2.absorbTimeslice(vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], false); //Perform multiplication with glist_insertion[0] vectorAuxD2.apply_gamma_scatt(glist_source_meson[0]); @@ -1405,8 +1478,8 @@ int main(int argc, char **argv) { } - propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); - propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } @@ -1427,24 +1500,27 @@ int main(int argc, char **argv) { corrTproton_protonpizero4.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq24"); - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, propDN_SS_packed)); - TIME(corrTproton_protonpizero1.convertTreductiontoDiagram( reductionsT1, false, true, false )); - TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, propUP_SS_packed)); - TIME(corrTproton_protonpizero2.convertTreductiontoDiagram( reductionsT2, false, false, true )); + if (dotwopoint==1){ - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); - TIME(corrTproton_protonpizero3.convertTreductiontoDiagram( reductionsT1, false, false, false )); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, propDN_SS_packed)); + TIME(corrTproton_protonpizero1.convertTreductiontoDiagram( reductionsT1, false, true, false )); + TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, propUP_SS_packed)); + TIME(corrTproton_protonpizero2.convertTreductiontoDiagram( reductionsT2, false, false, true )); - TIME(reductionsT1.T2(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); - TIME(corrTproton_protonpizero4.convertTreductiontoDiagram( reductionsT1, false, false, true)); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); + TIME(corrTproton_protonpizero3.convertTreductiontoDiagram( reductionsT1, false, false, false )); - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; + TIME(reductionsT1.T2(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); + TIME(corrTproton_protonpizero4.convertTreductiontoDiagram( reductionsT1, false, false, true)); + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; - TIME(produceOutput_2pt_packed(corrTproton_protonpizero1, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_protonpizero2, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_protonpizero3, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_protonpizero4, outfilename, "T", parallel_sources, attract_lookup_table)); + + TIME(produceOutput_2pt_packed(corrTproton_protonpizero1, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_protonpizero2, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_protonpizero3, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_protonpizero4, outfilename, "T", parallel_sources, attract_lookup_table)); + } //creating factors @@ -1481,58 +1557,61 @@ int main(int argc, char **argv) { corrW15_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W15"); corrW16_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W16"); - for (int i_sample=0; i_sample stochastic_piece; - stochastic_piece.unload(); - stochastic_piece.copy(*stochastic_sources[i_sample], HOST); - stochastic_piece.load(); + PLEGMA_Vector stochastic_piece; + stochastic_piece.unload(); + stochastic_piece.copy(*stochastic_sources[i_sample], HOST); + stochastic_piece.load(); - //V3 - TIME(reductionsV3_2pt.V3( stochastic_piece, glist_sink_meson, propTS_SS_packed, true)); + //V3 + TIME(reductionsV3_2pt.V3( stochastic_piece, glist_sink_meson, propTS_SS_packed, true)); - TIME(corrB3_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 3, true)); - TIME(corrB4_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 4, true)); - TIME(corrB5_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 5, true)); - TIME(corrB6_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 6, true)); + TIME(corrB3_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 3, true)); + TIME(corrB4_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 4, true)); + TIME(corrB5_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 5, true)); + TIME(corrB6_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 6, true)); - stochastic_piece.apply_gamma5(); - TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, false));//checked + stochastic_piece.apply_gamma5(); + TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, true));//checked - TIME(corrW13_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 13, true, false)); + TIME(corrW13_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 13, true, false)); - TIME(corrW15_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 15, true, false)); + TIME(corrW15_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 15, true, false)); - TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, false));//checked + TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, true));//checked - TIME(corrW14_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 14, true, false)); + TIME(corrW14_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 14, true, false)); - TIME(corrW16_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 16, true, false)); + TIME(corrW16_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 16, true, false)); - stochastic_piece.unload(); - stochastic_piece.copy(*stochastic_propagator_2pt_SS[i_sample], HOST); - stochastic_piece.load(); - TIME(reductionsV2_2pt.V4( stochastic_piece, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, false));//checked + stochastic_piece.unload(); + stochastic_piece.copy(*stochastic_propagator_2pt_SS[i_sample], HOST); + stochastic_piece.load(); + TIME(reductionsV2_2pt.V4( stochastic_piece, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, true));//checked - TIME(corrW5_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 5, true, false)); + TIME(corrW5_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 5, true, false)); - TIME(corrW7_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 7, true, false)); + TIME(corrW7_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 7, true, false)); - TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, false));//checked + TIME(reductionsV2_2pt.V2( stochastic_piece, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, true));//checked - TIME(corrW6_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 6, true, false)); + TIME(corrW6_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 6, true, false)); - TIME(corrW8_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 8, true, false)); + TIME(corrW8_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 8, true, false)); + } //loop over sample - } + }//loop over doing twopoint for (int k=0; k= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); PLEGMA_ScattCorrelator corrB3(source, filtered_sourcemomentumList); @@ -1584,7 +1663,7 @@ int main(int argc, char **argv) { PLEGMA_Propagator propTS_SS_packed_to_sink; for (int i_source_parallel=0; i_source_parallel< parallel_sources;++i_source_parallel){ - int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propTS_SS_packed_to_sink.pack_propagator_as_sink(propTS_SS_packed, global_fixSinkTime, tsinkMtsource, i_source_parallel==0 ? true : false); } @@ -1593,9 +1672,9 @@ int main(int argc, char **argv) { { for (int j=0; j< parallel_sources;++j){ int tsinkMtsource = tSinks[k]; - if(tsinkMtsource >= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); - int global_fixSinkTime = (tsinkMtsource + source[3]+j*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+j*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propUPpacked_to_sink.pack_propagator_as_sink(propUP_SS_packed, global_fixSinkTime, tsinkMtsource, j==0 ? true : false); propDNpacked_to_sink.pack_propagator_as_sink(propDN_SS_packed, global_fixSinkTime, tsinkMtsource, j==0 ? true : false); @@ -1605,10 +1684,10 @@ int main(int argc, char **argv) { for (int i_sample=0; i_sample temporary; - temporary.copy(*stochastic_propags_DN_SL[lookuptable_DN[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]]*n_stochastic_samples+i_sample],HOST); + temporary.copy(*stochastic_propags_DN_SL[lookuptable_DN[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]]*n_stochastic_samples+i_sample],HOST); temporary.load(); - stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (sourcePositions[isource][3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (sourcePositions[isource][3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } stochastic_propagator_packed.apply_gamma5(); @@ -1625,53 +1704,53 @@ int main(int argc, char **argv) { stochastic_propagator_packed.load(); PLEGMA_Vector stochastic_source_packed; for (int i_source_parallel=0; i_source_parallel vector1, vector2; vectorAuxF.absorb(propDN_SS_packed, isc/3, isc%3); vectorAuxD.copy(vectorAuxF); - vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); PLEGMA_Gauge3D smearedGauge3D; - smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); + + vector1.mulMomentumPhases(momentum_i2,1); TIME(vector2.gaussianSmearing(vector1, smearedGauge3D, nsmearGauss, alphaGauss)); - vector2.mulMomentumPhases(momentum_i2,1); - vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); } - vectorAuxD2.absorbTimeslice(vectorAuxD, (sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], false); + vectorAuxD2.absorbTimeslice(vectorAuxD, (sourcePositions[isource][3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], false); //Perform multiplication with glist_insertion[0] vectorAuxD2.apply_gamma_scatt(glist_source_meson[0]); @@ -1757,78 +1837,66 @@ int main(int argc, char **argv) { - propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); - propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } + if (dotwopoint==1){ + PLEGMA_ScattCorrelator corrTproton_neutronpiplus1(source, list_mpi2ptot); + PLEGMA_ScattCorrelator corrTproton_neutronpiplus2(source, list_mpi2ptot); + PLEGMA_ScattCorrelator corrTproton_neutronpiplus3(source, list_mpi2ptot); + PLEGMA_ScattCorrelator corrTproton_neutronpiplus4(source, list_mpi2ptot); - PLEGMA_ScattCorrelator corrTproton_neutronpiplus1(source, list_mpi2ptot); - PLEGMA_ScattCorrelator corrTproton_neutronpiplus2(source, list_mpi2ptot); - PLEGMA_ScattCorrelator corrTproton_neutronpiplus3(source, list_mpi2ptot); - PLEGMA_ScattCorrelator corrTproton_neutronpiplus4(source, list_mpi2ptot); + corrTproton_neutronpiplus1.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq11"); - corrTproton_neutronpiplus1.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq11"); + corrTproton_neutronpiplus2.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq12"); - corrTproton_neutronpiplus2.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq12"); + corrTproton_neutronpiplus3.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq13"); - corrTproton_neutronpiplus3.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq13"); + corrTproton_neutronpiplus4.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq14"); - corrTproton_neutronpiplus4.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq14"); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, propDN_SS_packed)); + TIME(corrTproton_neutronpiplus1.convertTreductiontoDiagram( reductionsT1, false, true, false )); - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, propDN_SS_packed)); - TIME(corrTproton_neutronpiplus1.convertTreductiontoDiagram( reductionsT1, false, true, false )); + TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, propUP_SS_packed)); + TIME(corrTproton_neutronpiplus2.convertTreductiontoDiagram( reductionsT2, false, false, true )); - TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, propUP_SS_packed)); - TIME(corrTproton_neutronpiplus2.convertTreductiontoDiagram( reductionsT2, false, false, true )); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propDN_SS_packed)); + TIME(corrTproton_neutronpiplus3.convertTreductiontoDiagram( reductionsT1, false, false, false )); - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propDN_SS_packed)); - TIME(corrTproton_neutronpiplus3.convertTreductiontoDiagram( reductionsT1, false, false, false )); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); + TIME(corrTproton_neutronpiplus4.convertTreductiontoDiagram( reductionsT1, false, false, true )); - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propDN_SS_packed, propTS_SS_packed)); - TIME(corrTproton_neutronpiplus4.convertTreductiontoDiagram( reductionsT1, false, false, true )); + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; - - TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus1, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus2, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus3, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus4, outfilename, "T", parallel_sources, attract_lookup_table)); - - PLEGMA_ScattCorrelator corrB9_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrB10_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrB11_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrB12_2pt(source, filtered_sourcemomentumList_2pt); - - PLEGMA_ScattCorrelator corrW17_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW18_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW19_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW20_2pt(source, filtered_sourcemomentumList_2pt); - - PLEGMA_ScattCorrelator corrW21_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW22_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW23_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrW24_2pt(source, filtered_sourcemomentumList_2pt); - - - corrB9_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B9"); - corrB10_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B10"); - corrB11_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B11"); - corrB12_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B12"); + TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus1, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus2, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus3, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_neutronpiplus4, outfilename, "T", parallel_sources, attract_lookup_table)); + } - corrW17_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W17"); - corrW18_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W18"); - corrW19_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W19"); - corrW20_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W20"); + PLEGMA_ScattCorrelator corrB13_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrB14_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrB15_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrB16_2pt(source, filtered_sourcemomentumList_2pt); - corrW21_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W21"); - corrW22_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W22"); - corrW23_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W23"); - corrW24_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W24"); + PLEGMA_ScattCorrelator corrW25_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrW26_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrW27_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrW28_2pt(source, filtered_sourcemomentumList_2pt); + corrB13_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12","B13"); + corrB14_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B14"); + corrB15_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B15"); + corrB16_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "B16"); + corrW25_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W25"); + corrW26_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W26"); + corrW27_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W27"); + corrW28_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "W28"); for (int k=0; k< tSinks.size(); ++k){ @@ -1880,11 +1948,11 @@ int main(int argc, char **argv) { PLEGMA_Propagator propTS_SS_packed_to_sink; { - for (int i_source_parallel=0; i_source_parallel= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); - int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propTS_SS_packed_to_sink.pack_propagator_as_sink(propTS_SS_packed, global_fixSinkTime, tsinkMtsource, i_source_parallel==0 ? true : false); } } @@ -1894,9 +1962,9 @@ int main(int argc, char **argv) { PLEGMA_Propagator propDNpacked_to_sink; for (int j=0; j= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); - int global_fixSinkTime = (tsinkMtsource + source[3]+j*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+j*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propUPpacked_to_sink.pack_propagator_as_sink(propUP_SS_packed, global_fixSinkTime, tsinkMtsource, j==0 ? true : false); propDNpacked_to_sink.pack_propagator_as_sink(propDN_SS_packed, global_fixSinkTime, tsinkMtsource, j==0 ? true : false); } @@ -1904,68 +1972,48 @@ int main(int argc, char **argv) { for (int i_sample=0; i_sample stochastic_propagator_packed; - if (k==0){ - stochastic_propagator_packed.unload(); - stochastic_propagator_packed.copy(*stochastic_sources[i_sample], HOST); - stochastic_propagator_packed.load(); + if (k==0 && (dotwopoint==1)){ +// stochastic_propagator_packed.unload(); +// stochastic_propagator_packed.copy(*stochastic_sources[i_sample], HOST); +// stochastic_propagator_packed.load(); + stochastic_propagator_packed.unload(); + stochastic_propagator_packed.copy(*stochastic_propagator_2pt_SS[i_sample], HOST); + stochastic_propagator_packed.load(); + stochastic_propagator_packed.apply_gamma5(); TIME(reductionsV3_2pt.V3( stochastic_propagator_packed, glist_sink_meson, propTS_SS_packed, true )); - TIME( corrB9_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 9, true, false, false)); - TIME(corrB10_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 10, true, false, false)); - TIME(corrB11_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V2_GAMMAF1D_U_2pt[i_sample], 0, 11, true, false, false)); - TIME(corrB12_2pt.B_diagrams(reductionsV3_2pt, *reductions_UU_V4_GAMMAF1U_D_2pt[i_sample], 0, 12, true, false, false)); - + TIME(corrB13_2pt.B_diagrams(reductionsV3_2pt, *reductions_DD_V4_GAMMAF1U_D_2pt[i_sample], 0, 13, true, false, false)); + TIME(corrB14_2pt.B_diagrams(reductionsV3_2pt, *reductions_DD_V4_GAMMAF1U_D_2pt[i_sample], 0, 14, true, false, false)); + TIME(corrB15_2pt.B_diagrams(reductionsV3_2pt, *reductions_DD_V2_GAMMAF1U_D_2pt[i_sample], 0, 15, true, false, false)); + TIME(corrB16_2pt.B_diagrams(reductionsV3_2pt, *reductions_DD_V2_GAMMAF1U_D_2pt[i_sample], 0, 16, true, false, false)); + stochastic_propagator_packed.unload(); + stochastic_propagator_packed.copy(*stochastic_sources[i_sample], HOST); + stochastic_propagator_packed.load(); stochastic_propagator_packed.apply_gamma5(); - TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, false)); + TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, true)); - TIME(corrW22_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 22, true, false)); - TIME(corrW24_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 24, true, false)); + TIME(corrW27_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 27, true, false)); + TIME(corrW28_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 28, true, false)); - TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, false)); + TIME(reductionsV2_2pt.V4( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propDN_SS_packed, true)); - TIME(corrW21_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 21, true, false)); - TIME(corrW23_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2D_2pt[i_sample], reductionsV2_2pt, 0, 23, true, false)); + TIME(corrW25_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 25, true, false)); + TIME(corrW26_2pt.W_diagrams( *reductions_DD_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 26, true, false)); - stochastic_propagator_packed.unload(); - stochastic_propagator_packed.copy(*stochastic_propagator_2pt_SS[i_sample], HOST); - stochastic_propagator_packed.load(); - - - TIME(reductionsV2_2pt.V4( stochastic_propagator_packed, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, false)); - TIME(corrW17_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 17, true, false)); - TIME(corrW19_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 19, true, false)); - - TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propDN_SS_packed, propTS_SS_packed, false)); - TIME(corrW18_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 18, true, false)); - TIME(corrW20_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 20, true, false)); } for (int i_source_parallel=0; i_source_parallel temporary; - temporary.copy(*stochastic_propags_DN_SL[lookuptable_DN[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]]*n_stochastic_samples+i_sample],HOST); + temporary.copy(*stochastic_propags_DN_SL[lookuptable_DN[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]]*n_stochastic_samples+i_sample],HOST); temporary.load(); - stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } stochastic_propagator_packed.apply_gamma5(); - /* - if (i_sample==0){ - PLEGMA_Vector vectorAuxPrint; - for(int isc = 0 ; isc < 12 ; isc++){ - std::string spin=std::to_string(isc/3); - std::string col=std::to_string(isc%3); - - vectorAuxPrint.absorb(propTS_SL_packed,isc/3,isc%3); - vectorAuxPrint.unload(); - vectorAuxPrint.writeHDF5("corrB12_propTS_SL_packed_"+spin+"_c"+col); - } - - stochastic_propagator_packed.writeHDF5("corrB12_stochastic_propagator"); - } */ TIME(reductionsV3.V3( stochastic_propagator_packed, glist_insertion, propTS_SL_packed, true )); @@ -1973,9 +2021,6 @@ int main(int argc, char **argv) { TIME( corrB9.B_diagrams(reductionsV3, *reductions_UU_V2_GAMMAF1D_U[i_sample*tSinks.size()+k], 0, 9, true, false, true)); TIME(corrB10.B_diagrams(reductionsV3, *reductions_UU_V4_GAMMAF1U_D[i_sample*tSinks.size()+k], 0, 10, true, false, true)); TIME(corrB11.B_diagrams(reductionsV3, *reductions_UU_V2_GAMMAF1D_U[i_sample*tSinks.size()+k], 0, 11, true, false, true)); - //reductionsV3.writeHDF5("corrB12_V3_source_"+std::to_string(i_sample)+"_tSinkMtSource_"+std::to_string(k)); - //reductions_UU_V4_GAMMAF1U_D[i_sample*tSinks.size()+k]->writeHDF5("corrB12_V4_source_"+std::to_string(i_sample)+"_tSinkMtSource_"+std::to_string(k)); - TIME(corrB12.B_diagrams(reductionsV3, *reductions_UU_V4_GAMMAF1U_D[i_sample*tSinks.size()+k], 0, 12, true, false, true)); stochastic_propagator_packed.copy(*stochastic_sources[i_sample],HOST); @@ -1983,25 +2028,25 @@ int main(int argc, char **argv) { PLEGMA_Vector stochastic_source_packed; for (int i_source_parallel=0; i_source_parallel propTS_SS; @@ -2073,15 +2114,16 @@ int main(int argc, char **argv) { PLEGMA_Vector3D vector1, vector2; vectorAuxF.absorb(propDN_SS_packed, isc/3, isc%3); vectorAuxD.copy(vectorAuxF); - vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vector1.absorb( vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); PLEGMA_Gauge3D smearedGauge3D; - smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + smearedGauge3D.absorb(smearedGauge, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); + + vector1.mulMomentumPhases(momentum_i2,1); TIME(vector2.gaussianSmearing(vector1, smearedGauge3D, nsmearGauss, alphaGauss)); - vector2.mulMomentumPhases(momentum_i2,1); - vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]); + vectorAuxD.absorb(vector2, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]); } - vectorAuxD2.absorbTimeslice(vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], false); + vectorAuxD2.absorbTimeslice(vectorAuxD, (source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], false); //Perform multiplication with glist_insertion[0] vectorAuxD2.apply_gamma_scatt(glist_source_meson[0]); @@ -2104,28 +2146,31 @@ int main(int argc, char **argv) { } - propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); - propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SS_packed.pack_propagator_from_source_to_sink(propTS_SS, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + propTS_SL_packed.pack_propagator_from_source_to_sink(propTS_SL, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } - PLEGMA_ScattCorrelator corrTproton_protonpizero5(source, list_mpi2ptot); - PLEGMA_ScattCorrelator corrTproton_protonpizero6(source, list_mpi2ptot); + if (dotwopoint==1){ - corrTproton_protonpizero5.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq25"); + PLEGMA_ScattCorrelator corrTproton_protonpizero5(source, list_mpi2ptot); + PLEGMA_ScattCorrelator corrTproton_protonpizero6(source, list_mpi2ptot); - corrTproton_protonpizero6.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq26"); + corrTproton_protonpizero5.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq25"); - TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propUP_SS_packed)); - TIME(corrTproton_protonpizero5.convertTreductiontoDiagram( reductionsT1, false, true, false )); + corrTproton_protonpizero6.initialize_diagram(glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon,"12", "Tseq26"); - TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propDN_SS_packed)); - TIME(corrTproton_protonpizero6.convertTreductiontoDiagram( reductionsT2, false, false, true )); + TIME(reductionsT1.T1(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propUP_SS_packed)); + TIME(corrTproton_protonpizero5.convertTreductiontoDiagram( reductionsT1, false, true, false )); - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; + TIME(reductionsT2.T2(glist_source_nucleon,glist_sink_nucleon, propUP_SS_packed, propTS_SS_packed, propDN_SS_packed)); + TIME(corrTproton_protonpizero6.convertTreductiontoDiagram( reductionsT2, false, false, true )); - TIME(produceOutput_2pt_packed(corrTproton_protonpizero5, outfilename, "T", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrTproton_protonpizero6, outfilename, "T", parallel_sources, attract_lookup_table)); + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_T"; + + TIME(produceOutput_2pt_packed(corrTproton_protonpizero5, outfilename, "T", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrTproton_protonpizero6, outfilename, "T", parallel_sources, attract_lookup_table)); + } PLEGMA_ScattCorrelator corrB7_2pt(source, filtered_sourcemomentumList_2pt); PLEGMA_ScattCorrelator corrB8_2pt(source, filtered_sourcemomentumList_2pt); @@ -2177,9 +2222,9 @@ int main(int argc, char **argv) { { for (int i_source_parallel=0; i_source_parallel= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); - int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propTS_SS_packed_to_sink.pack_propagator_as_sink(propTS_SS_packed, global_fixSinkTime, tsinkMtsource, i_source_parallel==0 ? true : false); } } @@ -2188,9 +2233,9 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel< parallel_sources;++i_source_parallel){ int tsinkMtsource = tSinks[k]; - if(tsinkMtsource >= HGC_totalL[3]) + if(tsinkMtsource >= HGC.totalL[3]) PLEGMA_error("Provided tsink=%d is >= than temporal extent",tsinkMtsource); - int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]; + int global_fixSinkTime = (tsinkMtsource + source[3]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]; propUPpacked_to_sink.pack_propagator_as_sink(propUP_SS_packed, global_fixSinkTime, tsinkMtsource, i_source_parallel==0 ? true : false); } @@ -2198,17 +2243,17 @@ int main(int argc, char **argv) { for (int i_sample=0; i_sample stochastic_propagator_packed; - if (k==0){ + if (k==0 && (dotwopoint==1)){ stochastic_propagator_packed.unload(); stochastic_propagator_packed.copy(*stochastic_propagator_2pt_SS[i_sample],HOST); stochastic_propagator_packed.load(); - TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, false)); + TIME(reductionsV2_2pt.V2( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, true)); TIME( corrW9_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 9, true)); TIME(corrW11_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 11, true)); - TIME(reductionsV2_2pt.V4( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, false)); + TIME(reductionsV2_2pt.V4( stochastic_propagator_packed, glist_sink_nucleon, propTS_SS_packed, propUP_SS_packed, true)); TIME(corrW10_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 10, true, false)); TIME(corrW12_2pt.W_diagrams( *reductions_UU_V3_GAMMAF2U_2pt[i_sample], reductionsV2_2pt, 0, 12, true, false)); @@ -2221,12 +2266,12 @@ int main(int argc, char **argv) { TIME(corrB8_2pt.B_diagrams(reductionsV3_2pt, *reductions_DD_V2_GAMMAF1U_U_2pt[i_sample], 0, 8, true, false, false)); } - for (int i_source_parallel=0; i_source_parallel temporary; - temporary.copy(*stochastic_propags_UP_SL[lookuptable_UP[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3]]*n_stochastic_samples+i_sample],HOST); + temporary.copy(*stochastic_propags_UP_SL[lookuptable_UP[(source[3]+tSinks[k]+i_source_parallel*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3]]*n_stochastic_samples+i_sample],HOST); temporary.load(); - stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_propagator_packed.pack_propagator_from_source_to_sink(temporary, (source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } stochastic_propagator_packed.apply_gamma5(); @@ -2242,17 +2287,17 @@ int main(int argc, char **argv) { PLEGMA_Vector stochastic_source_packed; for (int i_source_parallel=0; i_source_parallel vectortmp1; @@ -2300,8 +2345,8 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel vectorAuxF; vectorAuxF.copy(vectortmp1); - stochastic_oet_prop_u_fini_mom_SL.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_oet_prop_u_fini_mom_SL.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); TIME(vectortmp2.gaussianSmearing(vectortmp1, smearedGauge, nsmearGauss, alphaGauss )); vectorAuxF.copy(vectortmp2); - stochastic_oet_prop_u_fini_mom_SS.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_oet_prop_u_fini_mom_SS.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } @@ -2363,7 +2408,7 @@ int main(int argc, char **argv) { //temporary1.copy(*stochastic_oet_prop_u_fini_mom_SL[spinindex],HOST); //temporary1.load(); //temporary2.copy(vectortmp2); - //temporary1.pack_propagator_from_source_to_sink(temporary2,(source[3]+(l+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, l == 0 ? true : false); + //temporary1.pack_propagator_from_source_to_sink(temporary2,(source[3]+(l+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, l == 0 ? true : false); //temporary1.unload(); //stochastic_oet_prop_u_fini_mom_SL[spinindex]->copy(temporary1,HOST); //temporary1.load(); @@ -2386,9 +2431,9 @@ int main(int argc, char **argv) { for (int i_source_parallel=0; i_source_parallel vectorAuxF; vectorAuxF.copy(vectortmp1); - stochastic_oet_prop_d_fini_mom_SL.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3],max_source_sink_separations, i_source_parallel == 0 ? true : false); + stochastic_oet_prop_d_fini_mom_SL.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3],max_source_sink_separations, i_source_parallel == 0 ? true : false); TIME(vectortmp2.gaussianSmearing(vectortmp1, smearedGauge, nsmearGauss, alphaGauss )); vectorAuxF.copy(vectortmp2); - stochastic_oet_prop_d_fini_mom_SS.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); - - - - //PLEGMA_Vector temporary1,temporary2; - //temporary1.copy(*stochastic_oet_prop_d_fini_mom_SL[spinindex],HOST); - //temporary1.load(); - //temporary2.copy(vectortmp2); - //temporary1.pack_propagator_from_source_to_sink(temporary2,(source[3]+(l+1)*max_source_sink_separations+HGC_totalL[3])%HGC_totalL[3],max_source_sink_separations, l == 0 ? true : false); - //temporary1.unload(); - //stochastic_oet_prop_d_fini_mom_SL[spinindex]->copy(temporary1,HOST); - //temporary1.load(); - - //vectortmp1.diluteSpinDisplace(vectorSource_finite_mom,(spinindex+1)%4,spinindex); - //vectorSource_finite_mom.copy(vectortmp1); - - //} //end of spin dilution + stochastic_oet_prop_d_fini_mom_SS.pack_propagator_from_source_to_sink(vectorAuxF,(source[3]+(i_source_parallel+1)*max_source_sink_separations+HGC.totalL[3])%HGC.totalL[3], max_source_sink_separations, i_source_parallel == 0 ? true : false); } // end of parallel sources }//end of finite momentum oet - //stochastic_oet_prop_d_fini_mom_SL.unload(); - //stochastic_oet_prop_d_fini_mom_SL.writeHDF5("finite_momentum_oet_unsmeared_d"); - //stochastic_oet_prop_d_fini_mom_SL.load(); - - - - //for (int i=0; i< 4; ++i){ { PLEGMA_Vector st_oet_d_fini; st_oet_d_fini.copy(stochastic_oet_prop_d_fini_mom_SL); - // st_oet_d_fini.copy(*stochastic_oet_prop_d_fini_mom_SL[i],HOST); - // st_oet_d_fini.load(); st_oet_d_fini.apply_gamma5(); TIME(reductionsV3_diluted_D_UP.V3( st_oet_d_fini, glist_insertion, propUP_SL_packed, true)); - st_oet_d_fini.copy(stochastic_oet_prop_d_fini_mom_SS); - st_oet_d_fini.apply_gamma5(); + if (dotwopoint==1){ + + st_oet_d_fini.copy(stochastic_oet_prop_d_fini_mom_SS); + st_oet_d_fini.apply_gamma5(); - TIME(reductionsV3_diluted_D_UP_2pt.V3( st_oet_d_fini, glist_sink_meson, propUP_SS_packed, true)); + TIME(reductionsV3_diluted_D_UP_2pt.V3( st_oet_d_fini, glist_sink_meson, propUP_SS_packed, true)); + + } } @@ -2480,17 +2504,15 @@ int main(int argc, char **argv) { { PLEGMA_Vector st_oet_u_fini; st_oet_u_fini.copy(stochastic_oet_prop_u_fini_mom_SL); - //st_oet_u_fini.load(); st_oet_u_fini.apply_gamma5(); TIME(reductionsV3_diluted_U_DN.V3( st_oet_u_fini, glist_insertion, propDN_SL_packed, true)); } - { + if (dotwopoint==1){ PLEGMA_Vector st_oet_u_fini; st_oet_u_fini.copy(stochastic_oet_prop_u_fini_mom_SS); - //st_oet_u_fini.load(); st_oet_u_fini.apply_gamma5(); @@ -2499,9 +2521,9 @@ int main(int argc, char **argv) { - PLEGMA_ScattCorrelator corrZ5_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrZ6_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrZ7_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrZ15_2pt(source, filtered_sourcemomentumList_2pt); + PLEGMA_ScattCorrelator corrZ16_2pt(source, filtered_sourcemomentumList_2pt); +/* PLEGMA_ScattCorrelator corrZ7_2pt(source, filtered_sourcemomentumList_2pt); PLEGMA_ScattCorrelator corrZ8_2pt(source, filtered_sourcemomentumList_2pt); PLEGMA_ScattCorrelator corrZ9_2pt(source, filtered_sourcemomentumList_2pt); @@ -2510,11 +2532,11 @@ int main(int argc, char **argv) { PLEGMA_ScattCorrelator corrZ11_2pt(source, filtered_sourcemomentumList_2pt); PLEGMA_ScattCorrelator corrZ12_2pt(source, filtered_sourcemomentumList_2pt); PLEGMA_ScattCorrelator corrZ13_2pt(source, filtered_sourcemomentumList_2pt); - PLEGMA_ScattCorrelator corrZ14_2pt(source, filtered_sourcemomentumList_2pt); - - corrZ5_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z5"); - corrZ6_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z6"); + PLEGMA_ScattCorrelator corrZ14_2pt(source, filtered_sourcemomentumList_2pt);*/ + corrZ15_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z5"); + corrZ16_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z6"); +/* corrZ7_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z7"); corrZ8_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z8"); @@ -2525,72 +2547,62 @@ int main(int argc, char **argv) { corrZ12_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z12"); corrZ13_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z13"); - corrZ14_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z14"); + corrZ14_2pt.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "12", "Z14");*/ corrM.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson, "32", "MNPPP"); - corrD1if34.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson,"12", "MNPP01"); - corrD1if12.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson,"12", "MNPP02"); +// corrD1if34.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson,"12", "MNPP01"); +// corrD1if12.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson,"12", "MNPP02"); corrD1if56.initialize_diagram( glist_source_nucleon_unpaired, glist_sink_nucleon_unpaired, glist_source_nucleon, glist_source_meson, glist_sink_nucleon, glist_sink_meson,"12", "MN0PP"); + if (dotwopoint==1){ + TIME(corrZ15_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 5, false )); + TIME(corrZ16_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 7, false )); +/* + TIME(corrZ6_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 6, false )); + TIME(corrZ8_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 8, false )); - TIME(corrZ5_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 5, false )); - TIME(corrZ7_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 7, false )); - - TIME(corrZ6_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 6, false )); - TIME(corrZ8_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_D_UP_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 8, false )); - - TIME( corrZ9_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHD_UP_UP_2pt, 0, 9, false )); - TIME(corrZ10_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHD_UP_UP_2pt, 0, 10,false )); + TIME( corrZ9_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHD_UP_UP_2pt, 0, 9, false )); + TIME(corrZ10_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHD_UP_UP_2pt, 0, 10,false )); - TIME(corrZ11_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 11, false )); - TIME(corrZ13_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 13, false )); + TIME(corrZ11_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 11, false )); + TIME(corrZ13_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV2_diluted_STOCHU_DN_UP_2pt, 0, 13, false )); - TIME(corrZ12_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 12, false )); - TIME(corrZ14_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 14, false )); + TIME(corrZ12_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 12, false )); + TIME(corrZ14_2pt.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN_2pt, reductionsV4_diluted_STOCHU_DN_UP_2pt, 0, 14, false ));*/ - TIME(corrPPUP.P_diagrams( stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS, i_mpi2)); - TIME(corrPPDN.P_diagrams( stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS, i_mpi2)); - TIME(corrP0UP.P_diagrams( stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS, i_mpi2)); - TIME(corrP0DN.P_diagrams( stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS, i_mpi2)); + TIME(corrPPUP.P_diagrams( stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS, i_mpi2)); + TIME(corrPPDN.P_diagrams( stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS, i_mpi2)); +// TIME(corrP0UP.P_diagrams( stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS, i_mpi2)); +// TIME(corrP0DN.P_diagrams( stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS, i_mpi2)); - TIME(corrM.M_diagrams( corrNP_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS )); - TIME(corrD1if56.M_diagrams( corrN0_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS)); - TIME(corrD1if34.M_diagrams( corrNP_packed, stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS)); - TIME(corrD1if12.M_diagrams( corrNP_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS)); + TIME(corrM.M_diagrams( corrNP_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS )); + TIME(corrD1if56.M_diagrams( corrN0_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS)); + //TIME(corrD1if34.M_diagrams( corrNP_packed, stochastic_oet_prop_d_zero_mom_SS, stochastic_oet_prop_u_fini_mom_SS)); + //TIME(corrD1if12.M_diagrams( corrNP_packed, stochastic_oet_prop_u_zero_mom_SS, stochastic_oet_prop_d_fini_mom_SS)); - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_Z_2pt"; + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_Z_2pt"; - TIME(produceOutput_2pt_packed(corrZ5_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ6_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ7_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ8_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ15_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ16_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); +/* TIME(produceOutput_2pt_packed(corrZ7_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ8_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ9_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ10_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ9_2pt, outfilename, "4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ10_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ11_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ12_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ13_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); - TIME(produceOutput_2pt_packed(corrZ14_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ11_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ12_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ13_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrZ14_2pt, outfilename,"4pt", parallel_sources, attract_lookup_table));*/ - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_M_2pt"; - TIME(produceOutput_2pt_packed(corrM, outfilename,"4pt")); - TIME(produceOutput_2pt_packed(corrD1if12, outfilename,"4pt")); - TIME(produceOutput_2pt_packed(corrD1if34, outfilename,"4pt")); - TIME(produceOutput_2pt_packed(corrD1if56, outfilename,"4pt")); - - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_N_2pt"; - TIME( corrN0_packed.apply_phase()); - TIME( corrN0_packed.apply_sign("N")); - TIME( corrN0_packed.applyBoundaryConditions( true, parallel_sources, attract_lookup_table)); - TIME( corrN0_packed.writeHDF5(outfilename)); - - TIME( corrNP_packed.apply_phase() ); - TIME( corrNP_packed.apply_sign("N") ); - TIME( corrNP_packed.applyBoundaryConditions( true, parallel_sources, attract_lookup_table)); - TIME( corrNP_packed.writeHDF5(outfilename) ); + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_M_correct_2pt"; + TIME(produceOutput_2pt_packed(corrM, outfilename,"4pt", parallel_sources, attract_lookup_table)); +// TIME(produceOutput_2pt_packed(corrD1if12, outfilename,"4pt", parallel_sources, attract_lookup_table)); +// TIME(produceOutput_2pt_packed(corrD1if34, outfilename,"4pt", parallel_sources, attract_lookup_table)); + TIME(produceOutput_2pt_packed(corrD1if56, outfilename,"4pt", parallel_sources, attract_lookup_table)); + } for (int k=0; kwriteHDF5("corr_Z11_reductionsV2_diluted_STOCHU_DN_UP_"+std::to_string(tSinks[k])); TIME(corrZ11.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN, reductionsV2_diluted_STOCHU_DN_UP,k, 11, false, true )); TIME(corrZ13.Z_diagrams_without_dilution( reductionsV3_diluted_U_DN, reductionsV2_diluted_STOCHU_DN_UP,k, 13, false, true )); @@ -2655,33 +2665,51 @@ int main(int argc, char **argv) { outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_Z"; - TIME(produceOutput_3pt(corrZ5, outfilename, "4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ6, outfilename, "4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ7, outfilename, "4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ8, outfilename, "4pt", tSinks[k], max_source_sink_separations )); + TIME(produceOutput_3pt(corrZ5, outfilename, "4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ6, outfilename, "4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ7, outfilename, "4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ8, outfilename, "4pt", parallel_sources, attract_lookup_table, tSinks[k] )); - TIME(produceOutput_3pt(corrZ9, outfilename, "4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ10, outfilename,"4pt", tSinks[k], max_source_sink_separations )); + TIME(produceOutput_3pt(corrZ9, outfilename, "4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ10, outfilename,"4pt", parallel_sources, attract_lookup_table, tSinks[k] )); - TIME(produceOutput_3pt(corrZ11, outfilename,"4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ12, outfilename,"4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ13, outfilename,"4pt", tSinks[k], max_source_sink_separations )); - TIME(produceOutput_3pt(corrZ14, outfilename,"4pt", tSinks[k], max_source_sink_separations )); + TIME(produceOutput_3pt(corrZ11, outfilename,"4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ12, outfilename,"4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ13, outfilename,"4pt", parallel_sources, attract_lookup_table, tSinks[k] )); + TIME(produceOutput_3pt(corrZ14, outfilename,"4pt", parallel_sources, attract_lookup_table, tSinks[k] )); }//end for loop source sink separations }//loop over mpi2 - outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_P_2pt"; - TIME(corrP0UP.apply_sign("P")); - TIME(corrP0UP.writeHDF5( outfilename )); - TIME(corrP0DN.apply_sign("P")); - TIME(corrP0DN.writeHDF5( outfilename )); - TIME(corrPPUP.apply_sign("P")); - TIME(corrPPUP.writeHDF5( outfilename )); - TIME(corrPPDN.apply_sign("P")); - TIME(corrPPDN.writeHDF5( outfilename )); + if (dotwopoint==1){ + + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_N_2pt"; + TIME( corrN0_packed.apply_phase()); + TIME( corrN0_packed.apply_sign("N")); + TIME( corrN0_packed.applyBoundaryConditions( true, parallel_sources, attract_lookup_table)); + TIME( corrN0_packed.writeHDF5(outfilename)); + + TIME( corrNP_packed.apply_phase() ); + TIME( corrNP_packed.apply_sign("N") ); + TIME( corrNP_packed.applyBoundaryConditions( true, parallel_sources, attract_lookup_table)); + TIME( corrNP_packed.writeHDF5(outfilename) ); + + + + + outfilename = outdiagramPrefix+confnumber+sourcepositiontext+"_P_2pt"; + TIME(corrP0UP.apply_sign("P")); + TIME(corrP0UP.writeHDF5( outfilename )); + TIME(corrP0DN.apply_sign("P")); + TIME(corrP0DN.writeHDF5( outfilename )); + TIME(corrPPUP.apply_sign("P")); + TIME(corrPPUP.writeHDF5( outfilename )); + TIME(corrPPDN.apply_sign("P")); + TIME(corrPPDN.writeHDF5( outfilename )); + + } //for (int spinindex=0;spinindex<4;++spinindex){ @@ -2697,13 +2725,13 @@ int main(int argc, char **argv) { for(int i_samples=0; i_samples< n_stochastic_samples; ++i_samples) { - reductions_UU_V2_GAMMAF1D_U_2pt.pop_back(); - reductions_UU_V4_GAMMAF1U_D_2pt.pop_back(); + if (dotwopoint==1){ + reductions_DD_V2_GAMMAF1U_D_2pt.pop_back(); + reductions_DD_V4_GAMMAF1U_D_2pt.pop_back(); - reductions_UU_V3_GAMMAF2U_2pt.pop_back(); - reductions_DD_V3_GAMMAF2D_2pt.pop_back(); + reductions_DD_V3_GAMMAF2U_2pt.pop_back(); - reductions_DD_V2_GAMMAF1U_U_2pt.pop_back(); + } for (int k=0; k +#include #include #include #include From 7b61543e9efbb636e1c554540ec0f049e971b9cd Mon Sep 17 00:00:00 2001 From: Ferenc Pittler Date: Wed, 22 Mar 2023 16:22:40 +0100 Subject: [PATCH 3/5] correcting cudaGetSymbolAddress --- lib/PLEGMA.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PLEGMA.cu b/lib/PLEGMA.cu index 8d7c30cb..2f32f4a4 100644 --- a/lib/PLEGMA.cu +++ b/lib/PLEGMA.cu @@ -167,12 +167,12 @@ void plegma::PLEGMA_init(int localL[4], int nProcs[4], int verbosity){ // copying globals to device #if defined (__NVCC__) - cudaError_t cudaStatus = cudaGetSymbolAddress((void **)&DGC_ptr, &DGC_const); + cudaError_t cudaStatus = cudaGetSymbolAddress((void **)&DGC_ptr, DGC_const); if (cudaStatus != cudaSuccess) { PLEGMA_error("cudaGetSymbolAddress (dev_N) failed: %s\n", cudaGetErrorString(cudaStatus)); } #elif defined (__HIP__) - hipError_t hipStatus = hipGetSymbolAddress((void **)&DGC_ptr, &DGC_const); + hipError_t hipStatus = hipGetSymbolAddress((void **)&DGC_ptr, DGC_const); if (hipStatus != hipSuccess) { PLEGMA_error("hipGetSymbolAddress (dev_N) failed: %s\n", hipGetErrorString(cudaStatus)); } From fffac7705d542700b376a3d457a954640a5d918b Mon Sep 17 00:00:00 2001 From: Ferenc Pittler Date: Thu, 23 Mar 2023 10:15:39 +0100 Subject: [PATCH 4/5] try to correct errors in copying from host to device --- lib/kernels/PLEGMA_kernel_tuner.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kernels/PLEGMA_kernel_tuner.cuh b/lib/kernels/PLEGMA_kernel_tuner.cuh index c6c03ba8..81fa5efe 100644 --- a/lib/kernels/PLEGMA_kernel_tuner.cuh +++ b/lib/kernels/PLEGMA_kernel_tuner.cuh @@ -203,7 +203,7 @@ public: sprintf(aux, "volume=%lld,Ndims=%d,Ncols=%d,maxvolume=%d,aux_range=(%d,%d,%d,%d)", ps.volume, N_DIMS, N_COLS, ps.max_volume, ps.aux_range.x, ps.aux_range.y, ps.aux_range.z, ps.aux_range.w); kernelName = kname + (std::string) typeid(*kernel).name(); // with cupti no longer necessary setPolicyTuning(ps.tune_globally); - qudaMemcpy(&DGC,DGC_ptr, sizeof(void*), qudaMemcpyHostToDevice); + qudaMemcpy(DGC,DGC_ptr, sizeof(struct global_vars_both*), qudaMemcpyHostToDevice); } ~PLEGMA_kernel_tuner(){ From ddf228c01b0b3accd4c710f048450868627602c7 Mon Sep 17 00:00:00 2001 From: Ferenc Pittler Date: Thu, 6 Apr 2023 08:07:13 +0200 Subject: [PATCH 5/5] correcting qudaMemcpy with cudaMemcpyToSymbol --- lib/kernels/PLEGMA_kernel_tuner.cuh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kernels/PLEGMA_kernel_tuner.cuh b/lib/kernels/PLEGMA_kernel_tuner.cuh index 81fa5efe..0b397b2d 100644 --- a/lib/kernels/PLEGMA_kernel_tuner.cuh +++ b/lib/kernels/PLEGMA_kernel_tuner.cuh @@ -203,7 +203,8 @@ public: sprintf(aux, "volume=%lld,Ndims=%d,Ncols=%d,maxvolume=%d,aux_range=(%d,%d,%d,%d)", ps.volume, N_DIMS, N_COLS, ps.max_volume, ps.aux_range.x, ps.aux_range.y, ps.aux_range.z, ps.aux_range.w); kernelName = kname + (std::string) typeid(*kernel).name(); // with cupti no longer necessary setPolicyTuning(ps.tune_globally); - qudaMemcpy(DGC,DGC_ptr, sizeof(struct global_vars_both*), qudaMemcpyHostToDevice); + cudaError_t temp=cudaMemcpyToSymbol(DGC,&DGC_ptr, sizeof(struct global_vars_both*)); + PLEGMA_printf("Return value of cudaMemcpyToSymbol is %d\n",temp); } ~PLEGMA_kernel_tuner(){