Add L0 extension for extended module descriptor
Add ZE_experimental_module_program extension to L0 driver to support multiple input modules being passed to zeModuleCreate(). Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
parent
60d0d4d67f
commit
ba89a47aea
|
@ -105,8 +105,19 @@ ze_result_t DriverHandleImp::getExtensionFunctionAddress(const char *pFuncName,
|
||||||
|
|
||||||
ze_result_t DriverHandleImp::getExtensionProperties(uint32_t *pCount,
|
ze_result_t DriverHandleImp::getExtensionProperties(uint32_t *pCount,
|
||||||
ze_driver_extension_properties_t *pExtensionProperties) {
|
ze_driver_extension_properties_t *pExtensionProperties) {
|
||||||
|
if (nullptr == pExtensionProperties) {
|
||||||
|
*pCount = static_cast<uint32_t>(this->extensionsSupported.size());
|
||||||
|
return ZE_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
*pCount = 0;
|
*pCount = std::min(static_cast<uint32_t>(this->extensionsSupported.size()), *pCount);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < *pCount; i++) {
|
||||||
|
auto extension = this->extensionsSupported[i];
|
||||||
|
strncpy_s(pExtensionProperties[i].name, ZE_MAX_EXTENSION_NAME,
|
||||||
|
extension.first.c_str(), extension.first.length() + 1);
|
||||||
|
pExtensionProperties[i].version = extension.second;
|
||||||
|
}
|
||||||
|
|
||||||
return ZE_RESULT_SUCCESS;
|
return ZE_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "level_zero/core/source/driver/driver_handle.h"
|
#include "level_zero/core/source/driver/driver_handle.h"
|
||||||
#include "level_zero/core/source/get_extension_function_lookup_map.h"
|
#include "level_zero/core/source/get_extension_function_lookup_map.h"
|
||||||
|
#include "level_zero/extensions/public/ze_exp_ext.h"
|
||||||
|
|
||||||
namespace L0 {
|
namespace L0 {
|
||||||
|
|
||||||
|
@ -70,7 +71,6 @@ struct DriverHandleImp : public DriverHandle {
|
||||||
uint32_t parseAffinityMask(std::vector<std::unique_ptr<NEO::Device>> &neoDevices);
|
uint32_t parseAffinityMask(std::vector<std::unique_ptr<NEO::Device>> &neoDevices);
|
||||||
|
|
||||||
uint32_t numDevices = 0;
|
uint32_t numDevices = 0;
|
||||||
std::unordered_map<std::string, void *> extensionFunctionsLookupMap;
|
|
||||||
std::vector<Device *> devices;
|
std::vector<Device *> devices;
|
||||||
NEO::MemoryManager *memoryManager = nullptr;
|
NEO::MemoryManager *memoryManager = nullptr;
|
||||||
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
||||||
|
@ -80,6 +80,13 @@ struct DriverHandleImp : public DriverHandle {
|
||||||
std::string affinityMaskString = "";
|
std::string affinityMaskString = "";
|
||||||
bool enableProgramDebugging = false;
|
bool enableProgramDebugging = false;
|
||||||
bool enableSysman = false;
|
bool enableSysman = false;
|
||||||
|
|
||||||
|
// Spec extensions
|
||||||
|
const std::vector<std::pair<std::string, uint32_t>> extensionsSupported = {
|
||||||
|
{ZE_MODULE_PROGRAM_EXP_NAME, ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT}};
|
||||||
|
|
||||||
|
// Experimental functions
|
||||||
|
std::unordered_map<std::string, void *> extensionFunctionsLookupMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct DriverHandleImp *GlobalDriver;
|
extern struct DriverHandleImp *GlobalDriver;
|
||||||
|
|
|
@ -37,12 +37,27 @@ TEST(zeInit, whenCallingZeInitThenInitializeOnDriverIsCalled) {
|
||||||
|
|
||||||
using DriverVersionTest = Test<DeviceFixture>;
|
using DriverVersionTest = Test<DeviceFixture>;
|
||||||
|
|
||||||
TEST_F(DriverVersionTest, givenCallToGetExtensionPropertiesThenZeroExtensionPropertiesAreReturned) {
|
TEST_F(DriverVersionTest,
|
||||||
|
givenCallToGetExtensionPropertiesThenSupportedExtensionsAreReturned) {
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
ze_driver_extension_properties_t properties;
|
ze_result_t res = driverHandle->getExtensionProperties(&count, nullptr);
|
||||||
ze_result_t res = driverHandle->getExtensionProperties(&count, &properties);
|
EXPECT_EQ(count, static_cast<uint32_t>(driverHandle->extensionsSupported.size()));
|
||||||
EXPECT_EQ(count, 0u);
|
|
||||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||||
|
|
||||||
|
ze_driver_extension_properties_t *extensionProperties = new ze_driver_extension_properties_t[count];
|
||||||
|
count++;
|
||||||
|
res = driverHandle->getExtensionProperties(&count, extensionProperties);
|
||||||
|
EXPECT_EQ(count, static_cast<uint32_t>(driverHandle->extensionsSupported.size()));
|
||||||
|
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||||
|
|
||||||
|
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(driverHandle.get());
|
||||||
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
|
auto extension = extensionProperties[i];
|
||||||
|
EXPECT_EQ(0, strcmp(extension.name, driverHandleImp->extensionsSupported[i].first.c_str()));
|
||||||
|
EXPECT_EQ(extension.version, driverHandleImp->extensionsSupported[i].second);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] extensionProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DriverVersionTest, returnsExpectedDriverVersion) {
|
TEST_F(DriverVersionTest, returnsExpectedDriverVersion) {
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <level_zero/ze_api.h>
|
||||||
|
|
||||||
|
// Intel 'oneAPI' Level-Zero Extension for supporting module programs.
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef ZE_MODULE_PROGRAM_EXP_NAME
|
||||||
|
/// @brief Module Program Extension Name
|
||||||
|
#define ZE_MODULE_PROGRAM_EXP_NAME "ZE_experimental_module_program"
|
||||||
|
#endif // ZE_MODULE_PROGRAM_EXP_NAME
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief Module Program Extension Version(s)
|
||||||
|
typedef enum _ze_module_program_exp_version_t {
|
||||||
|
ZE_MODULE_PROGRAM_EXP_VERSION_1_0 = ZE_MAKE_VERSION(1, 0), ///< version 1.0
|
||||||
|
ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT = ZE_MAKE_VERSION(1, 0), ///< latest known version
|
||||||
|
ZE_MODULE_PROGRAM_EXP_VERSION_FORCE_UINT32 = 0x7fffffff
|
||||||
|
|
||||||
|
} ze_module_program_exp_version_t;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief Module extended descriptor to support multiple input modules.
|
||||||
|
///
|
||||||
|
/// @details
|
||||||
|
/// - Implementation must support ::ZE_experimental_module_program extension
|
||||||
|
/// - pInputModules, pBuildFlags, and pConstants from ::ze_module_desc_t is
|
||||||
|
/// ignored.
|
||||||
|
/// - Format in ::ze_module_desc_t needs to be set to
|
||||||
|
/// ::ZE_MODULE_FORMAT_IL_SPIRV.
|
||||||
|
typedef struct _ze_module_program_exp_desc_t {
|
||||||
|
ze_structure_type_t stype; ///< [in] type of this structure
|
||||||
|
const void *pNext; ///< [in][optional] pointer to extension-specific structure
|
||||||
|
uint32_t count; ///< [in] Count of input modules
|
||||||
|
const size_t *inputSizes; ///< [in][range(0, count)] sizes of each input IL module in pInputModules.
|
||||||
|
const uint8_t **pInputModules; ///< [in][range(0, count)] pointer to an array of IL (e.g. SPIR-V modules).
|
||||||
|
///< Valid only for SPIR-V input.
|
||||||
|
const char **pBuildFlags; ///< [in][optional][range(0, count)] array of strings containing build
|
||||||
|
///< flags. See pBuildFlags in ::ze_module_desc_t.
|
||||||
|
const ze_module_constants_t **pConstants; ///< [in][optional][range(0, count)] pointer to array of specialization
|
||||||
|
///< constant strings. Valid only for SPIR-V input. This must be set to
|
||||||
|
///< nullptr if no specialization constants are provided.
|
||||||
|
|
||||||
|
} ze_module_program_exp_desc_t;
|
Loading…
Reference in New Issue