cl22: Reuse test harness code in half (#192)

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-22 12:09:32 +01:00
committed by Kévin Petit
parent 2c9ba4b352
commit 8a8ebf29b0
7 changed files with 126 additions and 237 deletions

View File

@@ -18,7 +18,7 @@
#include "tests.h"
#include "../../test_common/harness/testHarness.h"
int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
int test_roundTrip( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements )
{
int vectorSize, error;
uint64_t i, j;
@@ -107,7 +107,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
*/
if(g_arrVecSizes[vectorSize] == 3) {
programs[vectorSize] = MakeProgram( sourceV3, sizeof( sourceV3) / sizeof( sourceV3[0]) );
programs[vectorSize] = MakeProgram( device, sourceV3, sizeof( sourceV3) / sizeof( sourceV3[0]) );
if( NULL == programs[ vectorSize ] )
{
gFailCount++;
@@ -115,7 +115,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
return -1;
}
} else {
programs[vectorSize] = MakeProgram( source, sizeof( source) / sizeof( source[0]) );
programs[vectorSize] = MakeProgram( device, source, sizeof( source) / sizeof( source[0]) );
if( NULL == programs[ vectorSize ] )
{
gFailCount++;
@@ -134,15 +134,15 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
if( gTestDouble )
{
if(g_arrVecSizes[vectorSize] == 3) {
doublePrograms[vectorSize] = MakeProgram( doubleSourceV3, sizeof( doubleSourceV3) / sizeof( doubleSourceV3[0]) );
if( NULL == programs[ vectorSize ] )
doublePrograms[vectorSize] = MakeProgram( device, doubleSourceV3, sizeof( doubleSourceV3) / sizeof( doubleSourceV3[0]) );
if( NULL == doublePrograms[ vectorSize ] )
{
gFailCount++;
return -1;
}
} else {
doublePrograms[vectorSize] = MakeProgram( doubleSource, sizeof( doubleSource) / sizeof( doubleSource[0]) );
if( NULL == programs[ vectorSize ] )
doublePrograms[vectorSize] = MakeProgram( device, doubleSource, sizeof( doubleSource) / sizeof( doubleSource[0]) );
if( NULL == doublePrograms[ vectorSize ] )
{
gFailCount++;
return -1;
@@ -150,7 +150,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
}
doubleKernels[ vectorSize ] = clCreateKernel( doublePrograms[ vectorSize ], "test", &error );
if( NULL == kernels[vectorSize] )
if( NULL == doubleKernels[vectorSize] )
{
gFailCount++;
vlog_error( "\t\tFAILED -- Failed to create kernel. (%d)\n", error );
@@ -161,7 +161,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
// Figure out how many elements are in a work block
size_t elementSize = MAX( sizeof(cl_half), sizeof(cl_float));
size_t blockCount = (size_t)gBufferSize / elementSize; //elementSize is a power of two
size_t blockCount = (size_t)getBufferSize(device) / elementSize; //elementSize is a power of two
uint64_t lastCase = 1ULL << (8*sizeof(cl_half)); // number of cl_half
size_t stride = blockCount;
@@ -190,7 +190,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
for( vectorSize = kMinVectorSize; vectorSize < kLastVectorSizeToTest; vectorSize++)
{ // here we loop through vector sizes -- 3 is last.
uint32_t pattern = 0xdeaddead;
memset_pattern4( gOut_half, &pattern, (size_t)getBufferSize(gDevice)/2);
memset_pattern4( gOut_half, &pattern, (size_t)getBufferSize(device)/2);
if( (error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_half), gOut_half, 0, NULL, NULL)) )
{
@@ -201,7 +201,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
// here is where "3" starts to cause problems.
error = RunKernel( kernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
error = RunKernel(device, kernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
runsOverBy(count, vectorSize, false) );
if(error)
{
@@ -243,7 +243,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
if( gTestDouble )
{
memset_pattern4( gOut_half, &pattern, (size_t)getBufferSize(gDevice)/2);
memset_pattern4( gOut_half, &pattern, (size_t)getBufferSize(device)/2);
if( (error = clEnqueueWriteBuffer(gQueue, gOutBuffer_half, CL_TRUE, 0, count * sizeof(cl_half), gOut_half, 0, NULL, NULL)) )
{
vlog_error( "Failure in clWriteArray\n" );
@@ -252,7 +252,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
}
if( (error = RunKernel( doubleKernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
if( (error = RunKernel(device, doubleKernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
runsOverBy(count, vectorSize, false) ) ) )
{
gFailCount++;
@@ -313,7 +313,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
for( j = 0; j < loopCount; j++ )
{
uint64_t startTime = ReadTime();
if( (error = RunKernel( kernels[vectorSize], gInBuffer_half, gOutBuffer_half,numVecs(count, vectorSize, false) ,
if( (error = RunKernel(device, kernels[vectorSize], gInBuffer_half, gOutBuffer_half,numVecs(count, vectorSize, false) ,
runsOverBy(count, vectorSize, false)) ) )
{
gFailCount++;
@@ -340,7 +340,7 @@ int test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue
for( j = 0; j < loopCount; j++ )
{
uint64_t startTime = ReadTime();
if( (error = RunKernel( doubleKernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
if( (error = RunKernel(device, doubleKernels[vectorSize], gInBuffer_half, gOutBuffer_half, numVecs(count, vectorSize, false) ,
runsOverBy(count, vectorSize, false)) ) )
{
gFailCount++;