cl20: Fix Issue #35 - ask for capability size. Too small size could cause errors (#95)

* Fix Issue #35 - ask for capability size. Too small size could cause errors

* Fix Issue #35 - fix windows compilation failure

* Fix Issue #35 - Review fixes

* Fix Issue #35 - Review fixes - build issues fixed
This commit is contained in:
Grzegorz Wawiorko
2019-05-23 19:20:59 +02:00
committed by Kévin Petit
parent 0fce6d5d62
commit 51db6e87cf
6 changed files with 53 additions and 31 deletions

View File

@@ -39,15 +39,18 @@ HarnessD3D10_ExtensionCheck()
bool extensionPresent = false;
cl_int result = CL_SUCCESS;
cl_platform_id platform = NULL;
char extensions[1024];
size_t set_size;
HarnessD3D10_TestBegin("Extension query");
result = clGetPlatformIDs(1, &platform, NULL);
NonTestRequire(result == CL_SUCCESS, "Failed to get any platforms.");
result = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, sizeof(extensions), extensions, NULL);
NonTestRequire(result == CL_SUCCESS, "Failed to list extensions.");
extensionPresent = strstr(extensions, "cl_khr_d3d10_sharing") ? true : false;
NonTestRequire(result == CL_SUCCESS, "Failed to get any platforms.");
result = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, 0, NULL, &set_size);
NonTestRequire(result == CL_SUCCESS, "Failed to get size of extensions string.");
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) {
// 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.");
for (cl_uint i = 0; i < devicesCount; i++) {
clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS, sizeof(extensions), extensions, NULL);
NonTestRequire(result == CL_SUCCESS, "Failed to list extensions.");
extensionPresent = strstr(extensions, "cl_khr_d3d10_sharing") ? true : false;
if (extensionPresent)
if (is_extension_available(devices[i], "cl_khr_d3d10_sharing")) {
extensionPresent = true;
break;
}
}
}

View File

@@ -40,6 +40,7 @@ typedef unsigned char UINT8;
#include <CL/cl_d3d10.h>
#include <stdio.h>
#include "errorHelpers.h"
#include "../test_common/harness/kernelHelpers.h"
// #define log_info(...) printf(__VA_ARGS__)
// #define log_error(...) printf(__VA_ARGS__)

View File

@@ -205,7 +205,6 @@ void TestAdapterDevices(cl_platform_id platform, IDXGIAdapter* pAdapter, ID3D10D
cl_int result;
cl_uint num_devices = 0;
cl_device_id* devices = NULL;
char extensions[8192];
devices = new cl_device_id[num_devices_expected];
NonTestRequire(
@@ -230,8 +229,7 @@ void TestAdapterDevices(cl_platform_id platform, IDXGIAdapter* pAdapter, ID3D10D
for (cl_uint i = 0; i < num_devices; ++i)
{
// 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 (strstr(extensions, "cl_khr_d3d10_sharing") == NULL) {
if (!is_extension_available(devices[i], "cl_khr_d3d10_sharing")) {
TestPrint("Device does not support cl_khr_d3d10_sharing extension\n");
continue;
}