mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Separate pools for small and large allocations cache
This commit is contained in:
parent
efe5bc6a3c
commit
2bb2c68e15
@ -6,11 +6,23 @@ NAMESPACE_BEGIN(Grid);
|
|||||||
MemoryStats *MemoryProfiler::stats = nullptr;
|
MemoryStats *MemoryProfiler::stats = nullptr;
|
||||||
bool MemoryProfiler::debug = false;
|
bool MemoryProfiler::debug = false;
|
||||||
|
|
||||||
|
int PointerCache::NcacheSmall = PointerCache::NcacheSmallMax;
|
||||||
|
int PointerCache::Ncache = PointerCache::NcacheMax;
|
||||||
int PointerCache::Victim;
|
int PointerCache::Victim;
|
||||||
int PointerCache::VictimSmall;
|
int PointerCache::VictimSmall;
|
||||||
PointerCache::PointerCacheEntry PointerCache::Entries[PointerCache::Ncache];
|
PointerCache::PointerCacheEntry PointerCache::Entries[PointerCache::NcacheMax];
|
||||||
PointerCache::PointerCacheEntry PointerCache::EntriesSmall[PointerCache::NcacheSmall];
|
PointerCache::PointerCacheEntry PointerCache::EntriesSmall[PointerCache::NcacheSmallMax];
|
||||||
|
|
||||||
|
void PointerCache::Init(void)
|
||||||
|
{
|
||||||
|
char * str;
|
||||||
|
str= getenv("GRID_ALLOC_NCACHE_LARGE");
|
||||||
|
if ( str ) Ncache = atoi(str);
|
||||||
|
if ( (Ncache<0) || (Ncache > NcacheMax)) Ncache = NcacheMax;
|
||||||
|
str= getenv("GRID_ALLOC_NCACHE_SMALL");
|
||||||
|
if ( str ) NcacheSmall = atoi(str);
|
||||||
|
if ( (NcacheSmall<0) || (NcacheSmall > NcacheSmallMax)) NcacheSmall = NcacheSmallMax;
|
||||||
|
}
|
||||||
void *PointerCache::Insert(void *ptr,size_t bytes)
|
void *PointerCache::Insert(void *ptr,size_t bytes)
|
||||||
{
|
{
|
||||||
if (bytes < GRID_ALLOC_SMALL_LIMIT )
|
if (bytes < GRID_ALLOC_SMALL_LIMIT )
|
||||||
|
@ -53,8 +53,10 @@ private:
|
|||||||
/*Pinning pages is costly*/
|
/*Pinning pages is costly*/
|
||||||
/*Could maintain separate large and small allocation caches*/
|
/*Could maintain separate large and small allocation caches*/
|
||||||
/* Could make these configurable, perhaps up to a max size*/
|
/* Could make these configurable, perhaps up to a max size*/
|
||||||
static const int NcacheSmall=128;
|
static const int NcacheSmallMax=128;
|
||||||
static const int Ncache=8;
|
static const int NcacheMax=16;
|
||||||
|
static int NcacheSmall;
|
||||||
|
static int Ncache;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *address;
|
void *address;
|
||||||
@ -62,13 +64,13 @@ private:
|
|||||||
int valid;
|
int valid;
|
||||||
} PointerCacheEntry;
|
} PointerCacheEntry;
|
||||||
|
|
||||||
static PointerCacheEntry Entries[Ncache];
|
static PointerCacheEntry Entries[NcacheMax];
|
||||||
static int Victim;
|
static int Victim;
|
||||||
static PointerCacheEntry EntriesSmall[NcacheSmall];
|
static PointerCacheEntry EntriesSmall[NcacheSmallMax];
|
||||||
static int VictimSmall;
|
static int VictimSmall;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void Init(void);
|
||||||
static void *Insert(void *ptr,size_t bytes) ;
|
static void *Insert(void *ptr,size_t bytes) ;
|
||||||
static void *Insert(void *ptr,size_t bytes,PointerCacheEntry *entries,int ncache,int &victim) ;
|
static void *Insert(void *ptr,size_t bytes,PointerCacheEntry *entries,int ncache,int &victim) ;
|
||||||
static void *Lookup(size_t bytes) ;
|
static void *Lookup(size_t bytes) ;
|
||||||
|
@ -779,9 +779,9 @@ void CayleyFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
|
|||||||
assert(mu>=0);
|
assert(mu>=0);
|
||||||
assert(mu<Nd);
|
assert(mu<Nd);
|
||||||
|
|
||||||
int tshift = (mu == Nd-1) ? 1 : 0;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
int tshift = (mu == Nd-1) ? 1 : 0;
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// SHAMIR CASE
|
// SHAMIR CASE
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
@ -829,6 +829,7 @@ void CayleyFermion5D<Impl>::SeqConservedCurrent(PropagatorField &q_in,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GRID_NVCC
|
#ifndef GRID_NVCC
|
||||||
|
int tshift = (mu == Nd-1) ? 1 : 0;
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// GENERAL CAYLEY CASE
|
// GENERAL CAYLEY CASE
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
@ -355,6 +355,8 @@ void Grid_init(int *argc,char ***argv)
|
|||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
GridGpuInit(); // Must come first to set device prior to MPI init
|
GridGpuInit(); // Must come first to set device prior to MPI init
|
||||||
|
|
||||||
|
PointerCache::Init();
|
||||||
|
|
||||||
if( GridCmdOptionExists(*argv,*argv+*argc,"--shm") ){
|
if( GridCmdOptionExists(*argv,*argv+*argc,"--shm") ){
|
||||||
int MB;
|
int MB;
|
||||||
arg= GridCmdOptionPayload(*argv,*argv+*argc,"--shm");
|
arg= GridCmdOptionPayload(*argv,*argv+*argc,"--shm");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user