summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-03-14 14:58:09 -0400
committerTom Stellard <thomas.stellard@amd.com>2012-03-14 14:58:09 -0400
commit83f44eaf94939d126d6c4daf866c40a2778d561b (patch)
tree6e9e96d555c4f6760531cf9f8b38c4b1be7793bd
parent8dc546eced1d35424853d25834e482c611e9f6ca (diff)
add clTestReadOutput
-rw-r--r--get_global_id.c28
-rw-r--r--util.c22
-rw-r--r--util.h2
3 files changed, 25 insertions, 27 deletions
diff --git a/get_global_id.c b/get_global_id.c
index 0f64192..84e6fb9 100644
--- a/get_global_id.c
+++ b/get_global_id.c
@@ -23,37 +23,11 @@ int main(int argc, char ** argv)
context.kernel,
1, &global_work_size, &global_work_size);
- error = clEnqueueReadBuffer(context.command_queue,
- context.out_buffer,
- CL_TRUE, /* TRUE means it is a blocking read. */
- 0, /* Buffer offset to read from. */
- sizeof(out_data), /* Bytes to read */
- out_data, /* Pointer to store the data */
- 0, /* Events in wait list */
- NULL, /* Wait list */
- NULL); /* Event object */
-
-
- if (error != CL_SUCCESS) {
- fprintf(stderr, "clEnqueueReadBuffer() failed: %s\n",
- clTestErrorString(error));
- return EXIT_FAILURE;
- }
+ clTestReadOutput(&context, out_data, sizeof(out_data));
- fprintf(stderr, "clEnqueueReadBuffer() suceeded.\n");
for (i = 0; i < 10; i++) {
fprintf(stderr, "id %u = %u\n", i, out_data[i]);
}
-/*
-
- if (out_value == expected) {
- fprintf(stderr, "Pass\n");
- return EXIT_SUCCESS;
- } else {
- fprintf(stderr, "Expected %d, but got %d\n", expected, out_value);
- return EXIT_FAILURE;
- }
-*/
}
diff --git a/util.c b/util.c
index 766f1c4..1bfd975 100644
--- a/util.c
+++ b/util.c
@@ -317,3 +317,25 @@ unsigned clTestEnqueueNDRangeKernel(cl_command_queue command_queue,
return 1;
}
+
+unsigned clTestReadOutput(struct cltest_context * context, void * data,
+ size_t data_bytes)
+{
+ cl_int error = clEnqueueReadBuffer(context->command_queue,
+ context->out_buffer,
+ CL_TRUE, /* TRUE means it is a blocking read. */
+ 0, /* Buffer offset to read from. */
+ data_bytes, /* Bytes to read */
+ data, /* Pointer to store the data */
+ 0, /* Events in wait list */
+ NULL, /* Wait list */
+ NULL); /* Event object */
+
+ if (error != CL_SUCCESS) {
+ fprintf(stderr, "clEnqueueReadBuffer() failed: %s\n",
+ clTestErrorString(error));
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/util.h b/util.h
index ecaab60..4d30690 100644
--- a/util.h
+++ b/util.h
@@ -21,3 +21,5 @@ unsigned clTestKernelSetArg(cl_kernel kernel, cl_uint index, size_t size,
unsigned clTestEnqueueNDRangeKernel(cl_command_queue command_queue,
cl_kernel kernel, cl_uint work_dim, const size_t * global_work_size,
const size_t * local_work_size);
+unsigned clTestReadOutput(struct cltest_context * context, void * data,
+ size_t data_bytes);