From 4a8cae4ae2aece06859b0fbc7a1933058d88b4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 19 Nov 2019 18:59:04 +0000 Subject: [PATCH] harness: select queue creation function based on OpenCL version (#490) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use clCreateCommandQueue before OpenCL 2.0. This enables most of the binaries to run to completion on a 1.2 implementation. Signed-off-by: Kévin Petit --- test_common/harness/testHarness.c | 47 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/test_common/harness/testHarness.c b/test_common/harness/testHarness.c index 9fbbc5fa..5d0393ba 100644 --- a/test_common/harness/testHarness.c +++ b/test_common/harness/testHarness.c @@ -695,28 +695,7 @@ test_status callSingleTestFunction( test_definition test, cl_device_id deviceToU cl_int error; cl_context context = NULL; cl_command_queue queue = NULL; - const cl_command_queue_properties cmd_queueProps = (queueProps)?CL_QUEUE_PROPERTIES:0; - cl_command_queue_properties queueCreateProps[] = {cmd_queueProps, queueProps, 0}; - /* Create a context to work with, unless we're told not to */ - if( !forceNoContextCreation ) - { - context = clCreateContext(NULL, 1, &deviceToUse, notify_callback, NULL, &error ); - if (!context) - { - print_error( error, "Unable to create testing context" ); - return TEST_FAIL; - } - - queue = clCreateCommandQueueWithProperties( context, deviceToUse, &queueCreateProps[0], &error ); - if( queue == NULL ) - { - print_error( error, "Unable to create testing command queue" ); - return TEST_FAIL; - } - } - - /* Run the test and print the result */ log_info( "%s...\n", test.name ); fflush( stdout ); @@ -728,6 +707,32 @@ test_status callSingleTestFunction( test_definition test, cl_device_id deviceToU return TEST_SKIP; } + /* Create a context to work with, unless we're told not to */ + if( !forceNoContextCreation ) + { + context = clCreateContext(NULL, 1, &deviceToUse, notify_callback, NULL, &error ); + if (!context) + { + print_error( error, "Unable to create testing context" ); + return TEST_FAIL; + } + + if (device_version < Version(2, 0)) { + queue = clCreateCommandQueue(context, deviceToUse, queueProps, &error); + } else { + const cl_command_queue_properties cmd_queueProps = (queueProps)?CL_QUEUE_PROPERTIES:0; + cl_command_queue_properties queueCreateProps[] = {cmd_queueProps, queueProps, 0}; + queue = clCreateCommandQueueWithProperties( context, deviceToUse, &queueCreateProps[0], &error ); + } + + if( queue == NULL ) + { + print_error( error, "Unable to create testing command queue" ); + return TEST_FAIL; + } + } + + /* Run the test and print the result */ error = check_functions_for_offline_compiler(test.name, deviceToUse); test_missing_support_offline_cmpiler(error, test.name);