[Piglit] [PATCH 3/3] cl: add CL_MEM_HOST_* releated tests

EdB edb+piglit at sigluy.net
Mon Nov 10 06:25:01 PST 2014


---
 tests/cl/api/enqueue-map-buffer.c        | 111 +++++++++++++++++++++++++++++++
 tests/cl/api/enqueue-read_write-buffer.c |  49 +++++++++++++-
 2 files changed, 158 insertions(+), 2 deletions(-)

diff --git a/tests/cl/api/enqueue-map-buffer.c b/tests/cl/api/enqueue-map-buffer.c
index 214ef7f..13a2511 100644
--- a/tests/cl/api/enqueue-map-buffer.c
+++ b/tests/cl/api/enqueue-map-buffer.c
@@ -118,5 +118,116 @@ piglit_cl_test(const int argc,
 		return PIGLIT_FAIL;
 	}
 
+#if defined(CL_VERSION_1_2)
+	/*
+	 * CL_INVALID_OPERATION if buffer has been created with
+	 * CL_MEM_HOST_WRITE_ONLY or CL_MEM_HOST_NO_ACCESS
+	 * and CL_MAP_READ is set in map_flags
+	 *
+	 * CL_INVALID_OPERATION if buffer has been created with
+	 * CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_NO_ACCESS
+	 * and CL_MAP_WRITE or CL_MAP_WRITE_INVALIDATE_REGION is set in map_flags.
+	 *
+	 * Version: 1.2
+	 */
+	if(env->version >= 12) {
+		enum piglit_result result;
+		cl_mem device_mem;
+		cl_ulong alloc_size = 64;
+		cl_int *host_mem;
+
+		/* host write only buffer */
+
+		device_mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_WRITE_ONLY,
+		                            alloc_size, NULL, NULL);
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_READ, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_READ: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_READ_ONLY");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		clReleaseMemObject(device_mem);
+
+		/* host no access buffer */
+
+		device_mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_NO_ACCESS,
+		                            alloc_size, NULL, NULL);
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_READ, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_READ: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_NO_ACCESS");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_WRITE, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_WRITE: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_NO_ACCESS");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_WRITE_INVALIDATE_REGION, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_WRITE_INVALIDATE_REGION: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_NO_ACCESS");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		clReleaseMemObject(device_mem);
+
+		/* host read only buffer */
+
+		device_mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_READ_ONLY,
+		                            alloc_size, NULL, NULL);
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_WRITE, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_WRITE: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_NO_ACCESS");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		host_mem = clEnqueueMapBuffer(queue, device_mem, CL_TRUE,
+		                              CL_MAP_WRITE_INVALIDATE_REGION, 0, alloc_size,
+		                              0, NULL, NULL, &err);
+
+		if (!piglit_cl_check_error(err, CL_INVALID_OPERATION)) {
+			fprintf(stderr, "clEnqueueMapBuffer CL_MAP_WRITE_INVALIDATE_REGION: Failed (error code: %s): %s.\n",
+			        piglit_cl_get_error_name(err),
+			        "Trigger CL_INVALID_OPERATION when buffer has been created with CL_MEM_HOST_NO_ACCESS");
+			piglit_merge_result(&result, PIGLIT_FAIL);
+		}
+
+		(void)host_mem;
+		clReleaseMemObject(device_mem);
+
+		if (result == PIGLIT_FAIL)
+			return PIGLIT_FAIL;
+	}
+#endif //CL_VERSION_1_2
+
 	return PIGLIT_PASS;
 }
diff --git a/tests/cl/api/enqueue-read_write-buffer.c b/tests/cl/api/enqueue-read_write-buffer.c
index f98125c..c7ca9a4 100644
--- a/tests/cl/api/enqueue-read_write-buffer.c
+++ b/tests/cl/api/enqueue-read_write-buffer.c
@@ -514,16 +514,61 @@ piglit_cl_test(const int argc,
 	 * Version: 1.1
 	 * TODO
 	 */
+
+	clReleaseMemObject(mem);
+
+#if defined(CL_VERSION_1_2)
 	/*
 	 * CL_INVALID_OPERATION if clEnqueueReadBuffer is called on
 	 * buffer which has been created with CL_MEM_HOST_WRITE_ONLY
 	 * or CL_MEM_HOST_NO_ACCESS.
 	 *
+	 * CL_INVALID_OPERATION if clEnqueueWriteBuffer is called on
+	 * buffer which has been created with CL_MEM_HOST_READ_ONLY
+	 * or CL_MEM_HOST_NO_ACCESS.
+	 *
 	 * Version: 1.2
-	 * TODO
 	 */
+	if(env->version >= 12) {
+		/* create host write only buffer */
+		mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_WRITE_ONLY, alloc_size,
+		                     NULL, NULL);
 
-	clReleaseMemObject(mem);
+		test_read(env->context->command_queues[0], mem, true, 0,
+		          BUFFER_SIZE, host_buffer_read, 0, NULL, NULL,
+		          CL_INVALID_OPERATION, &result,
+		          "Trigger CL_INVALID_OPERATION when clEnqueueReadBuffer is called on buffer which has been created with CL_MEM_HOST_WRITE_ONLY");
+
+		clReleaseMemObject(mem);
+
+		/* create host no access buffer */
+		mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_NO_ACCESS, alloc_size,
+		                     NULL, NULL);
+
+		test_read(env->context->command_queues[0], mem, true, 0,
+		          BUFFER_SIZE, host_buffer_read, 0, NULL, NULL,
+		          CL_INVALID_OPERATION, &result,
+		          "Trigger CL_INVALID_OPERATION when clEnqueueReadBuffer is called on buffer which has been created with CL_MEM_HOST_NO_ACCESS");
+
+		test_write(env->context->command_queues[0], mem, true, 0,
+		           BUFFER_SIZE, host_buffer_write, 0, NULL, NULL,
+		           CL_INVALID_OPERATION, &result,
+		           "Trigger CL_INVALID_OPERATION when clEnqueueWriteBuffer is called on buffer which has been created with CL_MEM_HOST_NO_ACCESS");
+
+		clReleaseMemObject(mem);
+
+		/* create host read only buffer */
+		mem = clCreateBuffer(env->context->cl_ctx, CL_MEM_HOST_READ_ONLY, alloc_size,
+		                     NULL, NULL);
+
+		test_write(env->context->command_queues[0], mem, true, 0,
+		           BUFFER_SIZE, host_buffer_write, 0, NULL, NULL,
+		           CL_INVALID_OPERATION, &result,
+		           "Trigger CL_INVALID_OPERATION when clEnqueueWriteBuffer is called on buffer which has been created with CL_MEM_HOST_READ_ONLY");
+
+		clReleaseMemObject(mem);
+	}
+#endif //CL_VERSION_1_2
 
 	return result;
 }
-- 
1.9.3



More information about the Piglit mailing list