Strengthen testing of CL_DEVICE_TYPE query and use of CL_DEVICE_TYPE* (#1977)

Issue: #1930
This commit is contained in:
Kamil-Goras-Mobica
2024-08-20 17:54:06 +02:00
committed by GitHub
parent b8981f5fb8
commit 746544af80
5 changed files with 205 additions and 35 deletions

View File

@@ -15,6 +15,8 @@
//
#include <stdio.h>
#include <string.h>
#include <bitset>
#include "harness/testHarness.h"
#include "harness/typeWrappers.h"
@@ -99,6 +101,20 @@ int test_device_info(cl_device_id device, cl_context context, cl_command_queue q
return -1;
}
cl_device_type device_type;
err_ret = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(cl_device_type),
&device_type, &ret_len);
test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_TYPE) failed");
std::bitset<sizeof(cl_device_type)> type_bits(device_type);
if (type_bits.count() > 1 || (device_type & CL_DEVICE_TYPE_DEFAULT))
{
log_error("clGetDeviceInfo(CL_DEVICE_TYPE) must report a single device "
"type, which must not be CL_DEVICE_TYPE_DEFAULT or "
"CL_DEVICE_TYPE_ALL.\n");
return -1;
}
return 0;
}