Fix code format errors

This commit is contained in:
Grzegorz Wawiorko
2020-07-06 13:05:22 +02:00
committed by Alastair Murray
parent c85527cec7
commit 44a240367e
16 changed files with 218 additions and 112 deletions

View File

@@ -665,30 +665,40 @@ static int create_single_kernel_helper_create_program_offline(cl_context context
size_t length = modifiedKernelBuf.size(); size_t length = modifiedKernelBuf.size();
log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithIL\n"); log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithIL\n");
if (gCoreILProgram) { if (gCoreILProgram)
*outProgram = clCreateProgramWithIL(context, &modifiedKernelBuf[0], length, &error); {
*outProgram = clCreateProgramWithIL(context, &modifiedKernelBuf[0],
length, &error);
} }
else { else
{
cl_platform_id platform; cl_platform_id platform;
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &platform, NULL);
print_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); print_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed");
clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL;
clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateProgramWithILKHR");
if (clCreateProgramWithILKHR == NULL) if (clCreateProgramWithILKHR == NULL)
{ {
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); log_error(
"ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1; return -1;
} }
*outProgram = clCreateProgramWithILKHR(context, &modifiedKernelBuf[0], length, &error); *outProgram = clCreateProgramWithILKHR(
context, &modifiedKernelBuf[0], length, &error);
} }
if (*outProgram == NULL || error != CL_SUCCESS) if (*outProgram == NULL || error != CL_SUCCESS)
{ {
if (gCoreILProgram) { if (gCoreILProgram)
{
print_error(error, "clCreateProgramWithIL failed"); print_error(error, "clCreateProgramWithIL failed");
} }
else { else
{
print_error(error, "clCreateProgramWithILKHR failed"); print_error(error, "clCreateProgramWithILKHR failed");
} }
return error; return error;

View File

@@ -57,7 +57,7 @@ int gIsEmbedded = 0;
int gIsOpenCL_C_1_0_Device = 0; int gIsOpenCL_C_1_0_Device = 0;
int gIsOpenCL_1_0_Device = 0; int gIsOpenCL_1_0_Device = 0;
int gHasLong = 1; int gHasLong = 1;
bool gCoreILProgram = true; bool gCoreILProgram = true;
#define DEFAULT_NUM_ELEMENTS 0x4000 #define DEFAULT_NUM_ELEMENTS 0x4000
@@ -79,9 +79,13 @@ int fail_init_info(int count) {
log_info("FAILED %d of %d tests.\n", count, count); log_info("FAILED %d of %d tests.\n", count, count);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
void version_expected_info(const char * test_name, const char * api_name, const char * expected_version, const char * device_version) { void version_expected_info(const char *test_name, const char *api_name,
log_info("%s skipped (requires at least %s version %s, but the device reports %s version %s)\n", const char *expected_version,
test_name, api_name, expected_version, api_name, device_version); const char *device_version)
{
log_info("%s skipped (requires at least %s version %s, but the device "
"reports %s version %s)\n",
test_name, api_name, expected_version, api_name, device_version);
} }
int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_definition testList[], int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_definition testList[],
int forceNoContextCreation, cl_command_queue_properties queueProps, int forceNoContextCreation, cl_command_queue_properties queueProps,
@@ -433,17 +437,16 @@ int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_def
log_error("Invalid device address bit size returned by device.\n"); log_error("Invalid device address bit size returned by device.\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (gCompilationMode == kSpir_v) { if (gCompilationMode == kSpir_v)
{
test_status spirv_readiness = check_spirv_compilation_readiness(device); test_status spirv_readiness = check_spirv_compilation_readiness(device);
if (spirv_readiness != TEST_PASS) { if (spirv_readiness != TEST_PASS)
{
switch (spirv_readiness) switch (spirv_readiness)
{ {
case TEST_PASS: case TEST_PASS: break;
break; case TEST_FAIL: return fail_init_info(testNum);
case TEST_FAIL: case TEST_SKIP: return skip_init_info(testNum);
return fail_init_info(testNum);
case TEST_SKIP:
return skip_init_info(testNum);
} }
} }
} }
@@ -699,7 +702,9 @@ test_status callSingleTestFunction( test_definition test, cl_device_id deviceToU
const Version device_version = get_device_cl_version(deviceToUse); const Version device_version = get_device_cl_version(deviceToUse);
if (test.min_version > device_version) if (test.min_version > device_version)
{ {
version_expected_info(test.name, "OpenCL", test.min_version.to_string().c_str(), device_version.to_string().c_str()); version_expected_info(test.name, "OpenCL",
test.min_version.to_string().c_str(),
device_version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }
@@ -905,48 +910,66 @@ Version get_device_cl_version(cl_device_id device)
throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data()); throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data());
} }
bool check_device_spirv_version_reported(cl_device_id device) { bool check_device_spirv_version_reported(cl_device_id device)
{
size_t str_size; size_t str_size;
cl_int err; cl_int err;
std::vector<char> str; std::vector<char> str;
if (gCoreILProgram) { if (gCoreILProgram)
{
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
if (err != CL_SUCCESS) { if (err != CL_SUCCESS)
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION size;"); {
log_error(
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION size;");
return false; return false;
} }
str.resize(str_size); str.resize(str_size);
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size, str.data(), NULL); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size,
if (err != CL_SUCCESS) { str.data(), NULL);
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;"); if (err != CL_SUCCESS)
{
log_error(
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;");
return false; return false;
} }
} }
else { else
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL, &str_size); {
if (err != CL_SUCCESS) { cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL,
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR size;"); &str_size);
if (err != CL_SUCCESS)
{
log_error(
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR size;");
return false; return false;
} }
str.resize(str_size); str.resize(str_size);
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size, str.data(), NULL); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size,
if (err != CL_SUCCESS) { str.data(), NULL);
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR value;"); if (err != CL_SUCCESS)
{
log_error(
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR value;");
return false; return false;
} }
} }
if (strstr(str.data(), "SPIR-V") == NULL) { if (strstr(str.data(), "SPIR-V") == NULL)
{
log_info("This device does not support SPIR-V offline compilation.\n"); log_info("This device does not support SPIR-V offline compilation.\n");
return false; return false;
} else { }
else
{
Version spirv_version = get_device_spirv_il_version(device); Version spirv_version = get_device_spirv_il_version(device);
log_info("This device supports SPIR-V offline compilation. SPIR-V version is %s\n", spirv_version.to_string().c_str()); log_info("This device supports SPIR-V offline compilation. SPIR-V "
"version is %s\n",
spirv_version.to_string().c_str());
} }
return true; return true;
} }
Version get_device_spirv_il_version(cl_device_id device) Version get_device_spirv_il_version(cl_device_id device)
@@ -954,20 +977,25 @@ Version get_device_spirv_il_version(cl_device_id device)
size_t str_size; size_t str_size;
cl_int err; cl_int err;
std::vector<char> str; std::vector<char> str;
if (gCoreILProgram) { if (gCoreILProgram)
{
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
ASSERT_SUCCESS(err, "clGetDeviceInfo"); ASSERT_SUCCESS(err, "clGetDeviceInfo");
str.resize(str_size); str.resize(str_size);
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size, str.data(), NULL); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size,
str.data(), NULL);
ASSERT_SUCCESS(err, "clGetDeviceInfo"); ASSERT_SUCCESS(err, "clGetDeviceInfo");
} }
else { else
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL, &str_size); {
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL,
&str_size);
ASSERT_SUCCESS(err, "clGetDeviceInfo"); ASSERT_SUCCESS(err, "clGetDeviceInfo");
str.resize(str_size); str.resize(str_size);
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size, str.data(), NULL); err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size,
str.data(), NULL);
ASSERT_SUCCESS(err, "clGetDeviceInfo"); ASSERT_SUCCESS(err, "clGetDeviceInfo");
} }
@@ -984,7 +1012,8 @@ Version get_device_spirv_il_version(cl_device_id device)
else if (strstr(str.data(), "SPIR-V_1.5") != NULL) else if (strstr(str.data(), "SPIR-V_1.5") != NULL)
return Version(1, 5); return Version(1, 5);
throw std::runtime_error(std::string("Unknown SPIR-V version: ") + str.data()); throw std::runtime_error(std::string("Unknown SPIR-V version: ")
+ str.data());
} }
test_status check_spirv_compilation_readiness(cl_device_id device) test_status check_spirv_compilation_readiness(cl_device_id device)
@@ -992,35 +1021,52 @@ test_status check_spirv_compilation_readiness(cl_device_id device)
auto ocl_version = get_device_cl_version(device); auto ocl_version = get_device_cl_version(device);
auto ocl_expected_min_version = Version(2, 1); auto ocl_expected_min_version = Version(2, 1);
if (ocl_version < ocl_expected_min_version) { if (ocl_version < ocl_expected_min_version)
if (is_extension_available(device, "cl_khr_il_program")) { {
if (is_extension_available(device, "cl_khr_il_program"))
{
gCoreILProgram = false; gCoreILProgram = false;
bool spirv_supported = check_device_spirv_version_reported(device); bool spirv_supported = check_device_spirv_version_reported(device);
if (spirv_supported == false) { if (spirv_supported == false)
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str()); {
log_error("SPIR-V intermediate language not supported !!! "
"OpenCL %s requires support.\n",
ocl_version.to_string().c_str());
return TEST_FAIL; return TEST_FAIL;
} }
else { else
{
return TEST_PASS; return TEST_PASS;
} }
} }
else { else
version_expected_info("Test", "OpenCL", ocl_expected_min_version.to_string().c_str(), ocl_version.to_string().c_str()); {
version_expected_info("Test", "OpenCL",
ocl_expected_min_version.to_string().c_str(),
ocl_version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }
} }
bool spirv_supported = check_device_spirv_version_reported(device); bool spirv_supported = check_device_spirv_version_reported(device);
if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2)) { if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2))
if (spirv_supported == false) { {
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str()); if (spirv_supported == false)
{
log_error("SPIR-V intermediate language not supported !!! OpenCL "
"%s requires support.\n",
ocl_version.to_string().c_str());
return TEST_FAIL; return TEST_FAIL;
} }
} }
if (ocl_version > Version(2, 2)) { if (ocl_version > Version(2, 2))
if (spirv_supported == false) { {
log_info("SPIR-V intermediate language not supported in OpenCL %s. Test skipped.\n", ocl_version.to_string().c_str()); if (spirv_supported == false)
{
log_info("SPIR-V intermediate language not supported in OpenCL %s. "
"Test skipped.\n",
ocl_version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }
} }

View File

@@ -137,7 +137,9 @@ extern cl_device_id GetOpposingDevice( cl_device_id device );
Version get_device_spirv_il_version(cl_device_id device); Version get_device_spirv_il_version(cl_device_id device);
bool check_device_spirv_il_support(cl_device_id device); bool check_device_spirv_il_support(cl_device_id device);
void version_expected_info(const char * test_name, const char * api_name, const char * expected_version, const char * device_version); void version_expected_info(const char *test_name, const char *api_name,
const char *expected_version,
const char *device_version);
test_status check_spirv_compilation_readiness(cl_device_id device); test_status check_spirv_compilation_readiness(cl_device_id device);
@@ -146,7 +148,7 @@ extern int gInfNanSupport; // This is set to 1 if the device suppor
extern int gIsEmbedded; // This is set to 1 if the device is an embedded device extern int gIsEmbedded; // This is set to 1 if the device is an embedded device
extern int gHasLong; // This is set to 1 if the device suppots long and ulong types in OpenCL C. extern int gHasLong; // This is set to 1 if the device suppots long and ulong types in OpenCL C.
extern int gIsOpenCL_C_1_0_Device; // This is set to 1 if the device supports only OpenCL C 1.0. extern int gIsOpenCL_C_1_0_Device; // This is set to 1 if the device supports only OpenCL C 1.0.
extern bool gCoreILProgram; extern bool gCoreILProgram;
#if ! defined( __APPLE__ ) #if ! defined( __APPLE__ )
void memset_pattern4(void *, const void *, size_t); void memset_pattern4(void *, const void *, size_t);

View File

@@ -281,7 +281,9 @@ test_status InitCL(cl_device_id device) {
auto version = get_device_cl_version(device); auto version = get_device_cl_version(device);
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) { if (version < expected_min_version) {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -110,7 +110,9 @@ test_status InitCL(cl_device_id device) {
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }
return TEST_PASS; return TEST_PASS;

View File

@@ -319,10 +319,10 @@ int main (int argc, const char **argv )
int ret = runTestHarnessWithCheck( 1, arg, test_num, test_list, true, 0, InitCL ); int ret = runTestHarnessWithCheck( 1, arg, test_num, test_list, true, 0, InitCL );
free_mtdata( gMTdata ); free_mtdata( gMTdata );
if (gQueue) { if (gQueue)
{
error = clFinish(gQueue); error = clFinish(gQueue);
if (error) if (error) vlog_error("clFinish failed: %d\n", error);
vlog_error("clFinish failed: %d\n", error);
} }
clReleaseMemObject(gInBuffer); clReleaseMemObject(gInBuffer);

View File

@@ -32,7 +32,9 @@ test_status InitCL(cl_device_id device) {
auto version = get_device_cl_version(device); auto version = get_device_cl_version(device);
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) { if (version < expected_min_version) {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -39,7 +39,9 @@ test_status InitCL(cl_device_id device) {
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -75,7 +75,9 @@ test_status InitCL(cl_device_id device) {
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -43,7 +43,9 @@ test_status InitCL(cl_device_id device) {
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }
return TEST_PASS; return TEST_PASS;

View File

@@ -24,7 +24,9 @@ test_status InitCL(cl_device_id device) {
auto version = get_device_cl_version(device); auto version = get_device_cl_version(device);
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) { if (version < expected_min_version) {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -1023,7 +1023,9 @@ test_status InitCL( cl_device_id device )
auto expected_min_version = Version(1, 2); auto expected_min_version = Version(1, 2);
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test", "OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }

View File

@@ -154,24 +154,33 @@ int get_program_with_il(clProgramWrapper &prog,
} }
unsigned char *buffer = &buffer_vec[0]; unsigned char *buffer = &buffer_vec[0];
if (gCoreILProgram) { if (gCoreILProgram)
{
prog = clCreateProgramWithIL(context, buffer, file_bytes, &err); prog = clCreateProgramWithIL(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithIL");
} }
else { else
{
cl_platform_id platform; cl_platform_id platform;
err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
SPIRV_CHECK_ERROR(err, "Failed to get platform info with clGetDeviceInfo"); sizeof(cl_platform_id), &platform, NULL);
SPIRV_CHECK_ERROR(err,
"Failed to get platform info with clGetDeviceInfo");
clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL;
clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateProgramWithILKHR");
if (clCreateProgramWithILKHR == NULL) if (clCreateProgramWithILKHR == NULL)
{ {
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); log_error(
"ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1; return -1;
} }
prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err); prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithILKHR"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithILKHR");
} }
err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL); err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL);
@@ -185,15 +194,18 @@ test_status InitCL(cl_device_id id)
test_status spirv_status; test_status spirv_status;
bool force = true; bool force = true;
spirv_status = check_spirv_compilation_readiness(id); spirv_status = check_spirv_compilation_readiness(id);
if (spirv_status != TEST_PASS) { if (spirv_status != TEST_PASS)
{
return spirv_status; return spirv_status;
} }
cl_uint address_bits; cl_uint address_bits;
cl_uint err = clGetDeviceInfo(id, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint), &address_bits, NULL); cl_uint err = clGetDeviceInfo(id, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint),
if(err != CL_SUCCESS){ &address_bits, NULL);
log_error("clGetDeviceInfo failed to get address bits!"); if (err != CL_SUCCESS)
return TEST_FAIL; {
log_error("clGetDeviceInfo failed to get address bits!");
return TEST_FAIL;
} }
gAddrWidth = address_bits == 32 ? "32" : "64"; gAddrWidth = address_bits == 32 ? "32" : "64";
@@ -234,8 +246,8 @@ int main(int argc, const char *argv[])
printUsage(); printUsage();
} }
return runTestHarnessWithCheck(argc, argv, return runTestHarnessWithCheck(
spirvTestsRegistry::getInstance().getNumTests(), argc, argv, spirvTestsRegistry::getInstance().getNumTests(),
spirvTestsRegistry::getInstance().getTestDefinitions(), spirvTestsRegistry::getInstance().getTestDefinitions(), false, 0,
false, 0, InitCL); InitCL);
} }

