diff --git a/Grid/lattice/Lattice_base.h b/Grid/lattice/Lattice_base.h index 271ab43e..1e8b4152 100644 --- a/Grid/lattice/Lattice_base.h +++ b/Grid/lattice/Lattice_base.h @@ -50,6 +50,14 @@ void accelerator_inline conformable(GridBase *lhs,GridBase *rhs) assert(lhs == rhs); } +//////////////////////////////////////////////////////////////////////////// +// Advise for memory management +//////////////////////////////////////////////////////////////////////////// +enum LatticeAcceleratorAdvise { + AdviseInfrequentUse = 0x1 // Advise that the data is used infrequently. This can + // significantly influence performance of bulk storage. +}; + //////////////////////////////////////////////////////////////////////////// // Minimal base class containing only data valid to access from accelerator // _odata will be a managed pointer in CUDA @@ -77,12 +85,12 @@ public: else grid = _grid; }; - // Advise that the data is used infrequently. This can - // significantly influence performance of bulk storage. - accelerator_inline void AdviseInfrequentUse() { + accelerator_inline void Advise(int advise) { #ifdef GRID_NVCC #ifndef __CUDA_ARCH__ // only on host - cudaMemAdvise(_odata,_odata_size*sizeof(vobj),cudaMemAdviseSetPreferredLocation,cudaCpuDeviceId); + if (advise & AdviseInfrequentUse) { + cudaMemAdvise(_odata,_odata_size*sizeof(vobj),cudaMemAdviseSetPreferredLocation,cudaCpuDeviceId); + } #endif #endif };