cl20: Reuse test harness code in clCopyImage (#197)

Some of the setup functionality is already there in the test harness, so
use that and remove the duplicated code from within the suite.

Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
Radek Szymanski
2019-04-25 02:47:13 +01:00
committed by Kévin Petit
parent 3c124e0807
commit 1a59260373
11 changed files with 133 additions and 228 deletions

View File

@@ -26,64 +26,67 @@
#include "../testBase.h"
#include "../../../test_common/harness/testHarness.h"
bool gDebugTrace = false, gTestSmallImages = false, gTestMaxImages = false, gUseRamp = false, gTestRounding = false, gEnablePitch = false, gTestMipmaps = false;
int gTypesToTest = 0;
bool gDebugTrace;
bool gTestSmallImages;
bool gTestMaxImages;
bool gUseRamp;
bool gTestRounding;
bool gEnablePitch;
bool gTestMipmaps;
int gTypesToTest;
cl_channel_type gChannelTypeToUse = (cl_channel_type)-1;
cl_channel_order gChannelOrderToUse = (cl_channel_order)-1;
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
cl_context context;
cl_command_queue queue;
static cl_device_id device;
extern int test_image_set( cl_device_id device, MethodsToTest testMethod );
extern int test_image_set( cl_device_id device, cl_context context, cl_command_queue queue, MethodsToTest testMethod );
#define MAX_ALLOWED_STD_DEVIATION_IN_MB 8.0
static void printUsage( const char *execName );
int test_1D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_1D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k1D );
return test_image_set( device, context, queue, k1D );
}
int test_2D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2D );
return test_image_set( device, context, queue, k2D );
}
int test_3D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_3D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k3D );
return test_image_set( device, context, queue, k3D );
}
int test_1Darray(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_1Darray(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k1DArray );
return test_image_set( device, context, queue, k1DArray );
}
int test_2Darray(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2Darray(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2DArray );
return test_image_set( device, context, queue, k2DArray );
}
int test_2Dto3D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2Dto3D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2DTo3D );
return test_image_set( device, context, queue, k2DTo3D );
}
int test_3Dto2D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_3Dto2D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k3DTo2D );
return test_image_set( device, context, queue, k3DTo2D );
}
int test_2Darrayto2D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2Darrayto2D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2DArrayTo2D );
return test_image_set( device, context, queue, k2DArrayTo2D );
}
int test_2Dto2Darray(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2Dto2Darray(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2DTo2DArray );
return test_image_set( device, context, queue, k2DTo2DArray );
}
int test_2Darrayto3D(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_2Darrayto3D(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k2DArrayTo3D );
return test_image_set( device, context, queue, k2DArrayTo3D );
}
int test_3Dto2Darray(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_3Dto2Darray(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return test_image_set( device, k3DTo2DArray );
return test_image_set( device, context, queue, k3DTo2DArray );
}
test_definition test_list[] = {
@@ -104,12 +107,8 @@ const int test_num = ARRAY_SIZE( test_list );
int main(int argc, const char *argv[])
{
cl_platform_id platform;
cl_channel_type chanType;
cl_channel_order chanOrder;
bool randomize = false;
test_start();
checkDeviceTypeOverride( &gDeviceType );
@@ -155,9 +154,6 @@ int main(int argc, const char *argv[])
else if( strcmp( argv[i], "use_pitches" ) == 0 )
gEnablePitch = true;
else if( strcmp( argv[i], "randomize" ) == 0 )
randomize = true;
else if( strcmp( argv[i], "--help" ) == 0 || strcmp( argv[i], "-h" ) == 0 )
{
printUsage( argv[ 0 ] );
@@ -176,78 +172,10 @@ int main(int argc, const char *argv[])
}
}
// Seed the random # generators
if( randomize )
{
gRandomSeed = (cl_uint) time( NULL );
log_info( "Random seed: %u.\n", gRandomSeed );
gReSeed = 1;
}
int error;
// Get our platform
error = clGetPlatformIDs(1, &platform, NULL);
if( error )
{
print_error( error, "Unable to get platform" );
test_finish();
return -1;
}
// Get our device
error = clGetDeviceIDs(platform, gDeviceType, 1, &device, NULL );
if( error )
{
print_error( error, "Unable to get specified device" );
test_finish();
return -1;
}
char deviceName[ 128 ], deviceVendor[ 128 ], deviceVersion[ 128 ];
error = clGetDeviceInfo( device, CL_DEVICE_NAME, sizeof( deviceName ), deviceName, NULL );
error |= clGetDeviceInfo( device, CL_DEVICE_VENDOR, sizeof( deviceVendor ), deviceVendor, NULL );
error |= clGetDeviceInfo( device, CL_DEVICE_VERSION, sizeof( deviceVersion ), deviceVersion, NULL );
if( error != CL_SUCCESS )
{
print_error( error, "Unable to get device information" );
test_finish();
return -1;
}
log_info("Using compute device: Name = %s, Vendor = %s, Version = %s\n", deviceName, deviceVendor, deviceVersion );
// Check for image support
if(checkForImageSupport( device ) == CL_IMAGE_FORMAT_NOT_SUPPORTED) {
log_info("Device does not support images. Skipping test.\n");
test_finish();
return 0;
}
// Create a context to test with
context = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
if( error != CL_SUCCESS )
{
print_error( error, "Unable to create testing context" );
test_finish();
return -1;
}
// Create a queue against the context
queue = clCreateCommandQueueWithProperties( context, device, 0, &error );
if( error != CL_SUCCESS )
{
print_error( error, "Unable to create testing command queue" );
test_finish();
return -1;
}
if( gTestSmallImages )
log_info( "Note: Using small test images\n" );
int ret = parseAndCallCommandLineTests( argCount, argList, NULL, test_num, test_list, true, 0, 0 );
error = clFinish(queue);
if (error)
print_error(error, "clFinish failed.");
int ret = runTestHarness( argCount, argList, test_num, test_list, true, false, 0 );
if (gTestFailure == 0) {
if (gTestCount > 1)
@@ -262,10 +190,7 @@ int main(int argc, const char *argv[])
}
// Clean up
clReleaseCommandQueue(queue);
clReleaseContext(context);
free(argList);
test_finish();
return ret;
}