summaryrefslogtreecommitdiff
path: root/utests/utest_helper.hpp
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo@intel.com>2016-04-23 00:37:18 +0800
committerYang Rong <rong.r.yang@intel.com>2016-04-22 18:13:01 +0800
commit0eebe2536c8e76cd20867d1ca00ba4735736f629 (patch)
tree97b06ecf8d59cd8994d89ddbfe78f82773cfa413 /utests/utest_helper.hpp
parent2d5c0576f0bdf2ad739f3778623b85d15465ec83 (diff)
downloadbeignet-0eebe2536c8e76cd20867d1ca00ba4735736f629.tar.gz
standalone utest for unified OpenCL implementation.
use the variable NOT_BUILD_STAND_ALONE_UTEST to control the build type: for beignet build, set it to 1; for stand alone build, do NOT need set it. remove all clXXXIntel extension call and such kind of tests since we intend to provide the unit test independently for viariant OpenCL implementation; replace the clMapBufferIntel/clMapBufferGTTIntel with clEnqueueMapBuffer/clEnqueueMapImage; link the utest binary to libOpenCL to follow the icd standard; remove the useless env in setenv.sh since we need make install the package after build. v2: fix the indent error; use function pointer for extesion case like vme and libva since we link to libOpenCL; v3: builtin_kernel_block_motion_estimate_intel released kernel twice; v4: find OpenCL library for standalone utest and link to libcl for not standalone utest; check default variables in setenv.sh whether empty before use. Signed-off-by: Luo Xionghu <xionghu.luo@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests/utest_helper.hpp')
-rw-r--r--utests/utest_helper.hpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 251fbcfe..70b983b9 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -123,24 +123,58 @@ extern EGLSurface eglSurface;
#define OCL_CREATE_SAMPLER(SAMPLER, ADDRESS_MODE, FILTER_MODE) \
OCL_CALL2(clCreateSampler, SAMPLER, ctx, 0, ADDRESS_MODE, FILTER_MODE)
+#define OCL_CALL_MAP(FN, ID, RET, ...) \
+ do { \
+ cl_int status; \
+ size_t size = 0; \
+ status = clGetMemObjectInfo(buf[ID], CL_MEM_SIZE, sizeof(size), &size, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ RET = FN(__VA_ARGS__, CL_TRUE, CL_MAP_READ, 0, size, 0, NULL, NULL, &status);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ } while (0)
+
#define OCL_MAP_BUFFER(ID) \
- OCL_CALL2(clMapBufferIntel, buf_data[ID], buf[ID])
+ OCL_CALL_MAP(clEnqueueMapBuffer, ID, buf_data[ID], queue, buf[ID])
#define OCL_UNMAP_BUFFER(ID) \
do { \
if (buf[ID] != NULL) { \
- OCL_CALL (clUnmapBufferIntel, buf[ID]); \
+ OCL_CALL (clEnqueueUnmapMemObject, queue, buf[ID], buf_data[ID], 0, NULL, NULL); \
buf_data[ID] = NULL; \
} \
} while (0)
+#define OCL_CALL_MAP_GTT(FN, ID, RET, ...) \
+ do { \
+ cl_int status; \
+ size_t image_row_pitch = 0; \
+ status = clGetImageInfo(buf[ID], CL_IMAGE_ROW_PITCH, sizeof(image_row_pitch), &image_row_pitch, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ size_t image_slice_pitch = 0; \
+ status = clGetImageInfo(buf[ID], CL_IMAGE_ROW_PITCH, sizeof(image_slice_pitch), &image_slice_pitch, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ size_t image_width = 0; \
+ status = clGetImageInfo(buf[ID], CL_IMAGE_WIDTH, sizeof(image_width), &image_width, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ size_t image_height = 0; \
+ status = clGetImageInfo(buf[ID], CL_IMAGE_HEIGHT, sizeof(image_height), &image_height, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ size_t image_depth= 0; \
+ status = clGetImageInfo(buf[ID], CL_IMAGE_DEPTH, sizeof(image_depth), &image_depth, NULL);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ size_t origin[3] = {0, 0, 0}; \
+ size_t region[3] = {image_width, image_height, image_depth}; \
+ RET = FN(__VA_ARGS__, CL_TRUE, CL_MAP_READ, origin, region, &image_row_pitch, &image_slice_pitch, 0, NULL, NULL, &status);\
+ if (status != CL_SUCCESS) OCL_THROW_ERROR(FN, status); \
+ } while (0)
+
#define OCL_MAP_BUFFER_GTT(ID) \
- OCL_CALL2(clMapBufferGTTIntel, buf_data[ID], buf[ID])
+ OCL_CALL_MAP_GTT(clEnqueueMapImage, ID, buf_data[ID], queue, buf[ID])
#define OCL_UNMAP_BUFFER_GTT(ID) \
do { \
if (buf[ID] != NULL) { \
- OCL_CALL (clUnmapBufferGTTIntel, buf[ID]); \
+ OCL_CALL (clEnqueueUnmapMemObject, queue, buf[ID], buf_data[ID], 0, NULL, NULL); \
buf_data[ID] = NULL; \
} \
} while (0)