12 #include "func_util.h"
30 #define MIN(x,y) ((x)<(y)?(x):(y))
33 #define MAX(x,y) ((x)<(y)?(y):(x))
44 #define PAD(n,p) (((n)<1 || (p)<1)?(n):(((n) % (p)) ? ((n) + (p) - (n) % (p)) : (n)))
46 #define CEILDIV(a,b) ((int)(ceil(((double)(a))/((double)(b)))))
48 #define GHOST_PAD_MAX 1024
50 #define IS_ALIGNED(PTR,BYTES) (((uintptr_t)(const void *)(PTR)) % (BYTES) == 0)
52 #define ISPOWEROFTWO(x) (((x) & ((x)-1)) == 0)
57 #define UNUSED(x) (void)(x)
59 #define GHOST_SINGLETHREAD(code) {\
61 _Pragma("omp parallel") {\
62 _Pragma("omp single") {\
63 nthread = ghost_omp_nthread(); \
66 ghost_omp_nthread_set(1);\
68 ghost_omp_nthread_set(nthread);\
127 a -= b; a -= c; a ^= (c>>13);
128 b -= c; b -= a; b ^= (a<<8);
129 c -= a; c -= b; c ^= (b>>13);
130 a -= b; a -= c; a ^= (c>>12);
131 b -= c; b -= a; b ^= (a<<16);
132 c -= a; c -= b; c ^= (b>>5);
133 a -= b; a -= c; a ^= (c>>3);
134 b -= c; b -= a; b ^= (a<<10);
135 c -= a; c -= b; c ^= (b>>15);
Functions for global mathematical operations.
Header file for type definitions.
ghost_error ghost_malloc_align(void **mem, const size_t size, const size_t align)
Allocate aligned memory.
Definition: util.c:206
ghost_error ghost_footer_string(char **str)
Definition: util.c:99
ghost_error
Error return type.
Definition: error.h:23
ghost_error ghost_line_string(char **str, const char *label, const char *unit, const char *format,...)
Definition: util.c:126
Macros used for code instrumentation.
ghost_error ghost_malloc(void **mem, const size_t size)
Allocate memory.
Definition: util.c:172
int ghost_hash(int a, int b, int c)
Computes a hash from three integral input values.
Definition: util.h:123
ghost_error ghost_header_string(char **str, const char *fmt,...)
Definition: util.c:27
ghost_error ghost_malloc_pinned(void **mem, const size_t size)
Allocate pinned memory to enable fast CPU-GPU transfers.
Definition: util.c:195