Initial support for getExternalMemoryProperties and getExtensionProperties

Change-Id: Ib7c75dcae10bfb34dd2f703e481ecdd768370772
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2020-11-02 17:47:58 -08:00
parent 4e8296495c
commit 6ab9e9f1e0
8 changed files with 38 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ ZE_APIEXPORT ze_result_t ZE_APICALL
zeDeviceGetExternalMemoryProperties(
ze_device_handle_t hDevice,
ze_device_external_memory_properties_t *pExternalMemoryProperties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
return L0::Device::fromHandle(hDevice)->getExternalMemoryProperties(pExternalMemoryProperties);
}
ZE_APIEXPORT ze_result_t ZE_APICALL

View File

@@ -67,6 +67,7 @@ struct Device : _ze_device_handle_t {
virtual ze_result_t getCacheProperties(uint32_t *pCount, ze_device_cache_properties_t *pCacheProperties) = 0;
virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0;
virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0;
virtual ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) = 0;
virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0;

View File

@@ -404,6 +404,15 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
return ZE_RESULT_SUCCESS;
}
ze_result_t DeviceImp::getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) {
pExternalMemoryProperties->imageExportTypes = 0u;
pExternalMemoryProperties->imageImportTypes = 0u;
pExternalMemoryProperties->memoryAllocationExportTypes = 0u;
pExternalMemoryProperties->memoryAllocationImportTypes = 0u;
return ZE_RESULT_SUCCESS;
}
ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) {
if (*pCount == 0) {
*pCount = this->numSubDevices;

View File

@@ -44,6 +44,7 @@ struct DeviceImp : public Device {
ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) override;
ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) override;
ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) override;
ze_result_t systemBarrier() override;
void *getExecEnvironment() override;
BuiltinFunctionsLib *getBuiltinFunctionsLib() override;

View File

@@ -105,7 +105,10 @@ ze_result_t DriverHandleImp::getExtensionFunctionAddress(const char *pFuncName,
ze_result_t DriverHandleImp::getExtensionProperties(uint32_t *pCount,
ze_driver_extension_properties_t *pExtensionProperties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
*pCount = 0;
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::getMemAllocProperties(const void *ptr,

View File

@@ -134,6 +134,10 @@ struct Mock<Device> : public Device {
getDeviceImageProperties,
(ze_device_image_properties_t * pDeviceImageProperties),
(override));
MOCK_METHOD(ze_result_t,
getExternalMemoryProperties,
(ze_device_external_memory_properties_t * pExternalMemoryProperties),
(override));
MOCK_METHOD(ze_result_t,
systemBarrier,
(),

View File

@@ -267,6 +267,21 @@ TEST_F(DeviceTest, givenCallToDevicePropertiesThenTimestampValidBitsAreCorrectly
EXPECT_EQ(32u, deviceProps.kernelTimestampValidBits);
}
TEST_F(DeviceTest, whenGetExternalMemoryPropertiesIsCalledThenSuccessIsReturnedAndNoPropertiesAreReturned) {
ze_device_external_memory_properties_t externalMemoryProperties;
ze_result_t result = device->getExternalMemoryProperties(&externalMemoryProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(externalMemoryProperties.imageExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD, 0u);
EXPECT_EQ(externalMemoryProperties.imageExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF, 0u);
EXPECT_EQ(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD, 0u);
EXPECT_EQ(externalMemoryProperties.imageImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF, 0u);
EXPECT_EQ(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD, 0u);
EXPECT_EQ(externalMemoryProperties.memoryAllocationExportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF, 0u);
EXPECT_EQ(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD, 0u);
EXPECT_EQ(externalMemoryProperties.memoryAllocationImportTypes & ZE_EXTERNAL_MEMORY_TYPE_FLAG_DMA_BUF, 0u);
}
struct DeviceHasNoDoubleFp64Test : public ::testing::Test {
void SetUp() override {
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);

View File

@@ -35,11 +35,12 @@ TEST(zeInit, whenCallingZeInitThenInitializeOnDriverIsCalled) {
using DriverVersionTest = Test<DeviceFixture>;
TEST_F(DriverVersionTest, givenCallToGetExtensionPropertiesThenUnsupportedIsReturned) {
TEST_F(DriverVersionTest, givenCallToGetExtensionPropertiesThenZeroExtensionPropertiesAreReturned) {
uint32_t count = 0;
ze_driver_extension_properties_t properties;
ze_result_t res = driverHandle->getExtensionProperties(&count, &properties);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, res);
EXPECT_EQ(count, 0u);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
}
TEST_F(DriverVersionTest, returnsExpectedDriverVersion) {