cl20: Khronos Bug 16122: Convert half to test harness

Conflicts:
	test_conformance/half/CMakeLists.txt
	test_conformance/half/Test_vStoreHalf.c
	test_conformance/half/cl_utils.c
	test_conformance/half/cl_utils.h

Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kevin Petit
2019-02-20 18:32:39 +00:00
committed by Kévin Petit
parent 901bc34567
commit aadfe3c5a7
9 changed files with 121 additions and 214 deletions

View File

@@ -8,9 +8,10 @@ set(${MODULE_NAME}_SOURCES
../../test_common/harness/msvc9.c ../../test_common/harness/msvc9.c
../../test_common/harness/mingw_compat.c ../../test_common/harness/mingw_compat.c
../../test_common/harness/errorHelpers.c ../../test_common/harness/errorHelpers.c
../../test_common/harness/kernelHelpers.c
../../test_common/harness/ThreadPool.c ../../test_common/harness/ThreadPool.c
../../test_common/harness/parseParameters.cpp ../../test_common/harness/parseParameters.cpp
../../test_common/harness/kernelHelpers.c ../../test_common/harness/testHarness.c
) )
include(../CMakeCommon.txt) include(../CMakeCommon.txt)

View File

@@ -3,43 +3,38 @@ ATF = -framework ATF
USE_ATF = -DUSE_ATF USE_ATF = -DUSE_ATF
endif endif
SRCFILES = cl_utils.c Test_vLoadHalf.c Test_roundTrip.c \ SRCS = main.c \
Test_vStoreHalf.c main.c cl_utils.c \
Test_vLoadHalf.c \
Test_roundTrip.c \
Test_vStoreHalf.c \
../../test_common/harness/errorHelpers.c \
../../test_common/harness/kernelHelpers.c \
../../test_common/harness/mingw_compat.c \
../../test_common/harness/testHarness.c
CC = c++ SOURCES = $(abspath $(SRCS))
CFLAGS = -g -Wall -Wshorten-64-to-32 $(COMPILERFLAGS) ${RC_CFLAGS} \ LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
${USE_ATF} LIBPATH += -L.
FRAMEWORK = $(SOURCES)
HEADERS =
TARGET = Test_half
INCLUDE =
COMPILERFLAGS = -c -Wall -g
CC = ${CROSS_COMPILE}g++
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(INCLUDE)
LIBRARIES = -framework OpenCL ${ATF}
LIBRARIES = -framework OpenCL ${RC_CFLAGS} ${ATF} OBJECTS := ${SOURCES:.c=.o}
TARGETOBJECT =
all: $(TARGET)
all: release $(TARGET): $(OBJECTS)
$(CC) $(INCLUDE) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
OBJECTS := ${SRCFILES:.c=.o}
release:
echo "Build Release"
$(CC) $(SRCFILES) -Os $(CFLAGS) -o Test_half $(LIBRARIES)
debug: $(OBJECTS)
echo "Build Debug"
$(CC) $(OBJECTS) -O0 $(CFLAGS) -o Test_half_debug -D_DEBUG=1 $(LIBRARIES)
test: release
arch -i386 ./Test_half -c > cpu.log &
arch -i386 ./Test_half -g > gpu.log &
echo "Testing 32-bit mode in progress. See cpu.log and gpu.log for results."
test64: release
arch -x86_64 ./Test_half -c > cpu64.log &
arch -x86_64 ./Test_half -g > gpu64.log &
echo "Testing 64-bit mode in progress. See cpu64.log and gpu64.log for results."
clean: clean:
rm -f ./Test_half_debug rm -f $(TARGET) $(OBJECTS)
rm -f ./Test_half
.DEFAULT: .DEFAULT:
@echo The target \"$@\" does not exist in Makefile. @echo The target \"$@\" does not exist in Makefile.

View File

