summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2013-04-11 15:08:59 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-04-12 14:13:48 +0800
commite6b503e2b902f939c506ad8a7d6e5b1058c1ff6c (patch)
treeb594bd8387ae4a5c09a323895ab6dfd775d58014
parent393090a4762114748d4206475354393b00053f8c (diff)
utests: refine the helper macros.Release_v0.1
The previous implementation has many duplicate code, and the FN is used incorrectly. Now fix it and the code looks a little bit clean and when it fails the reported function name should be correct now. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Lu Guanqun <guanqun.lu@intel.com>
-rw-r--r--utests/utest_helper.hpp43
1 files changed, 12 insertions, 31 deletions
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index f364ff9b..b52174d1 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -71,48 +71,33 @@
OCL_CALL(clFlush, queue); \
} while(0)
-#define OCL_CREATE_BUFFER(BUFFER, FLAGS, SIZE, DATA) \
+#define OCL_CALL2(FN, RET, ...) \
do { \
cl_int status; \
- BUFFER = clCreateBuffer(ctx, FLAGS, SIZE, DATA, &status); \
+ RET = FN(__VA_ARGS__, &status);\
if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
} while (0)
+#define OCL_CREATE_BUFFER(BUFFER, FLAGS, SIZE, DATA) \
+ OCL_CALL2(clCreateBuffer, BUFFER, ctx, FLAGS, SIZE, DATA)
+
#define OCL_CREATE_IMAGE(IMAGE, FLAGS, FORMAT, DESC, DATA) \
- do { \
- cl_int status; \
- IMAGE = clCreateImage(ctx, FLAGS, FORMAT, DESC, DATA, &status);\
- if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
- } while (0)
+ OCL_CALL2(clCreateImage, IMAGE, ctx, FLAGS, FORMAT, DESC, DATA)
#define OCL_CREATE_GL_IMAGE(IMAGE, FLAGS, TARGET, LEVEL, TEXTURE) \
- do { \
- cl_int status; \
- IMAGE = clCreateFromGLTexture(ctx, FLAGS, TARGET, LEVEL, TEXTURE, &status);\
- if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
- } while (0)
+ OCL_CALL2(clCreateFromGLTexture, IMAGE, ctx, FLAGS, TARGET, LEVEL, TEXTURE)
#define OCL_ENQUEUE_ACQUIRE_GL_OBJECTS(ID) \
- do { \
- clEnqueueAcquireGLObjects(queue, 1, &buf[ID], 0,0, 0); \
- } while(0)
+ OCL_CALL(clEnqueueAcquireGLObjects, queue, 1, &buf[ID], 0, 0, 0)
#define OCL_SWAP_EGL_BUFFERS() \
eglSwapBuffers(eglDisplay, eglSurface);
#define OCL_CREATE_SAMPLER(SAMPLER, ADDRESS_MODE, FILTER_MODE) \
- do { \
- cl_int status; \
- SAMPLER = clCreateSampler(ctx, 0, CL_ADDRESS_CLAMP, CL_FILTER_NEAREST, &status);\
- if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
- } while(0)
+ OCL_CALL2(clCreateSampler, SAMPLER, ctx, 0, ADDRESS_MODE, FILTER_MODE)
#define OCL_MAP_BUFFER(ID) \
- do { \
- cl_int status; \
- buf_data[ID] = (int *) clIntelMapBuffer(buf[ID], &status); \
- if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
- } while (0)
+ OCL_CALL2(clIntelMapBuffer, buf_data[ID], buf[ID])
#define OCL_UNMAP_BUFFER(ID) \
do { \
@@ -123,14 +108,10 @@
} while (0)
#define OCL_NDRANGE(DIM_N) \
- do { \
- OCL_CALL (clEnqueueNDRangeKernel, queue, kernel, DIM_N, NULL, globals, locals, 0, NULL, NULL); \
- } while (0)
+ OCL_CALL (clEnqueueNDRangeKernel, queue, kernel, DIM_N, NULL, globals, locals, 0, NULL, NULL)
#define OCL_SET_ARG(ID, SIZE, ARG) \
- do { \
- OCL_CALL (clSetKernelArg, kernel, ID, SIZE, ARG); \
- } while (0)
+ OCL_CALL (clSetKernelArg, kernel, ID, SIZE, ARG)
#define OCL_CHECK_IMAGE(DATA, W, H, FILENAME) \
if (cl_check_image(DATA, W, H, FILENAME) == 0) \