QUDA  v1.1.0
A library for QCD on GPUs
malloc.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <cstdio>
3 #include <string>
4 #include <map>
5 #include <unistd.h> // for getpagesize()
6 #include <execinfo.h> // for backtrace
7 #include <quda_internal.h>
8 
9 #ifdef USE_QDPJIT
10 #include "qdp_quda.h"
11 #include "qdp_config.h"
12 #endif
13 
14 #ifdef QUDA_BACKWARDSCPP
15 #include "backward.hpp"
16 #endif
17 namespace quda
18 {
19 
21 
22  class MemAlloc
23  {
24 
25  public:
28  int line;
29  size_t size;
30  size_t base_size;
31 #ifdef QUDA_BACKWARDSCPP
32  backward::StackTrace st;
33 #endif
34 
35  MemAlloc() : line(-1), size(0), base_size(0) {}
36 
38  {
39 #ifdef QUDA_BACKWARDSCPP
40  st.load_here(32);
41  st.skip_n_firsts(1);
42 #endif
43  }
44 
46  {
47  if (&a != this) {
48  func = a.func;
49  file = a.file;
50  line = a.line;
51  size = a.size;
52  base_size = a.base_size;
53 #ifdef QUDA_BACKWARDSCPP
54  st = a.st;
55 #endif
56  }
57  return *this;
58  }
59  };
60 
61  static std::map<void *, MemAlloc> alloc[N_ALLOC_TYPE];
62  static long total_bytes[N_ALLOC_TYPE] = {0};
63  static long max_total_bytes[N_ALLOC_TYPE] = {0};
64  static long total_host_bytes, max_total_host_bytes;
65  static long total_pinned_bytes, max_total_pinned_bytes;
66 
67  long device_allocated_peak() { return max_total_bytes[DEVICE]; }
68 
69  long pinned_allocated_peak() { return max_total_bytes[PINNED]; }
70 
71  long mapped_allocated_peak() { return max_total_bytes[MAPPED]; }
72 
73  long managed_allocated_peak() { return max_total_bytes[MANAGED]; }
74 
75  long host_allocated_peak() { return max_total_bytes[HOST]; }
76 
77  static void print_trace(void)
78  {
79  void *array[10];
80  size_t size;
81  char **strings;
82  size = backtrace(array, 10);
83  strings = backtrace_symbols(array, size);
84  printfQuda("Obtained %zd stack frames.\n", size);
85  for (size_t i = 0; i < size; i++) printfQuda("%s\n", strings[i]);
86  free(strings);
87  }
88 
89  static void print_alloc_header()
90  {
91  printfQuda("Type Pointer Size Location\n");
92  printfQuda("----------------------------------------------------------\n");
93  }
94 
95  static void print_alloc(AllocType type)
96  {
97  const char *type_str[] = {"Device", "Device Pinned", "Host ", "Pinned", "Mapped", "Managed"};
98  std::map<void *, MemAlloc>::iterator entry;
99 
100  for (entry = alloc[type].begin(); entry != alloc[type].end(); entry++) {
101  void *ptr = entry->first;
102  MemAlloc a = entry->second;
103  printfQuda("%s %15p %15lu %s(), %s:%d\n", type_str[type], ptr, (unsigned long)a.base_size, a.func.c_str(),
104  a.file.c_str(), a.line);
105 #ifdef QUDA_BACKWARDSCPP
106  if (getRankVerbosity()) {
107  backward::Printer p;
108  p.print(a.st);
109  }
110 #endif
111  }
112  }
113 
114  static void track_malloc(const AllocType &type, const MemAlloc &a, void *ptr)
115  {
116  total_bytes[type] += a.base_size;
117  if (total_bytes[type] > max_total_bytes[type]) { max_total_bytes[type] = total_bytes[type]; }
118  if (type != DEVICE && type != DEVICE_PINNED) {
119  total_host_bytes += a.base_size;
120  if (total_host_bytes > max_total_host_bytes) { max_total_host_bytes = total_host_bytes; }
121  }
122  if (type == PINNED || type == MAPPED) {
123  total_pinned_bytes += a.base_size;
124  if (total_pinned_bytes > max_total_pinned_bytes) { max_total_pinned_bytes = total_pinned_bytes; }
125  }
126  alloc[type][ptr] = a;
127  }
128 
129  static void track_free(const AllocType &type, void *ptr)
130  {
131  size_t size = alloc[type][ptr].base_size;
132  total_bytes[type] -= size;
133  if (type != DEVICE && type != DEVICE_PINNED) { total_host_bytes -= size; }
134  if (type == PINNED || type == MAPPED) { total_pinned_bytes -= size; }
135  alloc[type].erase(ptr);
136  }
137 
144  static void *aligned_malloc(MemAlloc &a, size_t size)
145  {
146  void *ptr = nullptr;
147 
148  a.size = size;
149 
150  static int page_size = 2 * getpagesize();
151  a.base_size = ((size + page_size - 1) / page_size) * page_size; // round up to the nearest multiple of page_size
152  int align = posix_memalign(&ptr, page_size, a.base_size);
153  if (!ptr || align != 0) {
154  errorQuda("Failed to allocate aligned host memory of size %zu (%s:%d in %s())\n", size, a.file.c_str(), a.line,
155  a.func.c_str());
156  }
157  return ptr;
158  }
159 
160  bool use_managed_memory()
161  {
162  static bool managed = false;
163  static bool init = false;
164 
165  if (!init) {
166  char *enable_managed_memory = getenv("QUDA_ENABLE_MANAGED_MEMORY");
167  if (enable_managed_memory && strcmp(enable_managed_memory, "1") == 0) {
168  warningQuda("Using managed memory for HIP allocations");
169  managed = true;
170 
171  if (deviceProp.major < 6) warningQuda("Using managed memory on pre-Pascal architecture is limited");
172  }
173 
174  init = true;
175  }
176 
177  return managed;
178  }
179 
180  bool is_prefetch_enabled()
181  {
182  static bool prefetch = false;
183  static bool init = false;
184 
185  if (!init) {
186  if (use_managed_memory()) {
187  char *enable_managed_prefetch = getenv("QUDA_ENABLE_MANAGED_PREFETCH");
188  if (enable_managed_prefetch && strcmp(enable_managed_prefetch, "1") == 0) {
189  warningQuda("Enabling prefetch support for managed memory");
190  prefetch = true;
191  }
192  }
193 
194  init = true;
195  }
196 
197  return prefetch;
198  }
199 
205  void *device_malloc_(const char *func, const char *file, int line, size_t size)
206  {
207  if (use_managed_memory()) return managed_malloc_(func, file, line, size);
208 
209 #ifndef QDP_USE_CUDA_MANAGED_MEMORY
210  MemAlloc a(func, file, line);
211  void *ptr;
212 
213  a.size = a.base_size = size;
214 
215  hipError_t err = hipMalloc(&ptr, size);
216  if (err != hipSuccess) {
217  errorQuda("Failed to allocate device memory of size %zu (%s:%d in %s())\n", size, file, line, func);
218  }
219  track_malloc(DEVICE, a, ptr);
220 #ifdef HOST_DEBUG
221  hipMemset(ptr, 0xff, size);
222 #endif
223  return ptr;
224 #else
225  // when QDO uses managed memory we can bypass the QDP memory manager
226  return device_pinned_malloc_(func, file, line, size);
227 #endif
228  }
229 
237  void *device_pinned_malloc_(const char *func, const char *file, int line, size_t size)
238  {
239  if (!comm_peer2peer_present()) return device_malloc_(func, file, line, size);
240 
241  MemAlloc a(func, file, line);
242  void *ptr;
243 
244  a.size = a.base_size = size;
245 
246  hipError_t err = hipMemAlloc((hipDeviceptr_t *)&ptr, size);
247  if (err != HIP_SUCCESS) {
248  errorQuda("Failed to allocate device memory of size %zu (%s:%d in %s())\n", size, file, line, func);
249  }
250  track_malloc(DEVICE_PINNED, a, ptr);
251 #ifdef HOST_DEBUG
252  hipMemset(ptr, 0xff, size);
253 #endif
254  return ptr;
255  }
256 
262  void *safe_malloc_(const char *func, const char *file, int line, size_t size)
263  {
264  MemAlloc a(func, file, line);
265  a.size = a.base_size = size;
266 
267  void *ptr = malloc(size);
268  if (!ptr) { errorQuda("Failed to allocate host memory of size %zu (%s:%d in %s())\n", size, file, line, func); }
269  track_malloc(HOST, a, ptr);
270 #ifdef HOST_DEBUG
271  memset(ptr, 0xff, size);
272 #endif
273  return ptr;
274  }
275 
285  void *pinned_malloc_(const char *func, const char *file, int line, size_t size)
286  {
287  MemAlloc a(func, file, line);
288  void *ptr = aligned_malloc(a, size);
289 
290  hipError_t err = hipHostRegister(ptr, a.base_size, hipHostRegisterDefault);
291  if (err != hipSuccess) {
292  errorQuda("Failed to register pinned memory of size %zu (%s:%d in %s())\n", size, file, line, func);
293  }
294  track_malloc(PINNED, a, ptr);
295 #ifdef HOST_DEBUG
296  memset(ptr, 0xff, a.base_size);
297 #endif
298  return ptr;
299  }
300 
306  void *mapped_malloc_(const char *func, const char *file, int line, size_t size)
307  {
308  MemAlloc a(func, file, line);
309 
310  void *ptr = aligned_malloc(a, size);
311  hipError_t err = hipHostRegister(ptr, a.base_size, hipHostRegisterMapped | hipHostRegisterPortable);
312  if (err != hipSuccess) {
313  errorQuda("Failed to register host-mapped memory of size %zu (%s:%d in %s())\n", size, file, line, func);
314  }
315 
316  track_malloc(MAPPED, a, ptr);
317 #ifdef HOST_DEBUG
318  memset(ptr, 0xff, a.base_size);
319 #endif
320  return ptr;
321  }
322 
328  void *managed_malloc_(const char *func, const char *file, int line, size_t size)
329  {
330  MemAlloc a(func, file, line);
331  void *ptr;
332 
333  a.size = a.base_size = size;
334 
335  hipError_t err = hipMallocManaged(&ptr, size);
336  if (err != hipSuccess) {
337  errorQuda("Failed to allocate managed memory of size %zu (%s:%d in %s())\n", size, file, line, func);
338  }
339  track_malloc(MANAGED, a, ptr);
340 #ifdef HOST_DEBUG
341  hipMemset(ptr, 0xff, size);
342 #endif
343  return ptr;
344  }
345 
351  void device_free_(const char *func, const char *file, int line, void *ptr)
352  {
353  if (use_managed_memory()) {
354  managed_free_(func, file, line, ptr);
355  return;
356  }
357 
358 #ifndef QDP_USE_CUDA_MANAGED_MEMORY
359  if (!ptr) { errorQuda("Attempt to free NULL device pointer (%s:%d in %s())\n", file, line, func); }
360  if (!alloc[DEVICE].count(ptr)) {
361  errorQuda("Attempt to free invalid device pointer (%s:%d in %s())\n", file, line, func);
362  }
363  hipError_t err = hipFree(ptr);
364  if (err != hipSuccess) { errorQuda("Failed to free device memory (%s:%d in %s())\n", file, line, func); }
365  track_free(DEVICE, ptr);
366 #else
367  device_pinned_free_(func, file, line, ptr);
368 #endif
369  }
370 
376  void device_pinned_free_(const char *func, const char *file, int line, void *ptr)
377  {
378  if (!comm_peer2peer_present()) {
379  device_free_(func, file, line, ptr);
380  return;
381  }
382 
383  if (!ptr) { errorQuda("Attempt to free NULL device pointer (%s:%d in %s())\n", file, line, func); }
384  if (!alloc[DEVICE_PINNED].count(ptr)) {
385  errorQuda("Attempt to free invalid device pointer (%s:%d in %s())\n", file, line, func);
386  }
387  hipError_t err = hipMemFree((hipDeviceptr_t)ptr);
388  if (err != HIP_SUCCESS) { printfQuda("Failed to free device memory (%s:%d in %s())\n", file, line, func); }
389  track_free(DEVICE_PINNED, ptr);
390  }
391 
397  void managed_free_(const char *func, const char *file, int line, void *ptr)
398  {
399  if (!ptr) { errorQuda("Attempt to free NULL managed pointer (%s:%d in %s())\n", file, line, func); }
400  if (!alloc[MANAGED].count(ptr)) {
401  errorQuda("Attempt to free invalid managed pointer (%s:%d in %s())\n", file, line, func);
402  }
403  hipError_t err = hipFree(ptr);
404  if (err != hipSuccess) { errorQuda("Failed to free device memory (%s:%d in %s())\n", file, line, func); }
405  track_free(MANAGED, ptr);
406  }
407 
413  void host_free_(const char *func, const char *file, int line, void *ptr)
414  {
415  if (!ptr) { errorQuda("Attempt to free NULL host pointer (%s:%d in %s())\n", file, line, func); }
416  if (alloc[HOST].count(ptr)) {
417  track_free(HOST, ptr);
418  free(ptr);
419  } else if (alloc[PINNED].count(ptr)) {
420  hipError_t err = hipHostUnregister(ptr);
421  if (err != hipSuccess) { errorQuda("Failed to unregister pinned memory (%s:%d in %s())\n", file, line, func); }
422  track_free(PINNED, ptr);
423  free(ptr);
424  } else if (alloc[MAPPED].count(ptr)) {
425 #ifdef HOST_ALLOC
426  hipError_t err = hipFreeHost(ptr);
427  if (err != hipSuccess) { errorQuda("Failed to free host memory (%s:%d in %s())\n", file, line, func); }
428 #else
429  hipError_t err = hipHostUnregister(ptr);
430  if (err != hipSuccess) {
431  errorQuda("Failed to unregister host-mapped memory (%s:%d in %s())\n", file, line, func);
432  }
433  free(ptr);
434 #endif
435  track_free(MAPPED, ptr);
436  } else {
437  printfQuda("ERROR: Attempt to free invalid host pointer (%s:%d in %s())\n", file, line, func);
438  print_trace();
439  errorQuda("Aborting");
440  }
441  }
442 
443  void printPeakMemUsage()
444  {
445  printfQuda("Device memory used = %.1f MB\n", max_total_bytes[DEVICE] / (double)(1 << 20));
446  printfQuda("Pinned device memory used = %.1f MB\n", max_total_bytes[DEVICE_PINNED] / (double)(1 << 20));
447  printfQuda("Managed memory used = %.1f MB\n", max_total_bytes[MANAGED] / (double)(1 << 20));
448  printfQuda("Page-locked host memory used = %.1f MB\n", max_total_pinned_bytes / (double)(1 << 20));
449  printfQuda("Total host memory used >= %.1f MB\n", max_total_host_bytes / (double)(1 << 20));
450  }
451 
452  void assertAllMemFree()
453  {
454  if (!alloc[DEVICE].empty() || !alloc[DEVICE_PINNED].empty() || !alloc[HOST].empty() || !alloc[PINNED].empty()
455  || !alloc[MAPPED].empty()) {
456  warningQuda("The following internal memory allocations were not freed.");
457  printfQuda("\n");
458  print_alloc_header();
459  print_alloc(DEVICE);
460  print_alloc(DEVICE_PINNED);
461  print_alloc(HOST);
462  print_alloc(PINNED);
463  print_alloc(MAPPED);
464  printfQuda("\n");
465  }
466  }
467 
468  QudaFieldLocation get_pointer_location(const void *ptr)
469  {
470 
471  // Unsupported in HIP
472  /*
473  CUpointer_attribute attribute[] = {CU_POINTER_ATTRIBUTE_MEMORY_TYPE};
474  CUmemorytype mem_type;
475  void *data[] = {&mem_type};
476  CUresult error = cuPointerGetAttributes(1, attribute, data, reinterpret_cast<CUdeviceptr>(ptr));
477  if (error != CUDA_SUCCESS) {
478  const char *string;
479  cuGetErrorString(error, &string);
480  errorQuda("cuPointerGetAttributes failed with error %s", string);
481  }
482 
483  // catch pointers that have not been created in CUDA
484  if (mem_type == 0) mem_type = CU_MEMORYTYPE_HOST;
485 
486  switch (mem_type) {
487  case CU_MEMORYTYPE_DEVICE:
488  case CU_MEMORYTYPE_UNIFIED: return QUDA_CUDA_FIELD_LOCATION;
489  case CU_MEMORYTYPE_HOST: return QUDA_CPU_FIELD_LOCATION;
490  default: errorQuda("Unknown memory type %d", mem_type); return QUDA_INVALID_FIELD_LOCATION;
491  }
492  */
493  }
494 
495  void *get_mapped_device_pointer_(const char *func, const char *file, int line, const void *host)
496  {
497  void *device;
498  auto error = hipHostGetDevicePointer(&device, const_cast<void *>(host), 0);
499  if (error != hipSuccess) {
500  errorQuda("hipHostGetDevicePointer failed with error %s (%s:%d in %s()", hipGetErrorString(error), file, line,
501  func);
502  }
503  return device;
504  }
505 
506  namespace pool
507  {
508 
512  static std::multimap<size_t, void *> pinnedCache;
513 
517  static std::map<void *, size_t> pinnedSize;
518 
522  static std::multimap<size_t, void *> deviceCache;
523 
527  static std::map<void *, size_t> deviceSize;
528 
529  static bool pool_init = false;
530 
532  static bool device_memory_pool = true;
533 
535  static bool pinned_memory_pool = true;
536 
537  void init()
538  {
539  if (!pool_init) {
540  // device memory pool
541  char *enable_device_pool = getenv("QUDA_ENABLE_DEVICE_MEMORY_POOL");
542  if (!enable_device_pool || strcmp(enable_device_pool, "0") != 0) {
543  warningQuda("Using device memory pool allocator");
544  device_memory_pool = true;
545  } else {
546  warningQuda("Not using device memory pool allocator");
547  device_memory_pool = false;
548  }
549 
550  // pinned memory pool
551  char *enable_pinned_pool = getenv("QUDA_ENABLE_PINNED_MEMORY_POOL");
552  if (!enable_pinned_pool || strcmp(enable_pinned_pool, "0") != 0) {
553  warningQuda("Using pinned memory pool allocator");
554  pinned_memory_pool = true;
555  } else {
556  warningQuda("Not using pinned memory pool allocator");
557  pinned_memory_pool = false;
558  }
559  pool_init = true;
560  }
561  }
562 
563  void *pinned_malloc_(const char *func, const char *file, int line, size_t nbytes)
564  {
565  void *ptr = nullptr;
566  if (pinned_memory_pool) {
567  std::multimap<size_t, void *>::iterator it;
568 
569  if (pinnedCache.empty()) {
570  ptr = quda::pinned_malloc_(func, file, line, nbytes);
571  } else {
572  it = pinnedCache.lower_bound(nbytes);
573  if (it != pinnedCache.end()) { // sufficiently large allocation found
574  nbytes = it->first;
575  ptr = it->second;
576  pinnedCache.erase(it);
577  } else { // sacrifice the smallest cached allocation
578  it = pinnedCache.begin();
579  ptr = it->second;
580  pinnedCache.erase(it);
581  host_free(ptr);
582  ptr = quda::pinned_malloc_(func, file, line, nbytes);
583  }
584  }
585  pinnedSize[ptr] = nbytes;
586  } else {
587  ptr = quda::pinned_malloc_(func, file, line, nbytes);
588  }
589  return ptr;
590  }
591 
592  void pinned_free_(const char *func, const char *file, int line, void *ptr)
593  {
594  if (pinned_memory_pool) {
595  if (!pinnedSize.count(ptr)) { errorQuda("Attempt to free invalid pointer"); }
596  pinnedCache.insert(std::make_pair(pinnedSize[ptr], ptr));
597  pinnedSize.erase(ptr);
598  } else {
599  quda::host_free_(func, file, line, ptr);
600  }
601  }
602 
603  void *device_malloc_(const char *func, const char *file, int line, size_t nbytes)
604  {
605  void *ptr = nullptr;
606  if (device_memory_pool) {
607  std::multimap<size_t, void *>::iterator it;
608 
609  if (deviceCache.empty()) {
610  ptr = quda::device_malloc_(func, file, line, nbytes);
611  } else {
612  it = deviceCache.lower_bound(nbytes);
613  if (it != deviceCache.end()) { // sufficiently large allocation found
614  nbytes = it->first;
615  ptr = it->second;
616  deviceCache.erase(it);
617  } else { // sacrifice the smallest cached allocation
618  it = deviceCache.begin();
619  ptr = it->second;
620  deviceCache.erase(it);
621  quda::device_free_(func, file, line, ptr);
622  ptr = quda::device_malloc_(func, file, line, nbytes);
623  }
624  }
625  deviceSize[ptr] = nbytes;
626  } else {
627  ptr = quda::device_malloc_(func, file, line, nbytes);
628  }
629  return ptr;
630  }
631 
632  void device_free_(const char *func, const char *file, int line, void *ptr)
633  {
634  if (device_memory_pool) {
635  if (!deviceSize.count(ptr)) { errorQuda("Attempt to free invalid pointer"); }
636  deviceCache.insert(std::make_pair(deviceSize[ptr], ptr));
637  deviceSize.erase(ptr);
638  } else {
639  quda::device_free_(func, file, line, ptr);
640  }
641  }
642 
643  void flush_pinned()
644  {
645  if (pinned_memory_pool) {
646  std::multimap<size_t, void *>::iterator it;
647  for (it = pinnedCache.begin(); it != pinnedCache.end(); it++) {
648  void *ptr = it->second;
649  host_free(ptr);
650  }
651  pinnedCache.clear();
652  }
653  }
654 
655  void flush_device()
656  {
657  if (device_memory_pool) {
658  std::multimap<size_t, void *>::iterator it;
659  for (it = deviceCache.begin(); it != deviceCache.end(); it++) {
660  void *ptr = it->second;
661  device_free(ptr);
662  }
663  deviceCache.clear();
664  }
665  }
666 
667  } // namespace pool
668 
669 } // namespace quda
std::string func
Definition: malloc.cpp:28
std::string file
Definition: malloc.cpp:29
MemAlloc(std::string func, std::string file, int line)
Definition: malloc.cpp:37
MemAlloc & operator=(const MemAlloc &a)
Definition: malloc.cpp:45
size_t size
Definition: malloc.cpp:31
size_t base_size
Definition: malloc.cpp:32
bool comm_peer2peer_present()
Returns true if any peer-to-peer capability is present on this system (regardless of whether it has b...
void * memset(void *s, int c, size_t n)
enum QudaFieldLocation_s QudaFieldLocation
#define device_free(ptr)
Definition: malloc_quda.h:110
#define host_free(ptr)
Definition: malloc_quda.h:115
void init()
Create the BLAS context.
void init()
Initialize the memory pool allocator.
Definition: malloc.cpp:632
void * pinned_malloc_(const char *func, const char *file, int line, size_t size)
Allocate pinned-memory. If a free pre-existing allocation exists reuse this.
Definition: malloc.cpp:665
void flush_pinned()
Free all outstanding pinned-memory allocations.
Definition: malloc.cpp:753
void flush_device()
Free all outstanding device-memory allocations.
Definition: malloc.cpp:761
void pinned_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
Definition: malloc.cpp:692
void device_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
Definition: malloc.cpp:730
void * device_malloc_(const char *func, const char *file, int line, size_t size)
Allocate device-memory. If free pre-existing allocation exists reuse this.
Definition: malloc.cpp:703
void device_free_(const char *func, const char *file, int line, void *ptr)
Definition: malloc.cpp:415
void host_free_(const char *func, const char *file, int line, void *ptr)
Definition: malloc.cpp:477
void * device_pinned_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:255
void * mapped_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:324
void * pinned_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:303
void printPeakMemUsage()
Definition: malloc.cpp:539
size_t host_allocated_peak()
Definition: malloc.cpp:87
void * get_mapped_device_pointer_(const char *func, const char *file, int line, const void *ptr)
Definition: malloc.cpp:590
void device_pinned_free_(const char *func, const char *file, int line, void *ptr)
Definition: malloc.cpp:440
void managed_free_(const char *func, const char *file, int line, void *ptr)
Definition: malloc.cpp:461
size_t managed_allocated_peak()
Definition: malloc.cpp:85
size_t mapped_allocated_peak()
Definition: malloc.cpp:83
void assertAllMemFree()
Definition: malloc.cpp:549
void * device_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:223
void * safe_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:280
bool use_managed_memory()
Definition: malloc.cpp:178
size_t pinned_allocated_peak()
Definition: malloc.cpp:81
size_t device_allocated_peak()
Definition: malloc.cpp:79
bool is_prefetch_enabled()
Definition: malloc.cpp:198
QudaFieldLocation get_pointer_location(const void *ptr)
Definition: malloc.cpp:566
AllocType
Definition: malloc.cpp:22
@ N_ALLOC_TYPE
Definition: malloc.cpp:22
@ MANAGED
Definition: malloc.cpp:22
@ DEVICE_PINNED
Definition: malloc.cpp:22
@ HOST
Definition: malloc.cpp:22
@ MAPPED
Definition: malloc.cpp:22
@ DEVICE
Definition: malloc.cpp:22
@ PINNED
Definition: malloc.cpp:22
void * managed_malloc_(const char *func, const char *file, int line, size_t size)
Definition: malloc.cpp:356
::std::string string
Definition: gtest-port.h:891
cudaDeviceProp deviceProp
Definition: device.cpp:14
#define printfQuda(...)
Definition: util_quda.h:114
bool getRankVerbosity()
This function returns true if the calling rank is enabled for verbosity (e.g., whether printQuda and ...
Definition: util_quda.cpp:30
#define warningQuda(...)
Definition: util_quda.h:132
#define errorQuda(...)
Definition: util_quda.h:120