mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Migrate buffers suite to the new test registration framework (#2315)
Contributes to #2181. Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <CL/cl_half.h>
|
||||
|
||||
#include "procs.h"
|
||||
#include "testBase.h"
|
||||
|
||||
//#define HK_DO_NOT_RUN_SHORT_ASYNC 1
|
||||
//#define HK_DO_NOT_RUN_USHORT_ASYNC 1
|
||||
@@ -618,8 +618,11 @@ static int verify_read_struct(TestStruct *outptr, int n)
|
||||
}
|
||||
|
||||
//----- the test functions
|
||||
int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[],
|
||||
int (*fn)(void *, int))
|
||||
{
|
||||
void *outptr[5];
|
||||
void *inptr[5];
|
||||
@@ -758,8 +761,12 @@ int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
|
||||
} // end test_buffer_read()
|
||||
|
||||
int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read_async(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements,
|
||||
size_t size, char *type, int loops,
|
||||
const char *kernelCode[],
|
||||
const char *kernelName[],
|
||||
int (*fn)(void *, int))
|
||||
{
|
||||
clProgramWrapper program[5];
|
||||
clKernelWrapper kernel[5];
|
||||
@@ -894,8 +901,10 @@ int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_comman
|
||||
} // end test_buffer_read_array_async()
|
||||
|
||||
|
||||
int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) )
|
||||
static int test_buffer_read_array_barrier(
|
||||
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||
int num_elements, size_t size, char *type, int loops,
|
||||
const char *kernelCode[], const char *kernelName[], int (*fn)(void *, int))
|
||||
{
|
||||
clProgramWrapper program[5];
|
||||
clKernelWrapper kernel[5];
|
||||
@@ -1033,12 +1042,14 @@ int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, c
|
||||
} // end test_buffer_read_array_barrier()
|
||||
|
||||
|
||||
#define DECLARE_READ_TEST(type, realType) \
|
||||
int test_buffer_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_READ_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_##type) \
|
||||
{ \
|
||||
return test_buffer_read(device, context, queue, num_elements, \
|
||||
sizeof(realType), (char *)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_READ_TEST(int, cl_int)
|
||||
DECLARE_READ_TEST(uint, cl_uint)
|
||||
@@ -1050,21 +1061,24 @@ DECLARE_READ_TEST(float, cl_float)
|
||||
DECLARE_READ_TEST(char, cl_char)
|
||||
DECLARE_READ_TEST(uchar, cl_uchar)
|
||||
|
||||
int test_buffer_read_half(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_half)
|
||||
{
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(deviceID)
|
||||
return test_buffer_read( deviceID, context, queue, num_elements, sizeof( cl_float ) / 2, (char*)"half", 5,
|
||||
buffer_read_half_kernel_code, half_kernel_name, verify_read_half );
|
||||
PASSIVE_REQUIRE_FP16_SUPPORT(device)
|
||||
return test_buffer_read(device, context, queue, num_elements,
|
||||
sizeof(cl_float) / 2, (char *)"half", 5,
|
||||
buffer_read_half_kernel_code, half_kernel_name,
|
||||
verify_read_half);
|
||||
}
|
||||
|
||||
|
||||
#define DECLARE_ASYNC_TEST(type, realType) \
|
||||
int test_buffer_read_async_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read_async( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_ASYNC_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_async_##type) \
|
||||
{ \
|
||||
return test_buffer_read_async(device, context, queue, num_elements, \
|
||||
sizeof(realType), (char *)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_ASYNC_TEST(char, cl_char)
|
||||
DECLARE_ASYNC_TEST(uchar, cl_uchar)
|
||||
@@ -1077,12 +1091,14 @@ DECLARE_ASYNC_TEST(ulong, cl_ulong)
|
||||
DECLARE_ASYNC_TEST(float, cl_float)
|
||||
|
||||
|
||||
#define DECLARE_BARRIER_TEST(type, realType) \
|
||||
int test_buffer_read_array_barrier_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \
|
||||
{ \
|
||||
return test_buffer_read_array_barrier( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \
|
||||
buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \
|
||||
}
|
||||
#define DECLARE_BARRIER_TEST(type, realType) \
|
||||
REGISTER_TEST(buffer_read_array_barrier_##type) \
|
||||
{ \
|
||||
return test_buffer_read_array_barrier( \
|
||||
device, context, queue, num_elements, sizeof(realType), \
|
||||
(char *)#type, 5, buffer_read_##type##_kernel_code, \
|
||||
type##_kernel_name, verify_read_##type); \
|
||||
}
|
||||
|
||||
DECLARE_BARRIER_TEST(int, cl_int)
|
||||
DECLARE_BARRIER_TEST(uint, cl_uint)
|
||||
@@ -1094,7 +1110,7 @@ DECLARE_BARRIER_TEST(char, cl_char)
|
||||
DECLARE_BARRIER_TEST(uchar, cl_uchar)
|
||||
DECLARE_BARRIER_TEST(float, cl_float)
|
||||
|
||||
int test_buffer_read_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_struct)
|
||||
{
|
||||
cl_mem buffers[1];
|
||||
TestStruct *output_ptr;
|
||||
@@ -1305,7 +1321,7 @@ static int testRandomReadSize( cl_device_id deviceID, cl_context context, cl_com
|
||||
} // end testRandomReadSize()
|
||||
|
||||
|
||||
int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
REGISTER_TEST(buffer_read_random_size)
|
||||
{
|
||||
int err = 0;
|
||||
int i;
|
||||
@@ -1317,7 +1333,8 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c
|
||||
for ( i = 0; i < 8; i++ ){
|
||||
start = (cl_uint)get_random_float( 0.f, (float)(num_elements - 8), d );
|
||||
size = (size_t)get_random_float( 8.f, (float)(num_elements - start), d );
|
||||
if (testRandomReadSize( deviceID, context, queue, num_elements, start, size ))
|
||||
if (testRandomReadSize(device, context, queue, num_elements, start,
|
||||
size))
|
||||
err++;
|
||||
}
|
||||
|
||||
@@ -1325,4 +1342,3 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user