1#include "plumbing/memalloc.h"
10void *memalloc(std::size_t size,
const char *filename,
const unsigned line) {
12#ifndef ALIGNED_MEMALLOC
16 if ((p = std::malloc(size)) ==
nullptr) {
17 if (filename !=
nullptr) {
18 hila::out <<
" *** memalloc failure in file " << filename <<
" at line "
23 hila::out <<
" requested allocation size " << size <<
" bytes\n"
24 <<
" *********************************" << std::endl;
35 size = ((size + 31) / 32) * 32;
36 int e = posix_memalign(&p, (std::size_t)32, size);
38 if (filename !=
nullptr) {
39 hila::out <<
" *** memalloc failure in file " << filename <<
" at line "
44 hila::out <<
" requested allocation size " << size <<
" bytes\n"
45 <<
" posix_memalign() error code " << e
46 <<
" *********************************" << std::endl;
55void *memalloc(std::size_t size) {
return memalloc(size,
nullptr, 0); }
60void *d_malloc(std::size_t size) {
62#if !defined(CUDA) && !defined(HIP)
64 return memalloc(size);
76void d_free(
void *dptr) {
78#if !defined(CUDA) && !defined(HIP)
80 if (dptr !=
nullptr) free(dptr);
std::ostream out
this is our default output file stream