Skip to content

Commit

Permalink
Add clGetDeviceAndHostTimer support check
Browse files Browse the repository at this point in the history
For OpenCL 3.0 clGetDeviceAndHostTimer is an optional feature.
Check whether it is supported in profiling/profiling_timebase

Fixes #753

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 authored and ahesham-arm committed Sep 22, 2024
1 parent b25318f commit 15def81
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
48 changes: 32 additions & 16 deletions test_conformance/profiling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,38 @@
// the following variables (<rdar://problem/11111245>):

test_definition test_list[] = {
ADD_TEST(read_array_int), ADD_TEST(read_array_uint),
ADD_TEST(read_array_long), ADD_TEST(read_array_ulong),
ADD_TEST(read_array_short), ADD_TEST(read_array_ushort),
ADD_TEST(read_array_float), ADD_TEST(read_array_char),
ADD_TEST(read_array_uchar), ADD_TEST(read_array_struct),
ADD_TEST(write_array_int), ADD_TEST(write_array_uint),
ADD_TEST(write_array_long), ADD_TEST(write_array_ulong),
ADD_TEST(write_array_short), ADD_TEST(write_array_ushort),
ADD_TEST(write_array_float), ADD_TEST(write_array_char),
ADD_TEST(write_array_uchar), ADD_TEST(write_array_struct),
ADD_TEST(read_image_float), ADD_TEST(read_image_char),
ADD_TEST(read_image_uchar), ADD_TEST(write_image_float),
ADD_TEST(write_image_char), ADD_TEST(write_image_uchar),
ADD_TEST(copy_array), ADD_TEST(copy_partial_array),
ADD_TEST(copy_image), ADD_TEST(copy_array_to_image),
ADD_TEST(execute), ADD_TEST(profiling_timebase),
ADD_TEST(read_array_int),
ADD_TEST(read_array_uint),
ADD_TEST(read_array_long),
ADD_TEST(read_array_ulong),
ADD_TEST(read_array_short),
ADD_TEST(read_array_ushort),
ADD_TEST(read_array_float),
ADD_TEST(read_array_char),
ADD_TEST(read_array_uchar),
ADD_TEST(read_array_struct),
ADD_TEST(write_array_int),
ADD_TEST(write_array_uint),
ADD_TEST(write_array_long),
ADD_TEST(write_array_ulong),
ADD_TEST(write_array_short),
ADD_TEST(write_array_ushort),
ADD_TEST(write_array_float),
ADD_TEST(write_array_char),
ADD_TEST(write_array_uchar),
ADD_TEST(write_array_struct),
ADD_TEST(read_image_float),
ADD_TEST(read_image_char),
ADD_TEST(read_image_uchar),
ADD_TEST(write_image_float),
ADD_TEST(write_image_char),
ADD_TEST(write_image_uchar),
ADD_TEST(copy_array),
ADD_TEST(copy_partial_array),
ADD_TEST(copy_image),
ADD_TEST(copy_array_to_image),
ADD_TEST(execute),
ADD_TEST_VERSION(profiling_timebase, Version(2, 1)),
};

const int test_num = ARRAY_SIZE( test_list );
Expand Down
22 changes: 16 additions & 6 deletions test_conformance/profiling/profiling_timebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ const char *kernelCode = "__kernel void kernel_empty(){}";
int test_profiling_timebase(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_int err;
Version version = get_device_cl_version(device);
cl_platform_id platform = getPlatformFromDevice(device);
cl_ulong timer_resolution = 0;
cl_int err =
clGetPlatformInfo(platform, CL_PLATFORM_HOST_TIMER_RESOLUTION,
sizeof(timer_resolution), &timer_resolution, NULL);
test_error(err, "Unable to query CL_PLATFORM_HOST_TIMER_RESOLUTION");

// If CL_PLATFORM_HOST_TIMER_RESOLUTION returns 0, clGetDeviceAndHostTimer
// is not a supported feature
if (timer_resolution == 0 && version >= Version(3, 0))
{
return TEST_SKIPPED_ITSELF;
}

cl_ulong hostTime;
clProgramWrapper program;
clKernelWrapper kernel;
Expand Down Expand Up @@ -79,14 +93,10 @@ int test_profiling_timebase(cl_device_id device, cl_context context,
"Device timestamp was taken before kernel was queued");
test_assert_error(eventQueue < deviceTimeAfterQueue,
"Device timestamp was taken after kernel was queued");
test_assert_error(deviceTimeAfterQueue < eventSubmit,
"Device timestamp was taken before kernel was submitted");
test_assert_error(eventSubmit < deviceTimeAfterCompletion,
"Device timestamp was taken after kernel was submitted");
test_assert_error((eventStart < deviceTimeAfterCompletion)
&& (eventEnd < deviceTimeAfterCompletion),
"Device timestamp was taken after kernel was execution");


"Device timestamp was taken after kernel was executed");
return TEST_PASS;
}

0 comments on commit 15def81

Please sign in to comment.