@@ -16,10 +16,9 @@
#include <string.h> #include <string.h>
#include "cl_utils.h" #include "cl_utils.h"
#include "tests.h" #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( void )
{ {
int vectorSize, error; int vectorSize, error;
uint64_t i, j; uint64_t i, j;
@@ -236,6 +235,7 @@ int Test_roundTrip( void )
vlog_error( "%lld) (of %lld) Failure at 0x%4.4x: 0x%4.4x vector_size = %d \n", j, (uint64_t)count, u2[j], u1[j], (g_arrVecSizes[vectorSize]) ); vlog_error( "%lld) (of %lld) Failure at 0x%4.4x: 0x%4.4x vector_size = %d \n", j, (uint64_t)count, u2[j], u1[j], (g_arrVecSizes[vectorSize]) );
gFailCount++; gFailCount++;
error = -1;
goto exit; goto exit;
} }
} }
@@ -285,6 +285,7 @@ int Test_roundTrip( void )
vlog_error( "%lld) Failure at 0x%4.4x: 0x%4.4x vector_size = %d (double precsion)\n", j, u2[j], u1[j], (g_arrVecSizes[vectorSize]) ); vlog_error( "%lld) Failure at 0x%4.4x: 0x%4.4x vector_size = %d (double precsion)\n", j, u2[j], u1[j], (g_arrVecSizes[vectorSize]) );
gFailCount++; gFailCount++;
error = -1;
goto exit; goto exit;
} }
} }
@@ -391,7 +392,6 @@ exit:
} }
} }
gTestCount++;
return error; return error;
} }

View File

@@ -14,6 +14,7 @@
// limitations under the License. // limitations under the License.
// //
#include "../../test_common/harness/compat.h" #include "../../test_common/harness/compat.h"
#include "../../test_common/harness/testHarness.h"
#include <string.h> #include <string.h>
#include "cl_utils.h" #include "cl_utils.h"
@@ -548,6 +549,7 @@ int Test_vLoadHalf_private( bool aligned )
vector_size_names[vectorSize], addressSpaceNames[addressSpace], vector_size_names[vectorSize], addressSpaceNames[addressSpace],
(aligned?"aligned":"unaligned")); (aligned?"aligned":"unaligned"));
gFailCount++; gFailCount++;
error = -1;
break; // goto exit; break; // goto exit;
} }
} }
@@ -612,16 +614,15 @@ exit:
} }
} }
gTestCount++;
return error; return error;
} }
int Test_vload_half( void ) int Test_vload_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vLoadHalf_private( false ); return Test_vLoadHalf_private( false );
} }
int Test_vloada_half( void ) int Test_vloada_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vLoadHalf_private( true ); return Test_vLoadHalf_private( true );
} }

View File

@@ -15,6 +15,7 @@
// //
#include "../../test_common/harness/compat.h" #include "../../test_common/harness/compat.h"
#include "../../test_common/harness/kernelHelpers.h" #include "../../test_common/harness/kernelHelpers.h"
#include "../../test_common/harness/testHarness.h"
#include <string.h> #include <string.h>
#include "cl_utils.h" #include "cl_utils.h"
@@ -611,7 +612,7 @@ double2half_rtn( double f )
return (u.u >> (53-11)) | sign; return (u.u >> (53-11)) | sign;
} }
int Test_vstore_half( void ) int Test_vstore_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
switch (get_default_rounding_mode(gDevice)) switch (get_default_rounding_mode(gDevice))
{ {
@@ -624,27 +625,27 @@ int Test_vstore_half( void )
} }
} }
int Test_vstore_half_rte( void ) int Test_vstore_half_rte( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreHalf_private(float2half_rte, double2half_rte, "_rte"); return Test_vStoreHalf_private(float2half_rte, double2half_rte, "_rte");
} }
int Test_vstore_half_rtz( void ) int Test_vstore_half_rtz( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreHalf_private(float2half_rtz, double2half_rtz, "_rtz"); return Test_vStoreHalf_private(float2half_rtz, double2half_rtz, "_rtz");
} }
int Test_vstore_half_rtp( void ) int Test_vstore_half_rtp( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreHalf_private(float2half_rtp, double2half_rtp, "_rtp"); return Test_vStoreHalf_private(float2half_rtp, double2half_rtp, "_rtp");
} }
int Test_vstore_half_rtn( void ) int Test_vstore_half_rtn( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreHalf_private(float2half_rtn, double2half_rtn, "_rtn"); return Test_vStoreHalf_private(float2half_rtn, double2half_rtn, "_rtn");
} }
int Test_vstorea_half( void ) int Test_vstorea_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
switch (get_default_rounding_mode(gDevice)) switch (get_default_rounding_mode(gDevice))
{ {
@@ -657,22 +658,22 @@ int Test_vstorea_half( void )
} }
} }
int Test_vstorea_half_rte( void ) int Test_vstorea_half_rte( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreaHalf_private(float2half_rte, double2half_rte, "_rte"); return Test_vStoreaHalf_private(float2half_rte, double2half_rte, "_rte");
} }
int Test_vstorea_half_rtz( void ) int Test_vstorea_half_rtz( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreaHalf_private(float2half_rtz, double2half_rtz, "_rtz"); return Test_vStoreaHalf_private(float2half_rtz, double2half_rtz, "_rtz");
} }
int Test_vstorea_half_rtp( void ) int Test_vstorea_half_rtp( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreaHalf_private(float2half_rtp, double2half_rtp, "_rtp"); return Test_vStoreaHalf_private(float2half_rtp, double2half_rtp, "_rtp");
} }
int Test_vstorea_half_rtn( void ) int Test_vstorea_half_rtn( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
{ {
return Test_vStoreaHalf_private(float2half_rtn, double2half_rtn, "_rtn"); return Test_vStoreaHalf_private(float2half_rtn, double2half_rtn, "_rtn");
} }
@@ -1337,7 +1338,6 @@ exit:
} }
} }
gTestCount++;
return error; return error;
} }
@@ -1941,7 +1941,6 @@ exit:
} }
} }
gTestCount++;
return error; return error;
} }

