35 void util_fail_ (
const char *file,
int line,
const char *func,
const char *msg)
37 fprintf(stderr,
"%s, %i (%s):\n%s\n",file,line,func,msg);
40 void util_warn_ (
const char *file,
int line,
const char *func,
const char *msg)
42 fprintf(stderr,
"%s, %i (%s):\n%s\n",file,line,func,msg);
50 static size_t manipsize(
size_t sz)
52 const size_t critical_stride=4096, cacheline=64, overhead=32;
53 if (sz < (critical_stride/2))
return sz;
54 if (((sz+overhead)%critical_stride)>(2*cacheline))
return sz;
55 return sz+2*cacheline;
59 #include <xmmintrin.h> 60 void *util_malloc_ (
size_t sz)
63 if (sz==0)
return NULL;
64 res = _mm_malloc(manipsize(sz),32);
68 void util_free_ (
void *ptr)
69 {
if ((ptr)!=NULL) _mm_free(ptr); }
71 void *util_malloc_ (
size_t sz)
74 if (sz==0)
return NULL;
75 res = malloc(manipsize(sz));
79 void util_free_ (
void *ptr)
80 {
if ((ptr)!=NULL) free(ptr); }
#define UTIL_ASSERT(cond, msg)