Mercurial > hg > Members > innparusu > Gears
diff src/parallel_execution/context.h @ 101:8987cf13d5bb
Add Allocate macro
author | innparusu |
---|---|
date | Wed, 02 Mar 2016 19:23:00 +0900 |
parents | d400948dbbab |
children | 64c98838a291 |
line wrap: on
line diff
--- a/src/parallel_execution/context.h Tue Feb 02 16:12:34 2016 +0900 +++ b/src/parallel_execution/context.h Wed Mar 02 19:23:00 2016 +0900 @@ -1,9 +1,17 @@ /* Context definition for llrb example */ #include <pthread.h> +#ifdef USE_CUDA #include <cuda.h> +#endif #include "stack.h" #define ALLOCATE_SIZE 20000000 +#define NEW(type) (type*)(calloc(1, sizeof(type))) +#define NEWN(n, type) (type*)(calloc(n, sizeof(type))) + +#define ALLOC_DATA(context, dseg) ({ context->data[dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[dseg]; }) + +#define ALLOC_DATA_TYPE(context, dseg, type) ({ context->data[dseg] = context->heap; context->heap += sizeof(struct type); (struct type *)context->data[dseg]; }) enum Code { Code1, @@ -107,6 +115,7 @@ int num; struct Context* contexts; } worker; +#ifdef USE_CUDA struct CudaTask { CUdevice device; CUcontext cuCtx; @@ -114,6 +123,7 @@ CUdeviceptr* deviceptr; CUstream stream; } cudatask; +#endif struct Task { enum Code code; int key;