From 30d3459aa94054e09118378e17d71783efa641ae Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Wed, 11 Mar 2020 14:15:36 +0100 Subject: [PATCH] Move test Move 9gen specific test to proper directory. Change-Id: I6dd493de8e3b8fce30ad0bc610fe419c7fba6f3a Signed-off-by: Filip Hazubski --- .../api/cl_get_platform_ids_tests.inl | 44 -------------- opencl/test/unit_test/gen9/CMakeLists.txt | 1 + .../gen9/cl_get_platform_ids_tests_gen9.cpp | 59 +++++++++++++++++++ 3 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 opencl/test/unit_test/gen9/cl_get_platform_ids_tests_gen9.cpp diff --git a/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl b/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl index b6cee7e163..2f2ce677e4 100644 --- a/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl +++ b/opencl/test/unit_test/api/cl_get_platform_ids_tests.inl @@ -5,7 +5,6 @@ * */ -#include "shared/source/device/root_device.h" #include "shared/source/os_interface/device_factory.h" #include "shared/test/unit_test/helpers/ult_hw_config.h" @@ -86,49 +85,6 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToCreateDeviceThenClGetPlatfomsIdsRe platformsImpl.clear(); } -TEST(clGetPlatformIDsMultiPlatformTest, whenCreateDevicesWithDifferentProductFamilyThenClGetPlatformIdsCreatesMultiplePlatformsProperlySorted) { - DebugManagerStateRestore restorer; - const size_t numRootDevices = 2u; - DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); - VariableBackup createFuncBackup{&DeviceFactory::createRootDeviceFunc}; - DeviceFactory::createRootDeviceFunc = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr { - auto device = std::unique_ptr(Device::create(&executionEnvironment, rootDeviceIndex)); - auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); - if (rootDeviceIndex == 0) { - hwInfo->platform.eProductFamily = IGFX_SKYLAKE; - } else { - hwInfo->platform.eProductFamily = IGFX_KABYLAKE; - } - return device; - }; - platformsImpl.clear(); - - cl_int retVal = CL_SUCCESS; - cl_platform_id platformsRet[2]; - cl_uint numPlatforms = 0; - - retVal = clGetPlatformIDs(0, nullptr, &numPlatforms); - EXPECT_EQ(2u, numPlatforms); - EXPECT_EQ(CL_SUCCESS, retVal); - - numPlatforms = 0u; - retVal = clGetPlatformIDs(2u, platformsRet, &numPlatforms); - EXPECT_EQ(2u, numPlatforms); - EXPECT_EQ(CL_SUCCESS, retVal); - - EXPECT_NE(nullptr, platformsRet[0]); - auto platform0 = castToObject(platformsRet[0]); - EXPECT_EQ(1u, platform0->getNumDevices()); - EXPECT_EQ(IGFX_KABYLAKE, platform0->getClDevice(0)->getHardwareInfo().platform.eProductFamily); - EXPECT_EQ(1u, platform0->getClDevice(0)->getRootDeviceIndex()); - - EXPECT_NE(nullptr, platformsRet[1]); - auto platform1 = castToObject(platformsRet[1]); - EXPECT_EQ(1u, platform1->getNumDevices()); - EXPECT_EQ(IGFX_SKYLAKE, platform1->getClDevice(0)->getHardwareInfo().platform.eProductFamily); - EXPECT_EQ(0u, platform1->getClDevice(0)->getRootDeviceIndex()); - platformsImpl.clear(); -} TEST(clGetPlatformIDsNegativeTests, whenFailToCreatePlatformThenClGetPlatfomsIdsReturnsOutOfHostMemoryError) { VariableBackup createFuncBackup{&Platform::createFunc}; Platform::createFunc = [](ExecutionEnvironment &executionEnvironment) -> std::unique_ptr { diff --git a/opencl/test/unit_test/gen9/CMakeLists.txt b/opencl/test/unit_test/gen9/CMakeLists.txt index 7d9356d723..a1fc11c0af 100644 --- a/opencl/test/unit_test/gen9/CMakeLists.txt +++ b/opencl/test/unit_test/gen9/CMakeLists.txt @@ -7,6 +7,7 @@ if(TESTS_GEN9) set(IGDRCL_SRCS_tests_gen9 ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/cl_get_platform_ids_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/coherency_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/enqueue_kernel_gen9.cpp diff --git a/opencl/test/unit_test/gen9/cl_get_platform_ids_tests_gen9.cpp b/opencl/test/unit_test/gen9/cl_get_platform_ids_tests_gen9.cpp new file mode 100644 index 0000000000..209f8499a1 --- /dev/null +++ b/opencl/test/unit_test/gen9/cl_get_platform_ids_tests_gen9.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/device/root_device.h" +#include "shared/source/os_interface/device_factory.h" + +#include "opencl/test/unit_test/api/cl_api_tests.h" + +using namespace NEO; + +typedef api_tests clGetPlatformIDsTests; + +TEST(clGetPlatformIDsMultiPlatformTest, whenCreateDevicesWithDifferentProductFamilyThenClGetPlatformIdsCreatesMultiplePlatformsProperlySorted) { + DebugManagerStateRestore restorer; + const size_t numRootDevices = 2u; + DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); + VariableBackup createFuncBackup{&DeviceFactory::createRootDeviceFunc}; + DeviceFactory::createRootDeviceFunc = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr { + auto device = std::unique_ptr(Device::create(&executionEnvironment, rootDeviceIndex)); + auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); + if (rootDeviceIndex == 0) { + hwInfo->platform.eProductFamily = IGFX_SKYLAKE; + } else { + hwInfo->platform.eProductFamily = IGFX_KABYLAKE; + } + return device; + }; + platformsImpl.clear(); + + cl_int retVal = CL_SUCCESS; + cl_platform_id platformsRet[2]; + cl_uint numPlatforms = 0; + + retVal = clGetPlatformIDs(0, nullptr, &numPlatforms); + EXPECT_EQ(2u, numPlatforms); + EXPECT_EQ(CL_SUCCESS, retVal); + + numPlatforms = 0u; + retVal = clGetPlatformIDs(2u, platformsRet, &numPlatforms); + EXPECT_EQ(2u, numPlatforms); + EXPECT_EQ(CL_SUCCESS, retVal); + + EXPECT_NE(nullptr, platformsRet[0]); + auto platform0 = castToObject(platformsRet[0]); + EXPECT_EQ(1u, platform0->getNumDevices()); + EXPECT_EQ(IGFX_KABYLAKE, platform0->getClDevice(0)->getHardwareInfo().platform.eProductFamily); + EXPECT_EQ(1u, platform0->getClDevice(0)->getRootDeviceIndex()); + + EXPECT_NE(nullptr, platformsRet[1]); + auto platform1 = castToObject(platformsRet[1]); + EXPECT_EQ(1u, platform1->getNumDevices()); + EXPECT_EQ(IGFX_SKYLAKE, platform1->getClDevice(0)->getHardwareInfo().platform.eProductFamily); + EXPECT_EQ(0u, platform1->getClDevice(0)->getRootDeviceIndex()); + platformsImpl.clear(); +}