View File

@@ -33,34 +33,43 @@ static int test_linkage_compile(cl_device_id deviceID,
} }
unsigned char *buffer = &buffer_vec[0]; unsigned char *buffer = &buffer_vec[0];
if (gCoreILProgram) { if (gCoreILProgram)
{
prog = clCreateProgramWithIL(context, buffer, file_bytes, &err); prog = clCreateProgramWithIL(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithIL");
} }
else { else
{
cl_platform_id platform; cl_platform_id platform;
err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
SPIRV_CHECK_ERROR(err, "Failed to get platform info with clGetDeviceInfo"); sizeof(cl_platform_id), &platform, NULL);
SPIRV_CHECK_ERROR(err,
"Failed to get platform info with clGetDeviceInfo");
clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL;
clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateProgramWithILKHR");
if (clCreateProgramWithILKHR == NULL) if (clCreateProgramWithILKHR == NULL)
{ {
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); log_error(
"ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1; return -1;
} }
prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err); prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithILKHR"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithILKHR");
} }
err = clCompileProgram(prog, 1, &deviceID, err = clCompileProgram(prog, 1, &deviceID,
NULL, // options NULL, // options
0, // num headers 0, // num headers
NULL, // input headers NULL, // input headers
NULL, // header include names NULL, // header include names
NULL, // callback NULL, // callback
NULL // User data NULL // User data
); );
SPIRV_CHECK_ERROR(err, "Failed to compile spv program"); SPIRV_CHECK_ERROR(err, "Failed to compile spv program");
return 0; return 0;
} }