View File

@@ -24,6 +24,8 @@
#include "string.h" #include "string.h"
#include "../../test_common/harness/kernelHelpers.h" #include "../../test_common/harness/kernelHelpers.h"
#include "../../test_common/harness/testHarness.h"
#define HALF_MIN 1.0p-14 #define HALF_MIN 1.0p-14
@@ -58,13 +60,11 @@ uint32_t gDeviceFrequency = 0;
uint32_t gComputeDevices = 0; uint32_t gComputeDevices = 0;
size_t gMaxThreadGroupSize = 0; size_t gMaxThreadGroupSize = 0;
size_t gWorkGroupSize = 0; size_t gWorkGroupSize = 0;
int gTestCount = 0;
int gFailCount = 0; int gFailCount = 0;
bool gWimpyMode = false; bool gWimpyMode = false;
int gWimpyReductionFactor = 512; int gWimpyReductionFactor = 512;
int gTestDouble = 0; int gTestDouble = 0;
uint32_t gDeviceIndex = 0; uint32_t gDeviceIndex = 0;
int gIsEmbedded = 0;
size_t gBufferSize = 0; size_t gBufferSize = 0;
#if defined( __APPLE__ ) #if defined( __APPLE__ )
@@ -75,11 +75,6 @@ int gReportTimes = 0;
#pragma mark - #pragma mark -
static void CL_CALLBACK notify_callback(const char *errinfo, const void *private_info, size_t cb, void *user_data)
{
vlog( "%s\n", errinfo );
}
int InitCL( void ) int InitCL( void )
{ {
cl_platform_id platform = NULL; cl_platform_id platform = NULL;
@@ -439,25 +434,6 @@ double SubtractTime( uint64_t endTime, uint64_t startTime )
#endif #endif
#if !defined( __APPLE__ )
void memset_pattern4(void *dest, const void *src_pattern, size_t bytes )
{
uint32_t pat = ((uint32_t*) src_pattern)[0];
size_t count = bytes / 4;
size_t i;
uint32_t *d = (uint32_t*)dest;
for( i = 0; i < count; i++ )
d[i] = pat;
d += i;
bytes &= 3;
if( bytes )
memcpy( d, src_pattern, bytes );
}
#endif
size_t getBufferSize(cl_device_id device_id) size_t getBufferSize(cl_device_id device_id)
{ {
static int s_initialized = 0; static int s_initialized = 0;

View File

@@ -68,11 +68,9 @@ extern uint32_t gDeviceFrequency;
extern uint32_t gComputeDevices; extern uint32_t gComputeDevices;
extern size_t gMaxThreadGroupSize; extern size_t gMaxThreadGroupSize;
extern size_t gWorkGroupSize; extern size_t gWorkGroupSize;
extern int gTestCount;
extern int gFailCount; extern int gFailCount;
extern int gTestDouble; extern int gTestDouble;
extern int gReportTimes; extern int gReportTimes;
extern int gIsEmbedded;
extern size_t gBufferSize; extern size_t gBufferSize;
// gWimpyMode indicates if we run the test in wimpy mode where we limit the // gWimpyMode indicates if we run the test in wimpy mode where we limit the
@@ -99,10 +97,6 @@ void ReleaseCL( void );
int RunKernel( cl_kernel kernel, void *inBuf, void *outBuf, uint32_t blockCount , int extraArg); int RunKernel( cl_kernel kernel, void *inBuf, void *outBuf, uint32_t blockCount , int extraArg);
cl_program MakeProgram( const char *source[], int count ); cl_program MakeProgram( const char *source[], int count );
#if ! defined( __APPLE__ )
extern void memset_pattern4(void *dest, const void *src_pattern, size_t bytes );
#endif
#define STRING( _x ) STRINGIFY( _x ) #define STRING( _x ) STRINGIFY( _x )
#define STRINGIFY(x) #x #define STRINGIFY(x) #x

View File

@@ -26,6 +26,7 @@
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include "../../test_common/harness/testHarness.h"
#include "../../test_common/harness/mingw_compat.h" #include "../../test_common/harness/mingw_compat.h"
#include "../../test_common/harness/parseParameters.h" #include "../../test_common/harness/parseParameters.h"
#if defined (__MINGW32__) #if defined (__MINGW32__)
@@ -48,13 +49,48 @@ static int ParseArgs( int argc, const char **argv );
static void PrintUsage( void ); static void PrintUsage( void );
static void PrintArch(void); static void PrintArch(void);
static void PrintDevice(void); static void PrintDevice(void);
static int DoTest( void);
int g_arrVecSizes[kVectorSizeCount+kStrangeVectorSizeCount]; int g_arrVecSizes[kVectorSizeCount+kStrangeVectorSizeCount];
int g_arrVecAligns[kLargestVectorSize+1]; int g_arrVecAligns[kLargestVectorSize+1];
static int arrStrangeVecSizes[kStrangeVectorSizeCount] = {3}; static int arrStrangeVecSizes[kStrangeVectorSizeCount] = {3};
basefn basefn_list[] = {
Test_vload_half,
Test_vloada_half,
Test_vstore_half,
Test_vstorea_half,
Test_vstore_half_rte,
Test_vstorea_half_rte,
Test_vstore_half_rtz,
Test_vstorea_half_rtz,
Test_vstore_half_rtp,
Test_vstorea_half_rtp,
Test_vstore_half_rtn,
Test_vstorea_half_rtn,
Test_roundTrip,
};
const char *basefn_names[] = {
"vload_half",
"vloada_half",
"vstore_half",
"vstorea_half",
"vstore_half_rte",
"vstorea_half_rte",
"vstore_half_rtz",
"vstorea_half_rtz",
"vstore_half_rtp",
"vstorea_half_rtp",
"vstore_half_rtn",
"vstorea_half_rtn",
"roundTrip",
};
ct_assert((sizeof(basefn_names) / sizeof(basefn_names[0])) == (sizeof(basefn_list) / sizeof(basefn_list[0])));
int num_fns = sizeof(basefn_names) / sizeof(char *);
int main (int argc, const char **argv ) int main (int argc, const char **argv )
{ {
int error; int error;
@@ -99,34 +135,26 @@ int main (int argc, const char **argv )
} }
fflush( stdout ); fflush( stdout );
error = DoTest(); error = parseAndCallCommandLineTests( argCount, argList, NULL, num_fns, basefn_list, basefn_names, true, 0, 0 );
exit: exit:
if(gQueue)
if (gFailCount == 0) { {
if (gTestCount > 1) int flush_error = clFinish(gQueue);
vlog("PASSED %d of %d tests.\n", gTestCount, gTestCount); if(flush_error)
else {
vlog("PASSED test.\n"); vlog_error("clFinish failed: %d\n", flush_error);
} else if (gFailCount > 0) { }
if (gFailCount+gTestCount > 1)
vlog_error("FAILED %d of %d tests.\n", gFailCount, gTestCount+gFailCount);
else
vlog_error("FAILED test.\n");
} }
if (gQueue) { if(gFailCount > 0)
int flush_error = clFinish(gQueue); {
if (flush_error) vlog_error("FAILED %d sub-tests.\n", gFailCount);
vlog_error("clFinish failed: %d\n", flush_error);
} }
ReleaseCL(); ReleaseCL();
test_finish(); test_finish();
if (gFailCount)
return gFailCount;
return error; return error;
} }
@@ -138,10 +166,14 @@ static int ParseArgs( int argc, const char **argv )
int i; int i;
argList = (const char **)calloc( argc - 1, sizeof( char*) ); argList = (const char **)calloc( argc - 1, sizeof( char*) );
argCount = 0; if( NULL == argList )
{
vlog_error( "Failed to allocate memory for argList.\n" );
return 1;
}
if( NULL == argList && argc > 1 ) argList[0] = argv[0];
return -1; argCount = 1;
#if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__)) #if (defined( __APPLE__ ) || defined(__linux__) || defined(__MINGW32__))
{ // Extract the app name { // Extract the app name
@@ -293,7 +325,10 @@ static void PrintUsage( void )
vlog( "\t\t-w\tRun in wimpy mode\n" ); vlog( "\t\t-w\tRun in wimpy mode\n" );
vlog( "\t\t-[2^n]\tSet wimpy reduction factor, recommended range of n is 1-12, default factor(%u)\n", gWimpyReductionFactor); vlog( "\t\t-[2^n]\tSet wimpy reduction factor, recommended range of n is 1-12, default factor(%u)\n", gWimpyReductionFactor);
vlog( "\t\t-h\tHelp\n" ); vlog( "\t\t-h\tHelp\n" );
vlog( "\n" ); for( int i = 0; i < num_fns; i++ )
{
vlog("\t\t%s\n", basefn_names[i] );
}
} }
static void PrintArch( void ) static void PrintArch( void )
@@ -344,97 +379,3 @@ static void PrintDevice( void)
break; break;
} }
} }
static int DoTest( void )
{
int error = 0;
if( 0 == argCount )
{ // test all
if( (error = Test_vload_half()) )
return error;
if( (error = Test_vloada_half()) )
return error;
if( (error = Test_vstore_half()) )
return error;
if( (error = Test_vstorea_half()) )
return error;
if( (error = Test_vstore_half_rte()) )
return error;
if( (error = Test_vstorea_half_rte()) )
return error;
if( (error = Test_vstore_half_rtz()) )
return error;
if( (error = Test_vstorea_half_rtz()) )
return error;
if( (error = Test_vstore_half_rtp()) )
return error;
if( (error = Test_vstorea_half_rtp()) )
return error;
if( (error = Test_vstore_half_rtn()) )
return error;
if( (error = Test_vstorea_half_rtn()) )
return error;
if( (error = Test_roundTrip()) )
return error;
}
else
{
typedef struct{ int (*f)(void); const char *name; }TestItem;
#define ENTRY( _x ) { Test_ ## _x, STRINGIFY(_x) }
static const TestItem list[] =
{
ENTRY(vload_half),
ENTRY(vloada_half),
ENTRY(vstore_half),
ENTRY(vstorea_half),
ENTRY(vstore_half_rte),
ENTRY(vstorea_half_rte),
ENTRY(vstore_half_rtz),
ENTRY(vstorea_half_rtz),
ENTRY(vstore_half_rtp),
ENTRY(vstorea_half_rtp),
ENTRY(vstore_half_rtn),
ENTRY(vstorea_half_rtn),
ENTRY(roundTrip)
};
static const size_t list_count = sizeof( list ) / sizeof( list[0] );
size_t i, j;
for( i = 0; i < argCount; i++ )
{
const char *argp = argList[i];
for( j = 0; j < list_count; j++ )
{
if( 0 == strcmp(argp, list[j].name) )
{
if( (error = list[j].f()) )
return error;
break;
}
}
if( j == list_count )
{
vlog_error( "Unknown test name: %s\n. Exiting...\n", argp );
return -5;
}
}
}
return error;
}

View File

@@ -17,19 +17,19 @@
#define TESTS_H #define TESTS_H
int Test_vload_half( void ); int Test_vload_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vloada_half( void ); int Test_vloada_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstore_half( void ); int Test_vstore_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstorea_half( void ); int Test_vstorea_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstore_half_rte( void ); int Test_vstore_half_rte( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstorea_half_rte( void ); int Test_vstorea_half_rte( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstore_half_rtz( void ); int Test_vstore_half_rtz( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstorea_half_rtz( void ); int Test_vstorea_half_rtz( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstore_half_rtp( void ); int Test_vstore_half_rtp( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstorea_half_rtp( void ); int Test_vstorea_half_rtp( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstore_half_rtn( void ); int Test_vstore_half_rtn( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_vstorea_half_rtn( void ); int Test_vstorea_half_rtn( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
int Test_roundTrip( void ); int Test_roundTrip( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
typedef cl_ushort (*f2h)( float ); typedef cl_ushort (*f2h)( float );
typedef cl_ushort (*d2h)( double ); typedef cl_ushort (*d2h)( double );