diff --git a/test_conformance/basic/test_enqueued_local_size.cpp b/test_conformance/basic/test_enqueued_local_size.cpp index 91fe1434..ea95df68 100644 --- a/test_conformance/basic/test_enqueued_local_size.cpp +++ b/test_conformance/basic/test_enqueued_local_size.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 The Khronos Group Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -26,32 +26,33 @@ #include "procs.h" -static const char *enqueued_local_size_2d_code = -"__kernel void test_enqueued_local_size_2d(global int *dst)\n" -"{\n" -" if ((get_global_id(0) == 0) && (get_global_id(1) == 0))\n" -" {\n" -" dst[0] = (int)get_enqueued_local_size(0)\n;" -" dst[1] = (int)get_enqueued_local_size(1)\n;" -" }\n" -"}\n"; +static const char *enqueued_local_size_2d_code = R"( +__kernel void test_enqueued_local_size_2d(global int *dst) +{ + if ((get_global_id(0) == 0) && (get_global_id(1) == 0)) + { + dst[0] = (int)get_enqueued_local_size(0); + dst[1] = (int)get_enqueued_local_size(1); + } +} +)"; -static const char *enqueued_local_size_1d_code = -"__kernel void test_enqueued_local_size_1d(global int *dst)\n" -"{\n" -" int tid_x = get_global_id(0);\n" -" if (get_global_id(0) == 0)\n" -" {\n" -" dst[tid_x] = (int)get_enqueued_local_size(0)\n;" -" }\n" -"}\n"; +static const char *enqueued_local_size_1d_code = R"( +__kernel void test_enqueued_local_size_1d(global int *dst) +{ + int tid_x = get_global_id(0); + if (get_global_id(0) == 0) + { + dst[tid_x] = (int)get_enqueued_local_size(0); + } +} +)"; -static int -verify_enqueued_local_size(int *result, size_t *expected, int n) +static int verify_enqueued_local_size(int *result, size_t *expected, int n) { int i; - for (i=0; i(num_elements); + globalsize[1] = static_cast(num_elements); size_t max_wgs; - err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(max_wgs), &max_wgs, NULL); - test_error( err, "clGetDeviceInfo failed."); + err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, + sizeof(max_wgs), &max_wgs, nullptr); + test_error(err, "clGetDeviceInfo failed."); localsize[0] = std::min(16, max_wgs); localsize[1] = std::min(11, max_wgs / localsize[0]); @@ -143,35 +143,31 @@ test_enqueued_local_size(cl_device_id device, cl_context context, cl_command_que } } - err = clEnqueueNDRangeKernel(queue, kernel[1], 2, NULL, globalsize, localsize, 0, NULL, NULL); - test_error( err, "clEnqueueNDRangeKernel failed."); + err = clEnqueueNDRangeKernel(queue, kernel[1], 2, nullptr, globalsize, + localsize, 0, nullptr, nullptr); + test_error(err, "clEnqueueNDRangeKernel failed."); - err = clEnqueueReadBuffer(queue, streams, CL_TRUE, 0, 2*sizeof(int), output_ptr, 0, NULL, NULL); - test_error( err, "clEnqueueReadBuffer failed."); + err = clEnqueueReadBuffer(queue, stream, CL_BLOCKING, 0, 2 * sizeof(int), + output_ptr, 0, nullptr, nullptr); + test_error(err, "clEnqueueReadBuffer failed."); err = verify_enqueued_local_size(output_ptr, localsize, 2); - globalsize[0] = (size_t)num_elements; + globalsize[0] = static_cast(num_elements); localsize[0] = 9; if (use_uniform_work_groups && (globalsize[0] % localsize[0])) { globalsize[0] += (localsize[0] - (globalsize[0] % localsize[0])); } - err = clEnqueueNDRangeKernel(queue, kernel[1], 1, NULL, globalsize, localsize, 0, NULL, NULL); - test_error( err, "clEnqueueNDRangeKernel failed."); + err = clEnqueueNDRangeKernel(queue, kernel[1], 1, nullptr, globalsize, + localsize, 0, nullptr, nullptr); + test_error(err, "clEnqueueNDRangeKernel failed."); - err = clEnqueueReadBuffer(queue, streams, CL_TRUE, 0, 2*sizeof(int), output_ptr, 0, NULL, NULL); - test_error( err, "clEnqueueReadBuffer failed."); + err = clEnqueueReadBuffer(queue, stream, CL_BLOCKING, 0, 2 * sizeof(int), + output_ptr, 0, nullptr, nullptr); + test_error(err, "clEnqueueReadBuffer failed."); err = verify_enqueued_local_size(output_ptr, localsize, 1); - // cleanup - clReleaseMemObject(streams); - clReleaseKernel(kernel[0]); - clReleaseKernel(kernel[1]); - clReleaseProgram(program[0]); - clReleaseProgram(program[1]); - free(output_ptr); - return err; }