feature: Adding support for OCL C support queries to ocloc

Feature needed for automated OCL C compilation with ocloc as backend.
Added queries :
* CL_DEVICE_EXTENSIONS
* CL_DEVICE_EXTENSIONS_WITH_VERSION
* CL_DEVICE_PROFILE
* CL_DEVICE_OPENCL_C_ALL_VERSIONS
* CL_DEVICE_OPENCL_C_FEATURES

Sample command line:
ocloc query -device skl CL_DEVICE_OPENCL_C_FEATURES

Related-To: GSD-7420

Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
Chodor, Jaroslaw
2023-11-16 16:48:56 +00:00
committed by Compute-Runtime-Automation
parent d99104d5bf
commit 7e795cd3c1
25 changed files with 809 additions and 157 deletions

View File

@@ -9,6 +9,7 @@
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/compiler_interface.inl"
#include "shared/source/compiler_interface/compiler_options.h"
#include "shared/source/compiler_interface/oclc_extensions.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_info.h"
@@ -1625,3 +1626,23 @@ TEST(TranslationOutput, givenZeroSizeWhenMakingCopyThenClearOutOutput) {
EXPECT_EQ(0U, dstBuffer.size);
EXPECT_EQ(nullptr, dstBuffer.mem);
}
TEST(getOclCExtensionVersion, whenQueryingVersionOfIntegerDotProductExtensionThenReturns200) {
cl_version defaultVer = CL_MAKE_VERSION(7, 2, 5);
cl_version ver = NEO::getOclCExtensionVersion("cl_khr_integer_dot_product", defaultVer);
cl_version expectedVer = CL_MAKE_VERSION(2, 0, 0);
EXPECT_EQ(expectedVer, ver);
}
TEST(getOclCExtensionVersion, whenCheckingVersionOfExternalMemoryExtensionThenReturns091) {
cl_version defaultVer = CL_MAKE_VERSION(7, 2, 5);
cl_version ver = NEO::getOclCExtensionVersion("cl_khr_external_memory", defaultVer);
cl_version expectedVer = CL_MAKE_VERSION(0, 9, 1);
EXPECT_EQ(expectedVer, ver);
}
TEST(getOclCExtensionVersion, whenCheckingVersionOfUntrackedExtensionThenReturnsDefaultValue) {
cl_version defaultVer = CL_MAKE_VERSION(7, 2, 5);
cl_version ver = NEO::getOclCExtensionVersion("other", defaultVer);
EXPECT_EQ(defaultVer, ver);
}

View File

