Skip to content

Commit

Permalink
[NFC] Migrate profiling suite to new registration framework
Browse files Browse the repository at this point in the history
Contributes to KhronosGroup#2181

Signed-off-by: Kevin Petit <[email protected]>
  • Loading branch information
kpet committed Dec 13, 2024
1 parent 5b7af4b commit 9ecca0f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 126 deletions.
8 changes: 4 additions & 4 deletions test_conformance/profiling/copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static int copy_partial_size( cl_device_id device, cl_context context, cl_comman
} // end copy_partial_size()


int test_copy_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(copy_array)
{
int i, err = 0;
int size;
Expand All @@ -405,7 +405,7 @@ int test_copy_array( cl_device_id device, cl_context context, cl_command_queue q
} // end copy_array()


int test_copy_partial_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(copy_partial_array)
{
int i, err = 0;
int size;
Expand Down Expand Up @@ -681,7 +681,7 @@ static int copy_image_size( cl_device_id device, cl_context context,
} // end copy_image_size()


int test_copy_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(copy_image)
{
int err = 0;
int i;
Expand Down Expand Up @@ -754,7 +754,7 @@ int test_copy_image( cl_device_id device, cl_context context, cl_command_queue q
} // end copy_image()


int test_copy_array_to_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(copy_array_to_image)
{
cl_mem memobjs[3];
cl_image_format image_format_desc = { CL_RGBA, CL_UNORM_INT8 };
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/profiling/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static int basicFilter( int w, int h, int nChannels, uchar *inptr, uchar *outptr
} // end of basicFilter()


int test_execute( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(execute)
{
uchar *inptr;
uchar *outptr[2];
Expand Down
2 changes: 1 addition & 1 deletion test_conformance/profiling/execute_multipass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue
// use 3d to exercise the multipass events. In the future 3d may not be multpass, in which
// case we will need to ensure that we use gdims large enough to force multipass.

int execute_multipass( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(execute_multipass)
{
cl_uchar *inptr;
cl_uchar *outptr;
Expand Down
41 changes: 2 additions & 39 deletions test_conformance/profiling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,12 @@
#include <stdio.h>
#include <string.h>
#include <cinttypes>
#include "procs.h"
#include "harness/testHarness.h"

// FIXME: To use certain functions in harness/imageHelpers.h
// (for example, generate_random_image_data()), the tests are required to declare
// 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_VERSION(profiling_timebase, Version(2, 1)),
};

const int test_num = ARRAY_SIZE( test_list );

// FIXME: use timer resolution rather than hardcoding 1µs per tick.

#define QUEUE_SECONDS_LIMIT 30
Expand Down Expand Up @@ -133,7 +95,8 @@ int check_times(cl_ulong queueStart, cl_ulong commandSubmit, cl_ulong commandSta

int main( int argc, const char *argv[] )
{
return runTestHarness(argc, argv, test_num, test_list, false,
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false,
CL_QUEUE_PROFILING_ENABLE);
}

39 changes: 0 additions & 39 deletions test_conformance/profiling/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,8 @@
#include "harness/imageHelpers.h"
#include "harness/mt19937.h"


extern int check_times(cl_ulong queueStart, cl_ulong submitStart, cl_ulong commandStart, cl_ulong commandEnd, cl_device_id device);

extern int test_read_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_read_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_write_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_copy_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_copy_partial_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_copy_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_copy_array_to_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_execute( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_parallel_kernels( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements );
extern int test_profiling_timebase(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);


#endif // #ifndef __PROCS_H__


3 changes: 1 addition & 2 deletions test_conformance/profiling/profiling_timebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

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)
REGISTER_TEST(profiling_timebase)
{
Version version = get_device_cl_version(device);
cl_platform_id platform = getPlatformFromDevice(device);
Expand Down
22 changes: 11 additions & 11 deletions test_conformance/profiling/readArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ int test_stream_read( cl_device_id device, cl_context context, cl_command_queue
} // end test_stream_read()


int test_read_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_int)
{
int (*foo)(void *,int);
foo = verify_read_int;
Expand All @@ -768,7 +768,7 @@ int test_read_array_int( cl_device_id device, cl_context context, cl_command_que
}


int test_read_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_uint)
{
int (*foo)(void *,int);
foo = verify_read_uint;
Expand All @@ -778,7 +778,7 @@ int test_read_array_uint( cl_device_id device, cl_context context, cl_command_qu
}


int test_read_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_long)
{
int (*foo)(void *,int);
foo = verify_read_long;
Expand All @@ -794,7 +794,7 @@ int test_read_array_long( cl_device_id device, cl_context context, cl_command_qu
}


int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_ulong)
{
int (*foo)(void *,int);
foo = verify_read_ulong;
Expand All @@ -810,7 +810,7 @@ int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_q
}


int test_read_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_short)
{
int (*foo)(void *,int);
foo = verify_read_short;
Expand All @@ -820,7 +820,7 @@ int test_read_array_short( cl_device_id device, cl_context context, cl_command_q
}


int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_ushort)
{
int (*foo)(void *,int);
foo = verify_read_ushort;
Expand All @@ -830,7 +830,7 @@ int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_
}


int test_read_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_float)
{
int (*foo)(void *,int);
foo = verify_read_float;
Expand All @@ -840,7 +840,7 @@ int test_read_array_float( cl_device_id device, cl_context context, cl_command_q
}


int test_read_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_half)
{
int (*foo)(void *,int);
foo = verify_read_half;
Expand All @@ -850,7 +850,7 @@ int test_read_array_half( cl_device_id device, cl_context context, cl_command_qu
}


int test_read_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_char)
{
int (*foo)(void *,int);
foo = verify_read_char;
Expand All @@ -860,7 +860,7 @@ int test_read_array_char( cl_device_id device, cl_context context, cl_command_qu
}


int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_uchar)
{
int (*foo)(void *,int);
foo = verify_read_uchar;
Expand All @@ -870,7 +870,7 @@ int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_q
}


int test_read_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
REGISTER_TEST(read_array_struct)
{
int (*foo)(void *,int);
foo = verify_read_struct;
Expand Down
18 changes: 9 additions & 9 deletions test_conformance/profiling/readImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,33 +339,33 @@ int read_image( cl_device_id device, cl_context context, cl_command_queue queue,
} // end read_image()


int test_read_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
REGISTER_TEST(read_image_float)
{
cl_image_format image_format_desc = { CL_RGBA, CL_UNORM_INT8 };
PASSIVE_REQUIRE_IMAGE_SUPPORT( device )
// 0 to 255 for unsigned image data
return read_image( device, context, queue, numElements, readKernelCode[0], readKernelName[0], image_format_desc );

return read_image(device, context, queue, num_elements, readKernelCode[0],
readKernelName[0], image_format_desc);
}


int test_read_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
REGISTER_TEST(read_image_char)
{
cl_image_format image_format_desc = { CL_RGBA, CL_SIGNED_INT8 };
PASSIVE_REQUIRE_IMAGE_SUPPORT( device )
// -128 to 127 for signed iamge data
return read_image( device, context, queue, numElements, readKernelCode[1], readKernelName[1], image_format_desc );

return read_image(device, context, queue, num_elements, readKernelCode[1],
readKernelName[1], image_format_desc);
}


int test_read_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
REGISTER_TEST(read_image_uchar)
{
cl_image_format image_format_desc = { CL_RGBA, CL_UNSIGNED_INT8 };
PASSIVE_REQUIRE_IMAGE_SUPPORT( device )
// 0 to 255 for unsigned image data
return read_image( device, context, queue, numElements, readKernelCode[2], readKernelName[2], image_format_desc );

return read_image(device, context, queue, num_elements, readKernelCode[2],
readKernelName[2], image_format_desc);
}


Loading

0 comments on commit 9ecca0f

Please sign in to comment.