cl: Add imperfect CL_DEVICE_OPENCL_C_VERSION check
[piglit.git] / tests / cl / api / enqueue-copy-buffer.c
blob1a18d527977cdf15d0ae8ec56067ed269d9b1003
1 /*
2 * Copyright 2013 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Authors: Tom Stellard <thomas.stellard@amd.com>
27 #include "piglit-framework-cl-api.h"
28 #include "piglit-util-cl.h"
31 PIGLIT_CL_API_TEST_CONFIG_BEGIN
33 config.name = "clEnqueueCopyBuffer";
34 config.version_min = 10;
36 config.run_per_platform = true;
37 config.create_context = true;
39 PIGLIT_CL_API_TEST_CONFIG_END
41 enum piglit_result
42 piglit_cl_test(const int argc,
43 const char **argv,
44 const struct piglit_cl_api_test_config* config,
45 const struct piglit_cl_api_test_env* env)
47 int host_src_buffer[4] = {1, 2, 3, 4};
48 int host_dst_buffer[4] = {0, 0, 0, 0};
49 cl_mem device_src_buffer, device_dst_buffer;
50 cl_command_queue queue = env->context->command_queues[0];
51 cl_int err;
52 int i;
54 device_src_buffer = piglit_cl_create_buffer(
55 env->context, CL_MEM_READ_WRITE, sizeof(host_src_buffer));
56 device_dst_buffer = piglit_cl_create_buffer(
57 env->context, CL_MEM_READ_WRITE, sizeof(host_dst_buffer));
58 if (!piglit_cl_write_whole_buffer(queue,
59 device_src_buffer, host_src_buffer) ||
60 !piglit_cl_write_whole_buffer(queue,
61 device_dst_buffer, host_dst_buffer)) {
62 return PIGLIT_FAIL;
65 err = clEnqueueCopyBuffer(queue, device_src_buffer, device_dst_buffer,
66 0, 0, sizeof(host_src_buffer), 0, NULL, NULL);
67 if (!piglit_cl_check_error(err, CL_SUCCESS)) {
68 return PIGLIT_FAIL;
71 if (!piglit_cl_read_whole_buffer(queue, device_dst_buffer,
72 host_dst_buffer)) {
73 return PIGLIT_FAIL;
76 for (i = 0; i < sizeof(host_src_buffer) / sizeof(host_src_buffer[0]);
77 i++) {
78 if (!piglit_cl_probe_integer(host_dst_buffer[i],
79 host_src_buffer[i], 0)) {
80 fprintf(stderr, "Error at %d\n", i);
81 return PIGLIT_FAIL;
84 return PIGLIT_PASS;