@@ -314,3 +314,76 @@ HWTEST_F(CompilerProductHelperFixture, givenCompilerProductHelperWhenIsHeaplessM
auto &compilerProductHelper = pDevice->getCompilerProductHelper();
EXPECT_FALSE(compilerProductHelper.isHeaplessModeEnabled());
}
HWTEST_F(CompilerProductHelperFixture, WhenFullListOfSupportedOpenCLCVersionsIsRequestedThenReturnsListOfAllSupportedVersionsByTheAssociatedDevice) {
auto &compilerProductHelper = pDevice->getCompilerProductHelper();
auto versions = compilerProductHelper.getDeviceOpenCLCVersions(pDevice->getHardwareInfo(), NEO::OclCVersion{3, 0});
ASSERT_LT(3U, versions.size());
EXPECT_EQ(1, versions[0].major);
EXPECT_EQ(0, versions[0].minor);
EXPECT_EQ(1, versions[1].major);
EXPECT_EQ(1, versions[1].minor);
EXPECT_EQ(1, versions[2].major);
EXPECT_EQ(2, versions[2].minor);
if (pDevice->getHardwareInfo().capabilityTable.clVersionSupport == 30) {
ASSERT_EQ(4U, versions.size());
EXPECT_EQ(3, versions[3].major);
EXPECT_EQ(0, versions[3].minor);
} else {
EXPECT_EQ(3U, versions.size());
}
}
HWTEST_F(CompilerProductHelperFixture, WhenLimitedListOfSupportedOpenCLCVersionsIsRequestedThenReturnsListOfAllSupportedVersionsByTheAssociatedDeviceTrimmedToProvidedMax) {
auto &compilerProductHelper = pDevice->getCompilerProductHelper();
auto versions = compilerProductHelper.getDeviceOpenCLCVersions(pDevice->getHardwareInfo(), NEO::OclCVersion{1, 1});
ASSERT_EQ(2U, versions.size());
EXPECT_EQ(1, versions[0].major);
EXPECT_EQ(0, versions[0].minor);
EXPECT_EQ(1, versions[1].major);
EXPECT_EQ(1, versions[1].minor);
}
HWTEST_F(CompilerProductHelperFixture, GivenRequestForLimitedListOfSupportedOpenCLCVersionsWhenMaxVersionIsEmptyThenReturnsListOfAllSupportedVersionsByTheAssociatedDevice) {
auto &compilerProductHelper = pDevice->getCompilerProductHelper();
auto versions = compilerProductHelper.getDeviceOpenCLCVersions(pDevice->getHardwareInfo(), NEO::OclCVersion{0, 0});
ASSERT_LT(3U, versions.size());
EXPECT_EQ(1, versions[0].major);
EXPECT_EQ(0, versions[0].minor);
EXPECT_EQ(1, versions[1].major);
EXPECT_EQ(1, versions[1].minor);
EXPECT_EQ(1, versions[2].major);
EXPECT_EQ(2, versions[2].minor);
if (pDevice->getHardwareInfo().capabilityTable.clVersionSupport == 30) {
ASSERT_EQ(4U, versions.size());
EXPECT_EQ(3, versions[3].major);
EXPECT_EQ(0, versions[3].minor);
} else {
EXPECT_EQ(3U, versions.size());
}
}
HWTEST_F(CompilerProductHelperFixture, GivenRequestForLimitedListOfSupportedOpenCLCVersionsWhenMaxVersionIsBelow10ThenReturnsListOfAllSupportedVersionsByTheAssociatedDeviceTrimmedToOclC12) {
auto &compilerProductHelper = pDevice->getCompilerProductHelper();
auto versions = compilerProductHelper.getDeviceOpenCLCVersions(pDevice->getHardwareInfo(), NEO::OclCVersion{0, 1});
ASSERT_EQ(3U, versions.size());
EXPECT_EQ(1, versions[0].major);
EXPECT_EQ(0, versions[0].minor);
EXPECT_EQ(1, versions[1].major);
EXPECT_EQ(1, versions[1].minor);
EXPECT_EQ(1, versions[2].major);
EXPECT_EQ(2, versions[2].minor);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2022 Intel Corporation
* Copyright (C) 2019-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -267,3 +267,23 @@ TEST(ConstStringRefTrimEnd, givenTrimEndFunctionWithPredicateThatReturnsTrueForA
auto trimmed = str.trimEnd(predicate);
EXPECT_EQ(0u, trimmed.length());
}
TEST(ConstStringJoin, givenEmptyListOfStringsToJoinThenReturnEmptyString) {
std::string joined = NEO::ConstStringRef(" ").join(std::vector<std::string>{});
EXPECT_TRUE(joined.empty());
}
TEST(ConstStringJoin, givenOneStringOnListThenReturnThatString) {
std::string a = "aa";
std::string joined = NEO::ConstStringRef(" ").join(std::vector<std::string>{a});
ASSERT_FALSE(joined.empty());
EXPECT_EQ(a, joined);
}
TEST(ConstStringJoin, givenTwoStringOnListThenReturnThoseStringsJoinedWithConstring) {
std::string a = "aa";
std::string b = "bb";
std::string joined = NEO::ConstStringRef(" ").join(std::vector<std::string>{a, b});
ASSERT_FALSE(joined.empty());
EXPECT_EQ(std::string("aa bb"), joined);
}