// // 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include "testBase.h" #include "harness/typeWrappers.h" #include "harness/testHarness.h" #include "harness/conversions.h" const char *test_kernels[] = { "__kernel void kernelA(__global uint *dst)\n" "{\n" "\n" " dst[get_global_id(0)]*=3;\n" "\n" "}\n" "__kernel void kernelB(__global uint *dst)\n" "{\n" "\n" " dst[get_global_id(0)]++;\n" "\n" "}\n" }; #define TEST_SIZE 512 #define MAX_DEVICES 32 #define MAX_QUEUES 1000 int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices, int num_elements) { int error; clContextWrapper context; clProgramWrapper program; clKernelWrapper kernels[2]; clMemWrapper stream; clCommandQueueWrapper queues[MAX_QUEUES]; size_t threads[1], localThreads[1]; cl_uint data[TEST_SIZE]; cl_uint outputData[TEST_SIZE]; cl_uint expectedResults[TEST_SIZE]; cl_uint expectedResultsOneDevice[MAX_DEVICES][TEST_SIZE]; size_t i; memset(queues, 0, sizeof(queues)); RandomSeed seed( gRandomSeed ); if (deviceCount > MAX_DEVICES) { log_error("Number of devices in set (%ld) is greater than the number for which the test was written (%d).", deviceCount, MAX_DEVICES); return -1; } if (queueCount > MAX_QUEUES) { log_error("Number of queues (%ld) is greater than the number for which the test was written (%d).", queueCount, MAX_QUEUES); return -1; } log_info("Testing with %ld queues on %ld devices, %ld kernel executions.\n", queueCount, deviceCount, queueCount*num_elements/TEST_SIZE); for (i=0; i 2) { log_info("Note: got %d devices, using just the first two.\n", (int)numDevices); } /* Run test */ return test_device_set( 2, 2, devices, num_elements ); } int test_max_devices(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { cl_platform_id platform; cl_device_id devices[MAX_DEVICES]; cl_uint deviceCount; int err; err = clGetPlatformIDs(1, &platform, NULL); test_error( err, "Unable to get platform" ); /* Get some devices */ err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, &deviceCount ); test_error( err, "Unable to get multiple devices" ); log_info("Testing with %d devices.", deviceCount); /* Run test */ return test_device_set( deviceCount, deviceCount, devices, num_elements ); } int test_hundred_queues(cl_device_id device, cl_context contextIgnore, cl_command_queue queueIgnore, int num_elements) { return test_device_set( 1, 100, &device, num_elements ); }