45 inline constexpr
const char*
str_end(
const char *str) {
return *str ?
str_end(str + 1) : str; }
46 inline constexpr
bool str_slant(
const char *str) {
return *str ==
'/' ? true : (*str ?
str_slant(str + 1) :
false); }
47 inline constexpr
const char*
r_slant(
const char* str) {
return *str ==
'/' ? (str + 1) :
r_slant(str - 1); }
52 #define device_malloc(size) quda::device_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size) 53 #define device_pinned_malloc(size) quda::device_pinned_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size) 54 #define safe_malloc(size) quda::safe_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size) 55 #define pinned_malloc(size) quda::pinned_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size) 56 #define mapped_malloc(size) quda::mapped_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size) 57 #define device_free(ptr) quda::device_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr) 58 #define device_pinned_free(ptr) quda::device_pinned_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr) 59 #define host_free(ptr) quda::host_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr) 113 #define pool_device_malloc(size) quda::pool::device_malloc_(__func__, __FILE__, __LINE__, size) 114 #define pool_device_free(ptr) quda::pool::device_free_(__func__, __FILE__, __LINE__, ptr) 115 #define pool_pinned_malloc(size) quda::pool::pinned_malloc_(__func__, __FILE__, __LINE__, size) 116 #define pool_pinned_free(ptr) quda::pool::pinned_free_(__func__, __FILE__, __LINE__, ptr) 119 #endif // _MALLOC_QUDA_H long device_allocated_peak()
void * safe_malloc_(const char *func, const char *file, int line, size_t size)
void * device_malloc_(const char *func, const char *file, int line, size_t size)
constexpr const char * r_slant(const char *str)
void * device_pinned_malloc_(const char *func, const char *file, int line, size_t size)
void device_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
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.
void device_free_(const char *func, const char *file, int line, void *ptr)
constexpr const char * str_end(const char *str)
void flush_pinned()
Free all outstanding pinned-memory allocations.
void device_pinned_free_(const char *func, const char *file, int line, void *ptr)
void init()
Initialize the memory pool allocator.
void host_free_(const char *func, const char *file, int line, void *ptr)
void flush_device()
Free all outstanding device-memory allocations.
long host_allocated_peak()
long mapped_allocated_peak()
void * mapped_malloc_(const char *func, const char *file, int line, size_t size)
constexpr bool str_slant(const char *str)
long pinned_allocated_peak()
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.
constexpr const char * file_name(const char *str)
void pinned_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
void * pinned_malloc_(const char *func, const char *file, int line, size_t size)