66 void *
device_malloc_(
const char *func,
const char *file,
int line,
size_t size);
69 void *
safe_malloc_(
const char *func,
const char *file,
int line,
size_t size);
70 void *
pinned_malloc_(
const char *func,
const char *file,
int line,
size_t size);
71 void *
mapped_malloc_(
const char *func,
const char *file,
int line,
size_t size);
72 void *
managed_malloc_(
const char *func,
const char *file,
int line,
size_t size);
73 void device_free_(
const char *func,
const char *file,
int line,
void *ptr);
76 void managed_free_(
const char *func,
const char *file,
int line,
void *ptr);
77 void host_free_(
const char *func,
const char *file,
int line,
void *ptr);
80 inline constexpr
const char*
str_end(
const char *str) {
return *str ?
str_end(str + 1) : str; }
81 inline constexpr
bool str_slant(
const char *str) {
return *str ==
'/' ? true : (*str ?
str_slant(str + 1) :
false); }
82 inline constexpr
const char*
r_slant(
const char* str) {
return *str ==
'/' ? (str + 1) :
r_slant(str - 1); }
95 inline bool is_aligned(
const void *ptr,
size_t alignment)
97 return (
reinterpret_cast<std::uintptr_t
>(ptr) & (alignment - 1)) == 0;
102 #define device_malloc(size) quda::device_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
103 #define device_pinned_malloc(size) quda::device_pinned_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
104 #define device_comms_pinned_malloc(size) \
105 quda::device_comms_pinned_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
106 #define safe_malloc(size) quda::safe_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
107 #define pinned_malloc(size) quda::pinned_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
108 #define mapped_malloc(size) quda::mapped_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
109 #define managed_malloc(size) quda::managed_malloc_(__func__, quda::file_name(__FILE__), __LINE__, size)
110 #define device_free(ptr) quda::device_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
111 #define device_pinned_free(ptr) quda::device_pinned_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
112 #define device_comms_pinned_free(ptr) \
113 quda::device_comms_pinned_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
114 #define managed_free(ptr) quda::managed_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
115 #define host_free(ptr) quda::host_free_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
116 #define get_mapped_device_pointer(ptr) \
117 quda::get_mapped_device_pointer_(__func__, quda::file_name(__FILE__), __LINE__, ptr)
134 void *
device_malloc_(
const char *func,
const char *file,
int line,
size_t size);
140 void device_free_(
const char *func,
const char *file,
int line,
void *ptr);
148 void *
pinned_malloc_(
const char *func,
const char *file,
int line,
size_t size);
154 void pinned_free_(
const char *func,
const char *file,
int line,
void *ptr);
170 #define pool_device_malloc(size) quda::pool::device_malloc_(__func__, __FILE__, __LINE__, size)
171 #define pool_device_free(ptr) quda::pool::device_free_(__func__, __FILE__, __LINE__, ptr)
172 #define pool_pinned_malloc(size) quda::pool::pinned_malloc_(__func__, __FILE__, __LINE__, size)
173 #define pool_pinned_free(ptr) quda::pool::pinned_free_(__func__, __FILE__, __LINE__, ptr)
enum QudaFieldLocation_s QudaFieldLocation
void init()
Initialize the memory pool allocator.
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 flush_pinned()
Free all outstanding pinned-memory allocations.
void flush_device()
Free all outstanding device-memory allocations.
void pinned_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
void device_free_(const char *func, const char *file, int line, void *ptr)
Virtual free of pinned-memory allocation.
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.
void device_free_(const char *func, const char *file, int line, void *ptr)
void host_free_(const char *func, const char *file, int line, void *ptr)
void * device_pinned_malloc_(const char *func, const char *file, int line, size_t size)
void * mapped_malloc_(const char *func, const char *file, int line, size_t size)
constexpr const char * str_end(const char *str)
size_t mapped_allocated()
void * pinned_malloc_(const char *func, const char *file, int line, size_t size)
size_t device_allocated()
bool is_aligned(const void *ptr, size_t alignment)
constexpr const char * file_name(const char *str)
size_t host_allocated_peak()
void * get_mapped_device_pointer_(const char *func, const char *file, int line, const void *ptr)
void device_pinned_free_(const char *func, const char *file, int line, void *ptr)
constexpr const char * r_slant(const char *str)
void managed_free_(const char *func, const char *file, int line, void *ptr)
constexpr bool str_slant(const char *str)
size_t pinned_allocated()
void device_comms_pinned_free_(const char *func, const char *file, int line, void *ptr)
size_t mapped_allocated_peak()
void * device_malloc_(const char *func, const char *file, int line, size_t size)
void * safe_malloc_(const char *func, const char *file, int line, size_t size)
bool use_managed_memory()
size_t pinned_allocated_peak()
size_t device_allocated_peak()
bool is_prefetch_enabled()
QudaFieldLocation get_pointer_location(const void *ptr)
void * managed_malloc_(const char *func, const char *file, int line, size_t size)
void * device_comms_pinned_malloc_(const char *func, const char *file, int line, size_t size)