CMS 3D CMS Logo

AllocatorConfig.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_AlpakaInterface_interface_AllocatorConfig_h
2 #define HeterogeneousCore_AlpakaInterface_interface_AllocatorConfig_h
3 
4 #include <cstddef>
5 #include <cstdint>
6 #include <limits>
7 
8 namespace cms::alpakatools {
9 
10  struct AllocatorConfig {
11  // Bin growth factor (bin_growth in cub::CachingDeviceAllocator)
12  unsigned int binGrowth = 2;
13 
14  // Smallest bin, corresponds to binGrowth^minBin bytes (min_bin in cub::CachingDeviceAllocator
15  unsigned int minBin = 8; // 256 bytes
16 
17  // Largest bin, corresponds to binGrowth^maxBin bytes (max_bin in cub::CachingDeviceAllocator).
18  // Note that unlike in cub, allocations larger than binGrowth^maxBin are set to fail.
19  unsigned int maxBin = 30; // 1 GB
20 
21  // Total storage for the allocator; 0 means no limit.
22  size_t maxCachedBytes = 0;
23 
24  // Fraction of total device memory taken for the allocator; 0 means no limit.
25  // If both maxCachedBytes and maxCachedFraction are non-zero, the smallest resulting value is used.
26  double maxCachedFraction = 0.8;
27 
28  // Fill all newly allocated or re-used memory blocks with fillAllocationValue.
29  bool fillAllocations = false;
30 
31  // Fill only the re-used memory blocks with fillReallocationValue.
32  // If both fillAllocations and fillReallocations are true, fillAllocationValue is used for newly allocated blocks and fillReallocationValue is used for re-allocated blocks.
33  bool fillReallocations = false;
34 
35  // Fill memory blocks with fillDeallocationValue before freeing or caching them for re-use
36  bool fillDeallocations = false;
37 
38  // Fill memory blocks with fillCacheValue before caching them for re-use.
39  // If both fillDeallocations and fillCaches are true, fillDeallocationValue is used for blocks about to be freed and fillCacheValue is used for blocks about to be cached.
40  bool fillCaches = false;
41 
42  // Byte value used to fill all newly allocated or re-used memory blocks
43  uint8_t fillAllocationValue = 0xA5;
44 
45  // Byte value used to fill all re-used memory blocks
46  uint8_t fillReallocationValue = 0x69;
47 
48  // Byte value used to fill all deallocated or cached memory blocks
49  uint8_t fillDeallocationValue = 0x5A;
50 
51  // Byte value used to fill all cached memory blocks
52  uint8_t fillCacheValue = 0x96;
53  };
54 
55 } // namespace cms::alpakatools
56 
57 #endif // HeterogeneousCore_AlpakaInterface_interface_AllocatorConfig_h