Update CL_DEVICE_OPENCL_C_FEATURES query

Update query to return proper values.

Related-To: NEO-4368

Change-Id: Ie307429b3bf3a55fadd412a76a1eeb44e010aec8
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2020-06-10 16:32:38 +02:00
committed by sys_ocldev
parent dc02c41fae
commit e6fb967945
6 changed files with 124 additions and 20 deletions

View File

@ -44,31 +44,60 @@ struct DeviceGetCapsTest : public ::testing::Test {
}
void verifyOpenclCAllVersions(MockClDevice &clDevice) {
auto openclCWithVersion = clDevice.getDeviceInfo().openclCAllVersions.begin();
for (auto &openclCVersion : clDevice.getDeviceInfo().openclCAllVersions) {
EXPECT_STREQ("OpenCL C", openclCVersion.name);
}
EXPECT_STREQ("OpenCL C", openclCWithVersion->name);
EXPECT_EQ(CL_MAKE_VERSION(1u, 0u, 0u), openclCWithVersion->version);
openclCWithVersion++;
EXPECT_STREQ("OpenCL C", openclCWithVersion->name);
EXPECT_EQ(CL_MAKE_VERSION(1u, 1u, 0u), openclCWithVersion->version);
openclCWithVersion++;
EXPECT_STREQ("OpenCL C", openclCWithVersion->name);
EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), openclCWithVersion->version);
openclCWithVersion++;
auto openclCWithVersionIterator = clDevice.getDeviceInfo().openclCAllVersions.begin();
EXPECT_EQ(CL_MAKE_VERSION(1u, 0u, 0u), openclCWithVersionIterator->version);
EXPECT_EQ(CL_MAKE_VERSION(1u, 1u, 0u), (++openclCWithVersionIterator)->version);
EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), (++openclCWithVersionIterator)->version);
if (clDevice.areOcl21FeaturesEnabled()) {
EXPECT_STREQ("OpenCL C", openclCWithVersion->name);
EXPECT_EQ(CL_MAKE_VERSION(2u, 0u, 0u), openclCWithVersion->version);
openclCWithVersion++;
EXPECT_EQ(CL_MAKE_VERSION(2u, 0u, 0u), (++openclCWithVersionIterator)->version);
}
if (clDevice.getEnabledClVersion() == 30) {
EXPECT_STREQ("OpenCL C", openclCWithVersion->name);
EXPECT_EQ(CL_MAKE_VERSION(3u, 0u, 0u), openclCWithVersion->version);
openclCWithVersion++;
EXPECT_EQ(CL_MAKE_VERSION(3u, 0u, 0u), (++openclCWithVersionIterator)->version);
}
EXPECT_EQ(clDevice.getDeviceInfo().openclCAllVersions.end(), openclCWithVersion);
EXPECT_EQ(clDevice.getDeviceInfo().openclCAllVersions.end(), ++openclCWithVersionIterator);
}
void verifyOpenclCFeatures(MockClDevice &clDevice) {
for (auto &openclCFeature : clDevice.getDeviceInfo().openclCFeatures) {
EXPECT_EQ(CL_MAKE_VERSION(3u, 0u, 0u), openclCFeature.version);
}
auto &hwInfo = clDevice.getHardwareInfo();
auto openclCFeatureIterator = clDevice.getDeviceInfo().openclCFeatures.begin();
EXPECT_STREQ("__opencl_c_atomic_order_acq_rel", openclCFeatureIterator->name);
if (hwInfo.capabilityTable.supportsImages) {
EXPECT_STREQ("__opencl_c_3d_image_writes", (++openclCFeatureIterator)->name);
}
if (hwInfo.capabilityTable.supportsOcl21Features) {
EXPECT_STREQ("__opencl_c_atomic_order_seq_cst", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_atomic_scope_all_devices", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_atomic_scope_device", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_generic_address_space", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_program_scope_global_variables", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_read_write_images", (++openclCFeatureIterator)->name);
EXPECT_STREQ("__opencl_c_work_group_collective_functions", (++openclCFeatureIterator)->name);
if (clDevice.getDeviceInfo().independentForwardProgress) {
EXPECT_STREQ("__opencl_c_subgroups", (++openclCFeatureIterator)->name);
}
}
if (hwInfo.capabilityTable.supportsDeviceEnqueue) {
EXPECT_STREQ("__opencl_c_device_enqueue", (++openclCFeatureIterator)->name);
}
if (hwInfo.capabilityTable.supportsPipes) {
EXPECT_STREQ("__opencl_c_pipes", (++openclCFeatureIterator)->name);
}
EXPECT_EQ(clDevice.getDeviceInfo().openclCFeatures.end(), ++openclCFeatureIterator);
}
};
@ -94,6 +123,7 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) {
EXPECT_NE(nullptr, caps.clCVersion);
EXPECT_NE(0u, caps.numericClVersion);
EXPECT_GT(caps.openclCAllVersions.size(), 0u);
EXPECT_GT(caps.openclCFeatures.size(), 0u);
EXPECT_EQ(caps.extensionsWithVersion.size(), 0u);
EXPECT_NE(nullptr, caps.spirVersions);
@ -301,6 +331,7 @@ TEST_F(DeviceGetCapsTest, givenForceOclVersion30WhenCapsAreCreatedThenDeviceRepo
EXPECT_EQ(CL_MAKE_VERSION(3u, 0u, 0u), caps.numericClVersion);
EXPECT_FALSE(device->ocl21FeaturesEnabled);
verifyOpenclCAllVersions(*device);
verifyOpenclCFeatures(*device);
}
TEST_F(DeviceGetCapsTest, givenForceOclVersion21WhenCapsAreCreatedThenDeviceReportsOpenCL21) {
@ -313,6 +344,7 @@ TEST_F(DeviceGetCapsTest, givenForceOclVersion21WhenCapsAreCreatedThenDeviceRepo
EXPECT_EQ(CL_MAKE_VERSION(2u, 1u, 0u), caps.numericClVersion);
EXPECT_TRUE(device->ocl21FeaturesEnabled);
verifyOpenclCAllVersions(*device);
verifyOpenclCFeatures(*device);
}
TEST_F(DeviceGetCapsTest, givenForceOclVersion12WhenCapsAreCreatedThenDeviceReportsOpenCL12) {
@ -325,6 +357,7 @@ TEST_F(DeviceGetCapsTest, givenForceOclVersion12WhenCapsAreCreatedThenDeviceRepo
EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), caps.numericClVersion);
EXPECT_FALSE(device->ocl21FeaturesEnabled);
verifyOpenclCAllVersions(*device);
verifyOpenclCFeatures(*device);
}
TEST_F(DeviceGetCapsTest, givenForceOCL21FeaturesSupportEnabledWhenCapsAreCreatedThenDeviceReportsSupportOfOcl21Features) {
@ -362,6 +395,7 @@ TEST_F(DeviceGetCapsTest, givenForceInvalidOclVersionWhenCapsAreCreatedThenDevic
EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), caps.numericClVersion);
EXPECT_FALSE(device->ocl21FeaturesEnabled);
verifyOpenclCAllVersions(*device);
verifyOpenclCFeatures(*device);
}
TEST_F(DeviceGetCapsTest, givenForce32bitAddressingWhenCapsAreCreatedThenDeviceReports32bitAddressingOptimization) {

View File

@ -89,7 +89,7 @@ std::pair<uint32_t, size_t> deviceInfoParams2[] = {
{CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, sizeof(cl_uint)},
{CL_DEVICE_NUMERIC_VERSION, sizeof(cl_version)},
// {CL_DEVICE_OPENCL_C_ALL_VERSIONS, sizeof(cl_name_version[])},
{CL_DEVICE_OPENCL_C_FEATURES, 0u},
// {CL_DEVICE_OPENCL_C_FEATURES, sizeof(cl_name_version[])},
// {CL_DEVICE_OPENCL_C_VERSION, sizeof(char[])},
{CL_DEVICE_PARENT_DEVICE, sizeof(cl_device_id)},
{CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(cl_device_affinity_domain)},
@ -272,6 +272,20 @@ TEST(DeviceInfoTests, givenDefaultDeviceWhenQueriedForOpenclCAllVersionsThenProp
EXPECT_EQ(pClDevice->getDeviceInfo().openclCAllVersions.size() * sizeof(cl_name_version), sizeReturned);
}
TEST(DeviceInfoTests, givenDefaultDeviceWhenQueriedForOpenclCFeaturesThenProperSizeIsReturned) {
UltClDeviceFactory deviceFactory{1, 0};
auto pClDevice = deviceFactory.rootDevices[0];
size_t sizeReturned = 0;
auto retVal = pClDevice->getDeviceInfo(
CL_DEVICE_OPENCL_C_FEATURES,
0,
nullptr,
&sizeReturned);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pClDevice->getDeviceInfo().openclCFeatures.size() * sizeof(cl_name_version), sizeReturned);
}
TEST(DeviceInfoTests, givenDefaultDeviceWhenQueriedForExtensionsWithVersionThenProperSizeIsReturned) {
UltClDeviceFactory deviceFactory{1, 0};
auto pClDevice = deviceFactory.rootDevices[0];