mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-24 15:59:03 +00:00
* Fix Issue #35 - ask for capability size. Too small size could cause errors * Fix Issue #35 - Review fixes * Fix Issue #35 - Review fixes - build issues fixed
This commit is contained in:
committed by
Kévin Petit
parent
bfb3e4aa2c
commit
fa312ab953
@@ -75,7 +75,7 @@ typedef union
|
|||||||
size_t sizet;
|
size_t sizet;
|
||||||
size_t sizet_arr[3];
|
size_t sizet_arr[3];
|
||||||
cl_ulong ull;
|
cl_ulong ull;
|
||||||
char string[1024];
|
char * string;
|
||||||
cl_device_svm_capabilities svmCapabilities;
|
cl_device_svm_capabilities svmCapabilities;
|
||||||
} config_data;
|
} config_data;
|
||||||
|
|
||||||
@@ -324,6 +324,7 @@ int getConfigInfo(cl_device_id device, config_info* info)
|
|||||||
{
|
{
|
||||||
int err = CL_SUCCESS;
|
int err = CL_SUCCESS;
|
||||||
int size_err = 0;
|
int size_err = 0;
|
||||||
|
size_t config_size_set;
|
||||||
size_t config_size_ret;
|
size_t config_size_ret;
|
||||||
switch(info->config_type)
|
switch(info->config_type)
|
||||||
{
|
{
|
||||||
@@ -376,7 +377,13 @@ int getConfigInfo(cl_device_id device, config_info* info)
|
|||||||
size_err = config_size_ret != sizeof(info->config.ull);
|
size_err = config_size_ret != sizeof(info->config.ull);
|
||||||
break;
|
break;
|
||||||
case type_string:
|
case type_string:
|
||||||
err = clGetDeviceInfo(device, info->opcode, sizeof(info->config.string), &info->config.string, &config_size_ret);
|
err = clGetDeviceInfo(device, info->opcode, 0, NULL, &config_size_set);
|
||||||
|
info->config.string = NULL;
|
||||||
|
if (err == CL_SUCCESS && config_size_set > 0) {
|
||||||
|
info->config.string = (char*)malloc(config_size_set);
|
||||||
|
err = clGetDeviceInfo(device, info->opcode, config_size_set, info->config.string, &config_size_ret);
|
||||||
|
size_err = config_size_set != config_size_ret;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case type_cl_device_svm_capabilities:
|
case type_cl_device_svm_capabilities:
|
||||||
err = clGetDeviceInfo(device, info->opcode, sizeof(info->config.svmCapabilities), &info->config.svmCapabilities, &config_size_ret);
|
err = clGetDeviceInfo(device, info->opcode, sizeof(info->config.svmCapabilities), &info->config.svmCapabilities, &config_size_ret);
|
||||||
@@ -524,7 +531,7 @@ void dumpConfigInfo(cl_device_id device, config_info* info)
|
|||||||
log_info("\t%s == %lld\n", info->opcode_name, info->config.ull);
|
log_info("\t%s == %lld\n", info->opcode_name, info->config.ull);
|
||||||
break;
|
break;
|
||||||
case type_string:
|
case type_string:
|
||||||
log_info("\t%s == \"%s\"\n", info->opcode_name, info->config.string);
|
log_info("\t%s == \"%s\"\n", info->opcode_name, info->config.string ? info->config.string : "");
|
||||||
break;
|
break;
|
||||||
case type_cl_device_svm_capabilities:
|
case type_cl_device_svm_capabilities:
|
||||||
log_info("\t%s == %s|%s|%s|%s\n", info->opcode_name,
|
log_info("\t%s == %s|%s|%s|%s\n", info->opcode_name,
|
||||||
@@ -679,15 +686,20 @@ int getConfigInfos( cl_device_id device )
|
|||||||
err = parseVersion( info.config.string, & version );
|
err = parseVersion( info.config.string, & version );
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
total_errors++;
|
total_errors++;
|
||||||
|
free(info.config.string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if ( info.opcode == CL_DEVICE_EXTENSIONS ) {
|
} else if ( info.opcode == CL_DEVICE_EXTENSIONS ) {
|
||||||
err = parseExtensions( info.config.string, & extensions );
|
err = parseExtensions( info.config.string, & extensions );
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
total_errors++;
|
total_errors++;
|
||||||
|
free(info.config.string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (info.config_type == type_string) {
|
||||||
|
free(info.config.string);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
total_errors++;
|
total_errors++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -703,18 +703,22 @@ test_status InitCL( cl_device_id device )
|
|||||||
gIsRTZ = 1;
|
gIsRTZ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char extensions[2048] = "";
|
else if(is_extension_available(device, "cl_khr_fp64"))
|
||||||
if( (error = clGetDeviceInfo( device, CL_DEVICE_EXTENSIONS, sizeof( extensions ), extensions, NULL ) ) )
|
|
||||||
{
|
|
||||||
vlog_error( "FAILURE: unable to get device info for CL_DEVICE_EXTENSIONS!" );
|
|
||||||
return TEST_FAIL;
|
|
||||||
}
|
|
||||||
else if( strstr( extensions, "cl_khr_fp64" ) )
|
|
||||||
{
|
{
|
||||||
gHasDouble = 1;
|
gHasDouble = 1;
|
||||||
}
|
}
|
||||||
gTestDouble &= gHasDouble;
|
gTestDouble &= gHasDouble;
|
||||||
|
|
||||||
|
//detect whether profile of the device is embedded
|
||||||
|
char profile[1024] = "";
|
||||||
|
if( (error = clGetDeviceInfo( device, CL_DEVICE_PROFILE, sizeof(profile), profile, NULL ) ) ){}
|
||||||
|
else if( strstr(profile, "EMBEDDED_PROFILE" ) )
|
||||||
|
{
|
||||||
|
gIsEmbedded = 1;
|
||||||
|
if( !is_extension_available(device, "cles_khr_int64" ) )
|
||||||
|
gHasLong = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gContext = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
|
gContext = clCreateContext( NULL, 1, &device, notify_callback, NULL, &error );
|
||||||
if( NULL == gContext || error )
|
if( NULL == gContext || error )
|
||||||
|
|||||||
@@ -39,15 +39,18 @@ HarnessD3D10_ExtensionCheck()
|
|||||||
bool extensionPresent = false;
|
bool extensionPresent = false;
|
||||||
cl_int result = CL_SUCCESS;
|
cl_int result = CL_SUCCESS;
|
||||||
cl_platform_id platform = NULL;
|
cl_platform_id platform = NULL;
|
||||||
char extensions[1024];
|
size_t set_size;
|
||||||
|
|
||||||
HarnessD3D10_TestBegin("Extension query");
|
HarnessD3D10_TestBegin("Extension query");
|
||||||
|
|
||||||
result = clGetPlatformIDs(1, &platform, NULL);
|
result = clGetPlatformIDs(1, &platform, NULL);
|
||||||
NonTestRequire(result == CL_SUCCESS, "Failed to get any platforms.");
|
NonTestRequire(result == CL_SUCCESS, "Failed to get any platforms.");
|
||||||
result = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, sizeof(extensions), extensions, NULL);
|
result = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, 0, NULL, &set_size);
|
||||||
NonTestRequire(result == CL_SUCCESS, "Failed to list extensions.");
|
NonTestRequire(result == CL_SUCCESS, "Failed to get size of extensions string.");
|
||||||
extensionPresent = strstr(extensions, "cl_khr_d3d10_sharing") ? true : false;
|
std::vector<char> extensions(set_size);
|
||||||
|
result = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, extensions.size(), extensions.data(), NULL);
|
||||||
|
NonTestRequire(result == CL_SUCCESS, "Failed to list extensions.");
|
||||||
|
extensionPresent = strstr(extensions.data(), "cl_khr_d3d10_sharing") ? true : false;
|
||||||
|
|
||||||
if (!extensionPresent) {
|
if (!extensionPresent) {
|
||||||
// platform is required to report the extension only if all devices support it
|
// platform is required to report the extension only if all devices support it
|
||||||
@@ -59,11 +62,10 @@ HarnessD3D10_ExtensionCheck()
|
|||||||
NonTestRequire(result == CL_SUCCESS, "Failed to get devices count.");
|
NonTestRequire(result == CL_SUCCESS, "Failed to get devices count.");
|
||||||
|
|
||||||
for (cl_uint i = 0; i < devicesCount; i++) {
|
for (cl_uint i = 0; i < devicesCount; i++) {
|
||||||
clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS, sizeof(extensions), extensions, NULL);
|
if (is_extension_available(devices[i], "cl_khr_d3d10_sharing")) {
|
||||||
NonTestRequire(result == CL_SUCCESS, "Failed to list extensions.");
|
extensionPresent = true;
|
||||||
extensionPresent = strstr(extensions, "cl_khr_d3d10_sharing") ? true : false;
|
|
||||||
if (extensionPresent)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ void TestAdapterDevices(cl_platform_id platform, IDXGIAdapter* pAdapter, ID3D10D
|
|||||||
cl_int result;
|
cl_int result;
|
||||||
cl_uint num_devices = 0;
|
cl_uint num_devices = 0;
|
||||||
cl_device_id* devices = NULL;
|
cl_device_id* devices = NULL;
|
||||||
char extensions[8192];
|
|
||||||
|
|
||||||
devices = new cl_device_id[num_devices_expected];
|
devices = new cl_device_id[num_devices_expected];
|
||||||
NonTestRequire(
|
NonTestRequire(
|
||||||
@@ -234,8 +233,7 @@ void TestAdapterDevices(cl_platform_id platform, IDXGIAdapter* pAdapter, ID3D10D
|
|||||||
for (cl_uint i = 0; i < num_devices; ++i)
|
for (cl_uint i = 0; i < num_devices; ++i)
|
||||||
{
|
{
|
||||||
// make sure the device supports the extension
|
// make sure the device supports the extension
|
||||||
result = clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS, sizeof(extensions), extensions, NULL); NonTestRequire(result == CL_SUCCESS, "Failed to get extensions.");
|
if (!is_extension_available(devices[i], "cl_khr_d3d10_sharing")) {
|
||||||
if (strstr(extensions, "cl_khr_d3d10_sharing") == NULL) {
|
|
||||||
TestPrint("Device does not support cl_khr_d3d10_sharing extension\n");
|
TestPrint("Device does not support cl_khr_d3d10_sharing extension\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
#include "datagen.h"
|
#include "datagen.h"
|
||||||
@@ -345,15 +346,19 @@ DataRow& DataTable::operator[](int index)
|
|||||||
*/
|
*/
|
||||||
OclExtensions OclExtensions::getDeviceCapabilities(cl_device_id devId)
|
OclExtensions OclExtensions::getDeviceCapabilities(cl_device_id devId)
|
||||||
{
|
{
|
||||||
char extensions[1024] = {0};
|
|
||||||
size_t size;
|
size_t size;
|
||||||
|
size_t set_size;
|
||||||
|
cl_int errcode = clGetDeviceInfo(devId, CL_DEVICE_EXTENSIONS, 0, NULL, &set_size);
|
||||||
|
if (errcode)
|
||||||
|
throw Exceptions::TestError("Device query failed");
|
||||||
// Querying the device for its supported extensions
|
// Querying the device for its supported extensions
|
||||||
cl_int errcode = clGetDeviceInfo(devId,
|
std::vector<char> extensions(set_size);
|
||||||
CL_DEVICE_EXTENSIONS,
|
errcode = clGetDeviceInfo(devId,
|
||||||
sizeof(extensions),
|
CL_DEVICE_EXTENSIONS,
|
||||||
extensions,
|
extensions.size(),
|
||||||
&size);
|
extensions.data(),
|
||||||
|
&size);
|
||||||
|
|
||||||
if (errcode)
|
if (errcode)
|
||||||
throw Exceptions::TestError("Device query failed");
|
throw Exceptions::TestError("Device query failed");
|
||||||
|
|
||||||
@@ -367,13 +372,13 @@ OclExtensions OclExtensions::getDeviceCapabilities(cl_device_id devId)
|
|||||||
throw Exceptions::TestError("Device query failed");
|
throw Exceptions::TestError("Device query failed");
|
||||||
|
|
||||||
OclExtensions ret = OclExtensions::empty();
|
OclExtensions ret = OclExtensions::empty();
|
||||||
assert(size < sizeof(extensions));
|
assert(size == set_size);
|
||||||
if (!size)
|
if (!size)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
// Iterate over the extensions, and convert them into the bit field.
|
// Iterate over the extensions, and convert them into the bit field.
|
||||||
std::list<std::string> extVector;
|
std::list<std::string> extVector;
|
||||||
std::stringstream khrStream(extensions);
|
std::stringstream khrStream(extensions.data());
|
||||||
std::copy(std::istream_iterator<std::string>(khrStream),
|
std::copy(std::istream_iterator<std::string>(khrStream),
|
||||||
std::istream_iterator<std::string>(),
|
std::istream_iterator<std::string>(),
|
||||||
std::back_inserter(extVector));
|
std::back_inserter(extVector));
|
||||||
|
|||||||
Reference in New Issue
Block a user