From 6b14d408dc8cc0a05bca554e8b43d269fba179d0 Mon Sep 17 00:00:00 2001 From: Stuart Brady Date: Thu, 10 Feb 2022 06:24:33 +0000 Subject: [PATCH] Improve testing of kernel arg info in pipe_info test (#1326) The test now checks that CL_KERNEL_ARG_INFO_NOT_AVAILABLE is returned when calling clGetKernelArgInfo() with offline compilation modes. The correct function name is printed if clGetKernelArgInfo() fails when using online compilation (and not "clSetKernelArgInfo()"). When using online compilation, if the actual arg type is not as expected, the actual arg type is now logged, and the return value is now TEST_FAIL (-1) as per other failures (and not 1). All other test pass/fail values used in the test now use TEST_PASS and TEST_FAIL instead of 0 and -1 literals. An unnecessary cast of pipe_kernel_code has been removed. Signed-off-by: Stuart Brady --- test_conformance/pipes/test_pipe_info.cpp | 40 ++++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/test_conformance/pipes/test_pipe_info.cpp b/test_conformance/pipes/test_pipe_info.cpp index 7543c6cd..e7b486db 100644 --- a/test_conformance/pipes/test_pipe_info.cpp +++ b/test_conformance/pipes/test_pipe_info.cpp @@ -14,6 +14,7 @@ // limitations under the License. // #include "procs.h" +#include "harness/parseParameters.h" const char* pipe_kernel_code = { "__kernel void pipe_kernel(__write_only pipe int out_pipe)\n" @@ -39,8 +40,7 @@ int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue if (pipe_width != returnVal) { - log_error("Error in clGetPipeInfo() check of pipe packet size\n"); - return -1; + test_fail("Error in clGetPipeInfo() check of pipe packet size\n"); } else { @@ -52,29 +52,37 @@ int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue if(pipe_depth != returnVal) { - log_error( "Error in clGetPipeInfo() check of pipe max packets\n" ); - return -1; + test_fail("Error in clGetPipeInfo() check of pipe max packets\n"); } else { log_info( " CL_PIPE_MAX_PACKETS passed.\n" ); } - err = create_single_kernel_helper_with_build_options(context, &program, &kernel, 1, (const char**)&pipe_kernel_code, "pipe_kernel", "-cl-std=CL2.0 -cl-kernel-arg-info"); - test_error_ret(err, " Error creating program", -1); + err = create_single_kernel_helper_with_build_options( + context, &program, &kernel, 1, &pipe_kernel_code, "pipe_kernel", + "-cl-std=CL2.0 -cl-kernel-arg-info"); + test_error_fail(err, "Error creating program"); cl_kernel_arg_type_qualifier arg_type_qualifier = 0; - cl_kernel_arg_type_qualifier expected_type_qualifier = CL_KERNEL_ARG_TYPE_PIPE; - err = clGetKernelArgInfo( kernel, 0, CL_KERNEL_ARG_TYPE_QUALIFIER, sizeof(arg_type_qualifier), &arg_type_qualifier, NULL ); - test_error_ret(err, " clSetKernelArgInfo failed", -1); - err = (arg_type_qualifier != expected_type_qualifier); - - if(err) + err = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_TYPE_QUALIFIER, + sizeof(arg_type_qualifier), &arg_type_qualifier, + NULL); + if (gCompilationMode == kOnline) { - print_error(err, "ERROR: Bad type qualifier\n"); - return -1; + test_error_fail(err, "clGetKernelArgInfo failed"); + if (arg_type_qualifier != CL_KERNEL_ARG_TYPE_PIPE) + { + test_fail("ERROR: Incorrect type qualifier: %i\n", + arg_type_qualifier); + } + } + else + { + test_failure_error_ret(err, CL_KERNEL_ARG_INFO_NOT_AVAILABLE, + "clGetKernelArgInfo error not as expected", + TEST_FAIL); } - return err; - + return TEST_PASS; }