diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index a49cb61b74..64b90b41a7 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -748,7 +748,7 @@ ze_result_t DeviceImp::getKernelProperties(ze_device_module_properties_t *pKerne size_t minorVersionPos = ilVersion.find('.'); if (majorVersionPos != std::string::npos && minorVersionPos != std::string::npos) { - uint32_t majorSpirvVersion = static_cast(std::stoul(ilVersion.substr(majorVersionPos + 1, minorVersionPos))); + uint32_t majorSpirvVersion = static_cast(std::stoul(ilVersion.substr(majorVersionPos + 1))); uint32_t minorSpirvVersion = static_cast(std::stoul(ilVersion.substr(minorVersionPos + 1))); pKernelProperties->spirvVersionSupported = ZE_MAKE_VERSION(majorSpirvVersion, minorSpirvVersion); } else { diff --git a/opencl/source/cl_device/cl_device.h b/opencl/source/cl_device/cl_device.h index eea18e5d94..5c6b26f012 100644 --- a/opencl/source/cl_device/cl_device.h +++ b/opencl/source/cl_device/cl_device.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -140,6 +140,7 @@ class ClDevice : public BaseObject<_cl_device_id> { void initializeCaps(); void initializeExtensionsWithVersion(); void initializeOpenclCAllVersions(); + void initializeILsWithVersion(); void initializeOsSpecificCaps(); void initGTPinHelper(); void setupFp64Flags(); diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index de713dbc8d..7413a60cfe 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -31,7 +31,6 @@ namespace NEO { static std::string vendor = "Intel(R) Corporation"; static std::string profile = "FULL_PROFILE"; static std::string spirVersions = "1.2 "; -static std::string spirvName = "SPIR-V"; const char *latestConformanceVersionPassed = "v2023-05-16-00"; #define QTR(a) #a #define TOSTR(b) QTR(b) @@ -142,8 +141,7 @@ void ClDevice::initializeCaps() { initializeOpenclCAllVersions(); deviceInfo.platformLP = (hwInfo.capabilityTable.supportsOcl21Features == false); deviceInfo.spirVersions = spirVersions.c_str(); - deviceInfo.ilsWithVersion[0].version = CL_MAKE_VERSION(1, 2, 0); - strcpy_s(deviceInfo.ilsWithVersion[0].name, CL_NAME_VERSION_MAX_NAME_SIZE, spirvName.c_str()); + initializeILsWithVersion(); deviceInfo.independentForwardProgress = hwInfo.capabilityTable.supportsIndependentForwardProgress; deviceInfo.maxNumOfSubGroups = 0; @@ -458,6 +456,25 @@ void ClDevice::initializeOpenclCAllVersions() { } } +void ClDevice::initializeILsWithVersion() { + std::stringstream ilsStringStream{device.getDeviceInfo().ilVersion}; + std::vector ilsVector{ + std::istream_iterator{ilsStringStream}, std::istream_iterator{}}; + deviceInfo.ilsWithVersion.reserve(ilsVector.size()); + for (auto &il : ilsVector) { + size_t majorVersionPos = il.find_last_of('_'); + size_t minorVersionPos = il.find_last_of('.'); + if (majorVersionPos != std::string::npos && minorVersionPos != std::string::npos) { + cl_name_version ilWithVersion; + uint32_t majorVersion = static_cast(std::stoul(il.substr(majorVersionPos + 1))); + uint32_t minorVersion = static_cast(std::stoul(il.substr(minorVersionPos + 1))); + strcpy_s(ilWithVersion.name, CL_NAME_VERSION_MAX_NAME_SIZE, il.substr(0, majorVersionPos).c_str()); + ilWithVersion.version = CL_MAKE_VERSION(majorVersion, minorVersion, 0); + deviceInfo.ilsWithVersion.push_back(ilWithVersion); + } + } +} + const std::string ClDevice::getClDeviceName() const { return this->getDevice().getDeviceInfo().name; } diff --git a/opencl/source/cl_device/cl_device_info.cpp b/opencl/source/cl_device/cl_device_info.cpp index c28365fe6d..afff4db07c 100644 --- a/opencl/source/cl_device/cl_device_info.cpp +++ b/opencl/source/cl_device/cl_device_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -106,7 +106,6 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, case CL_DEVICE_HALF_FP_CONFIG: getCap(src, srcSize, retSize); break; case CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL: getCap(src, srcSize, retSize); break; case CL_DEVICE_HOST_UNIFIED_MEMORY: getCap(src, srcSize, retSize); break; - case CL_DEVICE_ILS_WITH_VERSION: getCap(src, srcSize, retSize); break; case CL_DEVICE_IL_VERSION: getStr(src, srcSize, retSize); break; case CL_DEVICE_IMAGE_SUPPORT: getCap(src, srcSize, retSize); break; case CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED: getStr(src, srcSize, retSize); break; @@ -236,6 +235,10 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, src = deviceInfo.openclCFeatures.data(); retSize = srcSize = deviceInfo.openclCFeatures.size() * sizeof(cl_name_version); break; + case CL_DEVICE_ILS_WITH_VERSION: + src = deviceInfo.ilsWithVersion.data(); + retSize = srcSize = deviceInfo.ilsWithVersion.size() * sizeof(cl_name_version); + break; case CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION: src = deviceInfo.builtInKernelsWithVersion.data(); retSize = srcSize = deviceInfo.builtInKernelsWithVersion.size() * sizeof(cl_name_version); diff --git a/opencl/source/cl_device/cl_device_info.h b/opencl/source/cl_device/cl_device_info.h index 2a7547570a..1845f529d6 100644 --- a/opencl/source/cl_device/cl_device_info.h +++ b/opencl/source/cl_device/cl_device_info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -26,7 +26,7 @@ struct ClDeviceInfoParam { // clang-format off struct ClDeviceInfo { - cl_name_version ilsWithVersion[1]; + std::vector ilsWithVersion; StackVec builtInKernelsWithVersion; StackVec openclCAllVersions; OpenClCFeaturesContainer openclCFeatures; diff --git a/opencl/source/cl_device/cl_device_info_map.h b/opencl/source/cl_device/cl_device_info_map.h index 39d07fa51a..f987e0d1fc 100644 --- a/opencl/source/cl_device/cl_device_info_map.h +++ b/opencl/source/cl_device/cl_device_info_map.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -100,7 +100,6 @@ template<> struct Map : template<> struct Map : public ClMapBase {}; template<> struct Map : public ClMapBase {}; template<> struct Map : public ClMapBase {}; -template<> struct Map : public ClMapBase {}; template<> struct Map : public ClMapBase {}; template<> struct Map : public ClMapBase {}; template<> struct Map : public ClMapBase {}; diff --git a/opencl/test/unit_test/api/cl_get_device_info_tests.inl b/opencl/test/unit_test/api/cl_get_device_info_tests.inl index 629dc181b3..47caa978a0 100644 --- a/opencl/test/unit_test/api/cl_get_device_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_device_info_tests.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -292,7 +292,7 @@ TEST_F(clGetDeviceInfoTests, GivenClDeviceExtensionsParamWhenGettingDeviceInfoTh } } -TEST_F(clGetDeviceInfoTests, GivenClDeviceIlVersionParamWhenGettingDeviceInfoThenSpirv12IsReturned) { +TEST_F(clGetDeviceInfoTests, GivenClDeviceIlVersionParamWhenGettingDeviceInfoThenSpirv10To13IsReturned) { size_t paramRetSize = 0; cl_int retVal = clGetDeviceInfo( @@ -314,8 +314,9 @@ TEST_F(clGetDeviceInfoTests, GivenClDeviceIlVersionParamWhenGettingDeviceInfoThe nullptr); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_STREQ("SPIR-V_1.2 ", paramValue.get()); + EXPECT_STREQ("SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0 ", paramValue.get()); } + using matcherAtMostGen12lp = IsAtMostGfxCore; HWTEST2_F(clGetDeviceInfoTests, givenClDeviceSupportedThreadArbitrationPolicyIntelWhenCallClGetDeviceInfoThenProperArrayIsReturned, matcherAtMostGen12lp) { cl_device_info paramName = 0; diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index 34f724767c..f004d97757 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -178,7 +178,7 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) { EXPECT_NE(0u, caps.globalMemCacheSize); EXPECT_LT(0u, sharedCaps.globalMemSize); EXPECT_EQ(sharedCaps.maxMemAllocSize, caps.maxConstantBufferSize); - EXPECT_STREQ("SPIR-V_1.2 ", sharedCaps.ilVersion); + EXPECT_STREQ("SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0 ", sharedCaps.ilVersion); EXPECT_EQ(defaultHwInfo->capabilityTable.supportsIndependentForwardProgress, caps.independentForwardProgress); EXPECT_EQ(static_cast(CL_TRUE), caps.deviceAvailable); diff --git a/opencl/test/unit_test/device/get_device_info_size_tests.cpp b/opencl/test/unit_test/device/get_device_info_size_tests.cpp index 18d5609f07..a70dd59206 100644 --- a/opencl/test/unit_test/device/get_device_info_size_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_size_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -64,8 +64,8 @@ std::pair deviceInfoParams2[] = { {CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof(cl_uint)}, {CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong)}, {CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, sizeof(size_t)}, - {CL_DEVICE_ILS_WITH_VERSION, sizeof(cl_name_version[1])}, - {CL_DEVICE_IL_VERSION, sizeof(char[12])}, + // {CL_DEVICE_ILS_WITH_VERSION, sizeof(cl_name_version[])}, + // {CL_DEVICE_IL_VERSION, sizeof(char[])}, {CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool)}, {CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED, strlen(latestConformanceVersionPassed) + 1}, {CL_DEVICE_LINKER_AVAILABLE, sizeof(cl_bool)}, diff --git a/opencl/test/unit_test/device/get_device_info_tests.cpp b/opencl/test/unit_test/device/get_device_info_tests.cpp index 639b52ea9f..e22518b4d9 100644 --- a/opencl/test/unit_test/device/get_device_info_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -538,18 +538,24 @@ TEST(GetDeviceInfo, GivenPreferredInteropsWhenGettingDeviceInfoThenCorrectValueI EXPECT_EQ(sizeof(cl_bool), size); EXPECT_TRUE(value == 1u); } + TEST(GetDeviceInfo, WhenQueryingIlsWithVersionThenProperValueIsReturned) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - cl_name_version ilsWithVersion[1]; + constexpr auto ilCount = 4; + cl_name_version ilsWithVersion[ilCount]; size_t paramRetSize; const auto retVal = device->getDeviceInfo(CL_DEVICE_ILS_WITH_VERSION, sizeof(ilsWithVersion), &ilsWithVersion, ¶mRetSize); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(sizeof(cl_name_version), paramRetSize); - EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), ilsWithVersion->version); - EXPECT_STREQ("SPIR-V", ilsWithVersion->name); + EXPECT_EQ(sizeof(cl_name_version) * ilCount, paramRetSize); + for (int i = 0; i < ilCount; i++) { + EXPECT_EQ(1u, CL_VERSION_MAJOR(ilsWithVersion[i].version)); + EXPECT_GT(4u, CL_VERSION_MINOR(ilsWithVersion[i].version)); + EXPECT_EQ(0u, CL_VERSION_PATCH(ilsWithVersion[i].version)); + EXPECT_STREQ("SPIR-V", ilsWithVersion[i].name); + } } TEST(GetDeviceInfo, WhenQueryingAtomicMemoryCapabilitiesThenProperValueIsReturned) { diff --git a/shared/source/device/device_caps.cpp b/shared/source/device/device_caps.cpp index d483d74659..ec15f803ce 100644 --- a/shared/source/device/device_caps.cpp +++ b/shared/source/device/device_caps.cpp @@ -27,7 +27,7 @@ namespace NEO { -static const char *spirvWithVersion = "SPIR-V_1.2 "; +static const char *spirvWithVersion = "SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0 "; size_t Device::getMaxParameterSizeFromIGC() const { CompilerInterface *compilerInterface = getCompilerInterface(); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index d074e50ae9..3b97942a5e 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -460,7 +460,7 @@ TEST(DeviceGetCapsSimpleTest, givenVariousOclVersionsWhenCapsAreCreatedThenDevic debugManager.flags.ForceOCLVersion.set(oclVersion); auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); const auto &caps = device->getDeviceInfo(); - EXPECT_STREQ("SPIR-V_1.2 ", caps.ilVersion); + EXPECT_STREQ("SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0 ", caps.ilVersion); } }