mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
cl22: Convert printf to testHarness (#92)
Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
committed by
Kévin Petit
parent
f2d339b8d2
commit
dd036cd02e
@@ -12,6 +12,7 @@ set(${MODULE_NAME}_SOURCES
|
||||
../../test_common/harness/conversions.c
|
||||
../../test_common/harness/mt19937.c
|
||||
../../test_common/harness/msvc9.c
|
||||
../../test_common/harness/testHarness.c
|
||||
#../../test_common/harness/imageHelpers.cpp
|
||||
../../test_common/harness/parseParameters.cpp
|
||||
../../test_common/harness/kernelHelpers.c
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
#include <io.h>
|
||||
#define streamDup(fd1) _dup(fd1)
|
||||
#define streamDup2(fd1,fd2) _dup2(fd1,fd2)
|
||||
#include "../../test_common/harness/testHarness.h"
|
||||
#endif
|
||||
|
||||
#include "../../test_common/harness/testHarness.h"
|
||||
#include "../../test_common/harness/errorHelpers.h"
|
||||
#include "../../test_common/harness/kernelHelpers.h"
|
||||
#include "../../test_common/harness/mt19937.h"
|
||||
@@ -49,6 +49,8 @@ typedef unsigned int uint32_t;
|
||||
// Static helper functions declaration
|
||||
//-----------------------------------------
|
||||
|
||||
static void printUsage( void );
|
||||
|
||||
//Stream helper functions
|
||||
|
||||
//Associate stdout stream with the file(/tmp/tmpfile):i.e redirect stdout stream to the specific files (/tmp/tmpfile)
|
||||
@@ -75,7 +77,7 @@ static int isKernelPFormat(testCase* pTestCase,size_t testId);
|
||||
static cl_program makePrintfProgram(cl_kernel *kernel_ptr, const cl_context context,const unsigned int testId,const unsigned int testNum,bool isLongSupport = true,bool is64bAddrSpace = false);
|
||||
|
||||
// Creates and execute the printf test for the given device, context, type/format
|
||||
static int doTest(cl_command_queue queue, cl_context context, const unsigned int testId, const unsigned int testNum, cl_device_id device,bool isLongSupport = true);
|
||||
static int doTest(cl_command_queue queue, cl_context context, const unsigned int testId, const unsigned int testNum, cl_device_id device);
|
||||
|
||||
// Check if device supports long
|
||||
static bool isLongSupported(cl_device_id device_id);
|
||||
@@ -98,6 +100,11 @@ int s_test_cnt = 0;
|
||||
int s_test_fail = 0;
|
||||
|
||||
|
||||
static cl_device_id gDevice;
|
||||
static cl_context gContext;
|
||||
static cl_command_queue gQueue;
|
||||
static int gFd;
|
||||
|
||||
//-----------------------------------------
|
||||
// Static helper functions definition
|
||||
//-----------------------------------------
|
||||
@@ -400,8 +407,45 @@ static bool is64bAddressSpace(cl_device_id device_id)
|
||||
//-----------------------------------------
|
||||
// doTest
|
||||
//-----------------------------------------
|
||||
static int doTest(cl_command_queue queue, cl_context context, const unsigned int testId, const unsigned int testNum, cl_device_id device,bool isLongSupport)
|
||||
static int doTest(cl_command_queue queue, cl_context context, const unsigned int testId, const unsigned int testNum, cl_device_id device)
|
||||
{
|
||||
if(allTestCase[testId]->_type == TYPE_VECTOR)
|
||||
{
|
||||
log_info("%d)testing printf(\"%sv%s%s\",%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].vectorFormatFlag,allTestCase[testId]->_genParameters[testNum].vectorSize,
|
||||
allTestCase[testId]->_genParameters[testNum].vectorFormatSpecifier,allTestCase[testId]->_genParameters[testNum].dataRepresentation);
|
||||
}
|
||||
else if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE)
|
||||
{
|
||||
if(isKernelArgument(allTestCase[testId], testNum))
|
||||
{
|
||||
log_info("%d)testing kernel //argument %s \n printf(%s,%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].addrSpaceArgumentTypeQualifier,
|
||||
allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].addrSpaceParameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("%d)testing kernel //variable %s \n printf(%s,%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].addrSpaceVariableTypeQualifier,
|
||||
allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].addrSpaceParameter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("%d)testing printf(\"%s\",%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].dataRepresentation);
|
||||
}
|
||||
|
||||
// Long support for varible type
|
||||
if(allTestCase[testId]->_type == TYPE_VECTOR && !strcmp(allTestCase[testId]->_genParameters[testNum].dataType,"long") && !isLongSupported(device))
|
||||
{
|
||||
log_info( "Long is not supported, test not run.\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Long support for address in FULL_PROFILE/EMBEDDED_PROFILE
|
||||
bool isLongSupport = true;
|
||||
if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE && isKernelPFormat(allTestCase[testId],testNum) && !isLongSupported(device))
|
||||
{
|
||||
isLongSupport = false;
|
||||
}
|
||||
|
||||
int err;
|
||||
cl_program program;
|
||||
cl_kernel kernel;
|
||||
@@ -525,15 +569,6 @@ exit:
|
||||
++s_test_cnt;
|
||||
return err;
|
||||
}
|
||||
//-----------------------------------------
|
||||
// printUsage
|
||||
//-----------------------------------------
|
||||
static void printUsage( void )
|
||||
{
|
||||
log_info("test_printf: [-cghw] [start_test_num] \n");
|
||||
log_info(" default is to run the full test on the default device\n");
|
||||
log_info(" start_test_num will start running from that num\n");
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// printArch
|
||||
@@ -571,15 +606,404 @@ static void printArch( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// notify_callback
|
||||
//-----------------------------------------
|
||||
void CL_CALLBACK notify_callback(const char *errinfo, const void *private_info, size_t cb, void *user_data)
|
||||
|
||||
int test_int_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
log_info( "%s\n", errinfo );
|
||||
return doTest(gQueue, gContext, TYPE_INT, 0, gDevice);
|
||||
}
|
||||
int test_int_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 1, gDevice);
|
||||
}
|
||||
int test_int_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 2, gDevice);
|
||||
}
|
||||
int test_int_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 3, gDevice);
|
||||
}
|
||||
int test_int_4(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 4, gDevice);
|
||||
}
|
||||
int test_int_5(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 5, gDevice);
|
||||
}
|
||||
int test_int_6(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 6, gDevice);
|
||||
}
|
||||
int test_int_7(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 7, gDevice);
|
||||
}
|
||||
int test_int_8(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_INT, 8, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_float_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 0, gDevice);
|
||||
}
|
||||
int test_float_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 1, gDevice);
|
||||
}
|
||||
int test_float_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 2, gDevice);
|
||||
}
|
||||
int test_float_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 3, gDevice);
|
||||
}
|
||||
int test_float_4(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 4, gDevice);
|
||||
}
|
||||
int test_float_5(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 5, gDevice);
|
||||
}
|
||||
int test_float_6(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 6, gDevice);
|
||||
}
|
||||
int test_float_7(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 7, gDevice);
|
||||
}
|
||||
int test_float_8(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 8, gDevice);
|
||||
}
|
||||
int test_float_9(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 9, gDevice);
|
||||
}
|
||||
int test_float_10(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 10, gDevice);
|
||||
}
|
||||
int test_float_11(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 11, gDevice);
|
||||
}
|
||||
int test_float_12(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 12, gDevice);
|
||||
}
|
||||
int test_float_13(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 13, gDevice);
|
||||
}
|
||||
int test_float_14(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 14, gDevice);
|
||||
}
|
||||
int test_float_15(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 15, gDevice);
|
||||
}
|
||||
#if ! defined( __ANDROID__ )
|
||||
int test_float_16(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 16, gDevice);
|
||||
}
|
||||
int test_float_17(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 17, gDevice);
|
||||
}
|
||||
#endif
|
||||
int test_float_18(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 18, gDevice);
|
||||
}
|
||||
int test_float_19(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 19, gDevice);
|
||||
}
|
||||
int test_float_20(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_FLOAT, 20, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_octal_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_OCTAL, 0, gDevice);
|
||||
}
|
||||
int test_octal_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_OCTAL, 1, gDevice);
|
||||
}
|
||||
int test_octal_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_OCTAL, 2, gDevice);
|
||||
}
|
||||
int test_octal_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_OCTAL, 3, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_unsigned_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_UNSIGNED, 0, gDevice);
|
||||
}
|
||||
int test_unsigned_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_UNSIGNED, 1, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_hexadecimal_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, 0, gDevice);
|
||||
}
|
||||
int test_hexadecimal_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, 1, gDevice);
|
||||
}
|
||||
int test_hexadecimal_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, 2, gDevice);
|
||||
}
|
||||
int test_hexadecimal_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, 3, gDevice);
|
||||
}
|
||||
int test_hexadecimal_4(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_HEXADEC, 4, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_char_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_CHAR, 0, gDevice);
|
||||
}
|
||||
int test_char_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_CHAR, 1, gDevice);
|
||||
}
|
||||
int test_char_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_CHAR, 2, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_string_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_STRING, 0, gDevice);
|
||||
}
|
||||
int test_string_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_STRING, 1, gDevice);
|
||||
}
|
||||
int test_string_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_STRING, 2, gDevice);
|
||||
}
|
||||
int test_string_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_STRING, 3, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_vector_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, 0, gDevice);
|
||||
}
|
||||
int test_vector_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, 1, gDevice);
|
||||
}
|
||||
int test_vector_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, 2, gDevice);
|
||||
}
|
||||
int test_vector_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, 3, gDevice);
|
||||
}
|
||||
int test_vector_4(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_VECTOR, 4, gDevice);
|
||||
}
|
||||
|
||||
|
||||
int test_address_space_0(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, 0, gDevice);
|
||||
}
|
||||
int test_address_space_1(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, 1, gDevice);
|
||||
}
|
||||
int test_address_space_2(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, 2, gDevice);
|
||||
}
|
||||
int test_address_space_3(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, 3, gDevice);
|
||||
}
|
||||
int test_address_space_4(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
|
||||
{
|
||||
return doTest(gQueue, gContext, TYPE_ADDRESS_SPACE, 4, gDevice);
|
||||
}
|
||||
|
||||
basefn basefn_list[] = {
|
||||
test_int_0,
|
||||
test_int_1,
|
||||
test_int_2,
|
||||
test_int_3,
|
||||
test_int_4,
|
||||
test_int_5,
|
||||
test_int_6,
|
||||
test_int_7,
|
||||
test_int_8,
|
||||
|
||||
test_float_0,
|
||||
test_float_1,
|
||||
test_float_2,
|
||||
test_float_3,
|
||||
test_float_4,
|
||||
test_float_5,
|
||||
test_float_6,
|
||||
test_float_7,
|
||||
test_float_8,
|
||||
test_float_9,
|
||||
test_float_10,
|
||||
test_float_11,
|
||||
test_float_12,
|
||||
test_float_13,
|
||||
test_float_14,
|
||||
test_float_15,
|
||||
#if ! defined( __ANDROID__ )
|
||||
test_float_16,
|
||||
test_float_17,
|
||||
#endif
|
||||
test_float_18,
|
||||
test_float_19,
|
||||
test_float_20,
|
||||
|
||||
test_octal_0,
|
||||
test_octal_1,
|
||||
test_octal_2,
|
||||
test_octal_3,
|
||||
|
||||
test_unsigned_0,
|
||||
test_unsigned_1,
|
||||
|
||||
test_hexadecimal_0,
|
||||
test_hexadecimal_1,
|
||||
test_hexadecimal_2,
|
||||
test_hexadecimal_3,
|
||||
test_hexadecimal_4,
|
||||
|
||||
test_char_0,
|
||||
test_char_1,
|
||||
test_char_2,
|
||||
|
||||
test_string_0,
|
||||
test_string_1,
|
||||
test_string_2,
|
||||
test_string_3,
|
||||
|
||||
test_vector_0,
|
||||
test_vector_1,
|
||||
test_vector_2,
|
||||
test_vector_3,
|
||||
test_vector_4,
|
||||
|
||||
test_address_space_0,
|
||||
test_address_space_1,
|
||||
test_address_space_2,
|
||||
test_address_space_3,
|
||||
test_address_space_4,
|
||||
};
|
||||
|
||||
const char *basefn_names[] = {
|
||||
"int_0",
|
||||
"int_1",
|
||||
"int_2",
|
||||
"int_3",
|
||||
"int_4",
|
||||
"int_5",
|
||||
"int_6",
|
||||
"int_7",
|
||||
"int_8",
|
||||
|
||||
"float_0",
|
||||
"float_1",
|
||||
"float_2",
|
||||
"float_3",
|
||||
"float_4",
|
||||
"float_5",
|
||||
"float_6",
|
||||
"float_7",
|
||||
"float_8",
|
||||
"float_9",
|
||||
"float_10",
|
||||
"float_11",
|
||||
"float_12",
|
||||
"float_13",
|
||||
"float_14",
|
||||
"float_15",
|
||||
#if ! defined( __ANDROID__ )
|
||||
"float_16",
|
||||
"float_17",
|
||||
#endif
|
||||
"float_18",
|
||||
"float_19",
|
||||
"float_20",
|
||||
|
||||
"octal_0",
|
||||
"octal_1",
|
||||
"octal_2",
|
||||
"octal_3",
|
||||
|
||||
"unsigned_0",
|
||||
"unsigned_1",
|
||||
|
||||
"hexadecimal_0",
|
||||
"hexadecimal_1",
|
||||
"hexadecimal_2",
|
||||
"hexadecimal_3",
|
||||
"hexadecimal_4",
|
||||
|
||||
"char_0",
|
||||
"char_1",
|
||||
"char_2",
|
||||
|
||||
"string_0",
|
||||
"string_1",
|
||||
"string_2",
|
||||
"string_3",
|
||||
|
||||
"vector_0",
|
||||
"vector_1",
|
||||
"vector_2",
|
||||
"vector_3",
|
||||
"vector_4",
|
||||
|
||||
"address_space_0",
|
||||
"address_space_1",
|
||||
"address_space_2",
|
||||
"address_space_3",
|
||||
"address_space_4",
|
||||
};
|
||||
|
||||
ct_assert((sizeof(basefn_names) / sizeof(basefn_names[0])) == (sizeof(basefn_list) / sizeof(basefn_list[0])));
|
||||
|
||||
int num_fns = sizeof(basefn_names) / sizeof(char *);
|
||||
|
||||
//-----------------------------------------
|
||||
// main
|
||||
//-----------------------------------------
|
||||
@@ -587,9 +1011,6 @@ int main(int argc, const char* argv[]) {
|
||||
int i;
|
||||
cl_device_type device_type = CL_DEVICE_TYPE_DEFAULT;
|
||||
cl_platform_id platform_id;
|
||||
long test_filter_num = 0; // test number to run or 0
|
||||
const char* exec_testname = NULL;
|
||||
cl_device_id device_id;
|
||||
uint32_t device_frequency = 0;
|
||||
uint32_t compute_devices = 0;
|
||||
|
||||
@@ -622,11 +1043,16 @@ int main(int argc, const char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if we want to run a particular test or if we want to
|
||||
// start running from a certain point and if we want to run on cpu/gpu
|
||||
// usage: test_printf [test_name] [start test num] [run_long]
|
||||
// default is to run all tests on the gpu and be short
|
||||
// test names are of the form printf_testId
|
||||
const char ** argList = (const char **)calloc( argc, sizeof( char*) );
|
||||
|
||||
if( NULL == argList )
|
||||
{
|
||||
log_error( "Failed to allocate memory for argList array.\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
argList[0] = argv[0];
|
||||
size_t argCount = 1;
|
||||
|
||||
for (i=1; i < argc; ++i) {
|
||||
const char *arg = argv[i];
|
||||
@@ -651,11 +1077,7 @@ int main(int argc, const char* argv[]) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
char* t = NULL;
|
||||
long num = strtol(argv[i], &t, 0);
|
||||
if (t != argv[i])
|
||||
test_filter_num = num;
|
||||
else if( 0 == strcmp( argv[i], "CL_DEVICE_TYPE_CPU" ) )
|
||||
if( 0 == strcmp( argv[i], "CL_DEVICE_TYPE_CPU" ) )
|
||||
device_type = CL_DEVICE_TYPE_CPU;
|
||||
else if( 0 == strcmp( argv[i], "CL_DEVICE_TYPE_GPU" ) )
|
||||
device_type = CL_DEVICE_TYPE_GPU;
|
||||
@@ -664,14 +1086,15 @@ int main(int argc, const char* argv[]) {
|
||||
else if( 0 == strcmp( argv[i], "CL_DEVICE_TYPE_DEFAULT" ) )
|
||||
device_type = CL_DEVICE_TYPE_DEFAULT;
|
||||
else {
|
||||
// assume it is a test name that we want to execute
|
||||
exec_testname = argv[i];
|
||||
argList[argCount] = arg;
|
||||
argCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int err;
|
||||
gFd = acquireOutputStream();
|
||||
|
||||
// Get platform
|
||||
err = clGetPlatformIDs(1, &platform_id, NULL);
|
||||
@@ -679,35 +1102,37 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
|
||||
// Get Device information
|
||||
err = clGetDeviceIDs(platform_id, device_type, 1, &device_id, 0);
|
||||
err = clGetDeviceIDs(platform_id, device_type, 1, &gDevice, 0);
|
||||
checkErr(err,"clGetComputeDevices");
|
||||
|
||||
|
||||
err = clGetDeviceInfo(device_id, CL_DEVICE_TYPE, sizeof(cl_device_type), &device_type, NULL);
|
||||
err = clGetDeviceInfo(gDevice, CL_DEVICE_TYPE, sizeof(cl_device_type), &device_type, NULL);
|
||||
checkErr(err,"clGetComputeConfigInfo 1");
|
||||
|
||||
|
||||
size_t config_size = sizeof( device_frequency );
|
||||
#if MULTITHREAD
|
||||
if( (err = clGetDeviceInfo(device_id, CL_DEVICE_MAX_COMPUTE_UNITS, config_size, &compute_devices, NULL )) )
|
||||
if( (err = clGetDeviceInfo(gDevice, CL_DEVICE_MAX_COMPUTE_UNITS, config_size, &compute_devices, NULL )) )
|
||||
#endif
|
||||
compute_devices = 1;
|
||||
|
||||
config_size = sizeof(device_frequency);
|
||||
if((err = clGetDeviceInfo(device_id, CL_DEVICE_MAX_CLOCK_FREQUENCY, config_size, &device_frequency, NULL )))
|
||||
if((err = clGetDeviceInfo(gDevice, CL_DEVICE_MAX_CLOCK_FREQUENCY, config_size, &device_frequency, NULL )))
|
||||
device_frequency = 1;
|
||||
|
||||
releaseOutputStream(gFd);
|
||||
|
||||
log_info( "\nCompute Device info:\n" );
|
||||
log_info( "\tProcessing with %d devices\n", compute_devices );
|
||||
log_info( "\tDevice Frequency: %d MHz\n", device_frequency );
|
||||
|
||||
|
||||
|
||||
printDeviceHeader( device_id );
|
||||
printDeviceHeader( gDevice );
|
||||
|
||||
printArch();
|
||||
|
||||
err = check_opencl_version(device_id,1,2);
|
||||
err = check_opencl_version(gDevice,1,2);
|
||||
if( err != CL_SUCCESS ) {
|
||||
print_missing_feature(err,"printf");
|
||||
test_finish();
|
||||
@@ -716,85 +1141,50 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
log_info( "Test binary built %s %s\n", __DATE__, __TIME__ );
|
||||
|
||||
cl_context context = clCreateContext(NULL, 1, &device_id, notify_callback, NULL, NULL);
|
||||
checkNull(context, "clCreateContext");
|
||||
gFd = acquireOutputStream();
|
||||
|
||||
cl_command_queue queue = clCreateCommandQueueWithProperties(context, device_id, 0, NULL);
|
||||
checkNull(queue, "clCreateCommandQueue");
|
||||
gContext = clCreateContext(NULL, 1, &gDevice, notify_callback, NULL, NULL);
|
||||
checkNull(gContext, "clCreateContext");
|
||||
|
||||
// Forall types
|
||||
for (int testId = 0; testId < TYPE_COUNT; ++testId) {
|
||||
if (test_filter_num && (testId != test_filter_num)) {
|
||||
log_info("\n*** Skipping printf for %s ***\n",strType[testId]);
|
||||
}
|
||||
else {
|
||||
log_info("\n*** Testing printf for %s ***\n",strType[testId]);
|
||||
gQueue = clCreateCommandQueueWithProperties(gContext, gDevice, 0, NULL);
|
||||
checkNull(gQueue, "clCreateCommandQueue");
|
||||
|
||||
//For all formats
|
||||
for(unsigned int testNum = 0;testNum < allTestCase[testId]->_testNum;++testNum){
|
||||
if(allTestCase[testId]->_type == TYPE_VECTOR)
|
||||
log_info("%d)testing printf(\"%sv%s%s\",%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].vectorFormatFlag,allTestCase[testId]->_genParameters[testNum].vectorSize,
|
||||
allTestCase[testId]->_genParameters[testNum].vectorFormatSpecifier,allTestCase[testId]->_genParameters[testNum].dataRepresentation);
|
||||
else if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE)
|
||||
{
|
||||
if(isKernelArgument(allTestCase[testId], testNum))
|
||||
log_info("%d)testing kernel //argument %s \n printf(%s,%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].addrSpaceArgumentTypeQualifier,
|
||||
allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].addrSpaceParameter);
|
||||
else
|
||||
log_info("%d)testing kernel //variable %s \n printf(%s,%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].addrSpaceVariableTypeQualifier,
|
||||
allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].addrSpaceParameter);
|
||||
}
|
||||
else
|
||||
log_info("%d)testing printf(\"%s\",%s)\n",testNum,allTestCase[testId]->_genParameters[testNum].genericFormat,allTestCase[testId]->_genParameters[testNum].dataRepresentation);
|
||||
releaseOutputStream(gFd);
|
||||
|
||||
// Long support for varible type
|
||||
if(allTestCase[testId]->_type == TYPE_VECTOR && !strcmp(allTestCase[testId]->_genParameters[testNum].dataType,"long") && !isLongSupported(device_id))
|
||||
continue;
|
||||
err = parseAndCallCommandLineTests( argCount, argList, NULL, num_fns, basefn_list, basefn_names, true, 0, 0 );
|
||||
|
||||
// Long support for address in FULL_PROFILE/EMBEDDED_PROFILE
|
||||
bool isLongSupport = true;
|
||||
if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE && isKernelPFormat(allTestCase[testId],testNum) && !isLongSupported(device_id))
|
||||
isLongSupport = false;
|
||||
|
||||
// Perform the test
|
||||
if (doTest(queue, context,testId,testNum,device_id,isLongSupport) != 0)
|
||||
{
|
||||
log_error("*** FAILED ***\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Passed\n");
|
||||
}
|
||||
}
|
||||
if(gQueue)
|
||||
{
|
||||
int error = clFinish(gQueue);
|
||||
if (error) {
|
||||
log_error("clFinish failed: %d\n", error);
|
||||
}
|
||||
}
|
||||
|
||||
int error = clFinish(queue);
|
||||
if (error) {
|
||||
log_error("clFinish failed: %d\n", error);
|
||||
}
|
||||
|
||||
if(clReleaseCommandQueue(queue)!=CL_SUCCESS)
|
||||
if(clReleaseCommandQueue(gQueue)!=CL_SUCCESS)
|
||||
log_error("clReleaseCommandQueue\n");
|
||||
if(clReleaseContext(context)!= CL_SUCCESS)
|
||||
if(clReleaseContext(gContext)!= CL_SUCCESS)
|
||||
log_error("clReleaseContext\n");
|
||||
|
||||
releaseOutputStream(gFd);
|
||||
|
||||
if (s_test_fail == 0) {
|
||||
if (s_test_cnt > 1)
|
||||
log_info("PASSED %d of %d tests.\n", s_test_cnt, s_test_cnt);
|
||||
else
|
||||
log_info("PASSED test.\n");
|
||||
} else if (s_test_fail > 0) {
|
||||
if (s_test_cnt > 1)
|
||||
{
|
||||
log_error("FAILED %d of %d tests.\n", s_test_fail, s_test_cnt);
|
||||
log_info("PASSED %d of %d tests.\n", s_test_cnt - s_test_fail, s_test_cnt);
|
||||
}
|
||||
else
|
||||
log_error(" FAILED test.\n");
|
||||
}
|
||||
|
||||
free(argList);
|
||||
|
||||
test_finish();
|
||||
return s_test_fail;
|
||||
return err;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// printUsage
|
||||
//-----------------------------------------
|
||||
static void printUsage( void )
|
||||
{
|
||||
log_info("test_printf: <optional: testnames> \n");
|
||||
log_info("\tdefault is to run the full test on the default device\n");
|
||||
log_info("\n");
|
||||
for( int i = 0; i < num_fns; i++ )
|
||||
{
|
||||
log_info( "\t%s\n", basefn_names[i] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user