View File

@@ -30,34 +30,43 @@ TEST_SPIRV_FUNC(op_type_opaque_simple)
clProgramWrapper prog; clProgramWrapper prog;
if (gCoreILProgram) { if (gCoreILProgram)
{
prog = clCreateProgramWithIL(context, buffer, file_bytes, &err); prog = clCreateProgramWithIL(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithIL");
} }
else { else
{
cl_platform_id platform; cl_platform_id platform;
err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
SPIRV_CHECK_ERROR(err, "Failed to get platform info with clGetDeviceInfo"); sizeof(cl_platform_id), &platform, NULL);
SPIRV_CHECK_ERROR(err,
"Failed to get platform info with clGetDeviceInfo");
clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL;
clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateProgramWithILKHR");
if (clCreateProgramWithILKHR == NULL) if (clCreateProgramWithILKHR == NULL)
{ {
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); log_error(
"ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1; return -1;
} }
prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err); prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err);
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithILKHR"); SPIRV_CHECK_ERROR(
err, "Failed to create program with clCreateProgramWithILKHR");
} }
err = clCompileProgram(prog, 1, &deviceID, err = clCompileProgram(prog, 1, &deviceID,
NULL, // options NULL, // options
0, // num headers 0, // num headers
NULL, // input headers NULL, // input headers
NULL, // header include names NULL, // header include names
NULL, // callback NULL, // callback
NULL // User data NULL // User data
); );
SPIRV_CHECK_ERROR(err, "Failed to compile spv program"); SPIRV_CHECK_ERROR(err, "Failed to compile spv program");
return 0; return 0;
} }

View File

@@ -47,7 +47,9 @@ test_status InitCL(cl_device_id device) {
auto expected_min_version = Version(2, 0); auto expected_min_version = Version(2, 0);
if (version < expected_min_version) if (version < expected_min_version)
{ {
version_expected_info("Test","OpenCL", expected_min_version.to_string().c_str(), version.to_string().c_str()); version_expected_info("Test", "OpenCL",
expected_min_version.to_string().c_str(),
version.to_string().c_str());
return TEST_SKIP; return TEST_SKIP;
} }