mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Remove PlatformFixture from ApiFixture
Related-To: NEO-4632 Change-Id: Ia012f8de672b9d571a40a3e9514de396b6fee93a Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
9ca46b41f2
commit
3a9360629b
@ -7,42 +7,39 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/helpers/variable_backup.h"
|
||||
#include "shared/test/unit_test/helpers/default_hw_info.h"
|
||||
#include "shared/test/unit_test/mocks/mock_device.h"
|
||||
|
||||
#include "opencl/source/api/api.h"
|
||||
#include "opencl/source/command_queue/command_queue.h"
|
||||
#include "opencl/source/execution_environment/cl_execution_environment.h"
|
||||
#include "opencl/source/tracing/tracing_api.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "opencl/test/unit_test/helpers/ult_limits.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_kernel.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Context;
|
||||
class MockClDevice;
|
||||
struct RootDeviceEnvironment;
|
||||
|
||||
template <uint32_t rootDeviceIndex = 1u>
|
||||
struct ApiFixture : PlatformFixture {
|
||||
ApiFixture() = default;
|
||||
~ApiFixture() = default;
|
||||
struct ApiFixture {
|
||||
|
||||
virtual void SetUp() {
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
PlatformFixture::SetUp();
|
||||
|
||||
executionEnvironment = new ClExecutionEnvironment();
|
||||
prepareDeviceEnvironments(*executionEnvironment);
|
||||
Device *rootDevice = MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, rootDeviceIndex);
|
||||
if (rootDeviceIndex != 0u) {
|
||||
rootDeviceEnvironmentBackup.swap(pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
rootDeviceEnvironmentBackup.swap(executionEnvironment->rootDeviceEnvironments[0]);
|
||||
}
|
||||
|
||||
pDevice = pPlatform->getClDevice(testedRootDeviceIndex);
|
||||
pDevice = new ClDevice(*rootDevice, nullptr);
|
||||
ASSERT_NE(nullptr, pDevice);
|
||||
|
||||
testedClDevice = pDevice;
|
||||
@ -62,12 +59,10 @@ struct ApiFixture : PlatformFixture {
|
||||
pCommandQueue->release();
|
||||
pContext->release();
|
||||
pProgram->release();
|
||||
|
||||
if (rootDeviceIndex != 0u) {
|
||||
rootDeviceEnvironmentBackup.swap(pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
rootDeviceEnvironmentBackup.swap(executionEnvironment->rootDeviceEnvironments[0]);
|
||||
}
|
||||
|
||||
PlatformFixture::TearDown();
|
||||
pDevice->decRefInternal();
|
||||
}
|
||||
DebugManagerStateRestore restorer;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
@ -81,6 +76,7 @@ struct ApiFixture : PlatformFixture {
|
||||
constexpr static uint32_t testedRootDeviceIndex = rootDeviceIndex;
|
||||
cl_device_id testedClDevice = nullptr;
|
||||
ClDevice *pDevice = nullptr;
|
||||
ClExecutionEnvironment *executionEnvironment = nullptr;
|
||||
std::unique_ptr<RootDeviceEnvironment> rootDeviceEnvironmentBackup;
|
||||
};
|
||||
|
||||
|
@ -5,20 +5,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct clCreateContextFromTypeTests : public ApiFixture<0u>,
|
||||
public ::testing::Test {
|
||||
void SetUp() override {
|
||||
ApiFixture::SetUp();
|
||||
}
|
||||
void TearDown() override {
|
||||
ApiFixture::TearDown();
|
||||
}
|
||||
struct clCreateContextFromTypeTests : Test<PlatformFixture> {
|
||||
cl_int retVal = CL_DEVICE_NOT_AVAILABLE;
|
||||
};
|
||||
|
||||
namespace ULT {
|
||||
|
@ -134,7 +134,7 @@ class EnqueueReadBufferTest : public api_tests {
|
||||
}
|
||||
};
|
||||
TEST_F(EnqueueReadBufferTest, GivenSvmPtrWhenReadingBufferThenSuccessIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(testedRootDeviceIndex)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
auto data = clSVMAlloc(pContext, CL_MEM_READ_WRITE, bufferSize, 64);
|
||||
auto retVal = clEnqueueReadBuffer(pCommandQueue, buffer, CL_TRUE, bufferSize, 0, data, 0, nullptr, nullptr);
|
||||
|
@ -36,7 +36,7 @@ TEST_F(clEnqueueSVMFreeTests, GivenInvalidCommandQueueWhenFreeingSVMThenInvalidC
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMFreeTests, GivenNonZeroNumOfSVMPointersAndNullSVMPointersWhenFreeingSVMThenInvalidValueErrorIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
auto retVal = clEnqueueSVMFree(
|
||||
pCommandQueue, // cl_command_queue command_queue
|
||||
@ -53,7 +53,7 @@ TEST_F(clEnqueueSVMFreeTests, GivenNonZeroNumOfSVMPointersAndNullSVMPointersWhen
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMFreeTests, GivenZeroNumOfSVMPointersAndNonNullSVMPointersWhenFreeingSVMThenInvalidValueErrorIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||
EXPECT_NE(nullptr, ptrSvm);
|
||||
@ -106,7 +106,7 @@ TEST_F(clEnqueueSVMFreeTests, GivenZeroNumOfEventsAndNonNullEventListWhenFreeing
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMFreeTests, GivenNonZeroNumOfSVMPointersAndNonNullSVMPointersWhenFreeingSVMThenSuccessIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||
EXPECT_NE(nullptr, ptrSvm);
|
||||
@ -129,7 +129,7 @@ TEST_F(clEnqueueSVMFreeTests, GivenNonZeroNumOfSVMPointersAndNonNullSVMPointersW
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMFreeTests, GivenZeroNumOfSVMPointersAndNullSVMPointersWhenFreeingSVMThenSuccessIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
auto retVal = clEnqueueSVMFree(
|
||||
pCommandQueue, // cl_command_queue command_queue
|
||||
|
@ -35,7 +35,7 @@ TEST_F(clEnqueueSVMMapTests, GivenInvalidCommandQueueWhenMappingSVMThenInvalidCo
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMMapTests, GivenNullSVMPointerWhenMappingSVMThenInvalidValueErrorIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
auto retVal = clEnqueueSVMMap(
|
||||
pCommandQueue, // cl_command_queue command_queue
|
||||
@ -52,7 +52,7 @@ TEST_F(clEnqueueSVMMapTests, GivenNullSVMPointerWhenMappingSVMThenInvalidValueEr
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMMapTests, GivenRegionSizeZeroWhenMappingSVMThenInvalidValueErrorIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||
EXPECT_NE(nullptr, ptrSvm);
|
||||
@ -104,7 +104,7 @@ TEST_F(clEnqueueSVMMapTests, GivenNonNullEventWaitListAndZeroNumEventsWhenMappin
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueSVMMapTests, GivenValidParametersWhenMappingSVMThenSuccessIsReturned) {
|
||||
const ClDeviceInfo &devInfo = pPlatform->getClDevice(0)->getDeviceInfo();
|
||||
const ClDeviceInfo &devInfo = pDevice->getDeviceInfo();
|
||||
if (devInfo.svmCapabilities != 0) {
|
||||
void *ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||
EXPECT_NE(nullptr, ptrSvm);
|
||||
|
@ -10,21 +10,19 @@
|
||||
#include "shared/test/unit_test/helpers/ult_hw_config.h"
|
||||
#include "shared/test/unit_test/helpers/variable_backup.h"
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using clGetDeviceIDsTests = api_tests;
|
||||
using clGetDeviceIDsTests = Test<PlatformFixture>;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
TEST_F(clGetDeviceIDsTests, GivenZeroNumEntriesWhenGettingDeviceIdsThenNumberOfDevicesIsGreaterThanZero) {
|
||||
cl_uint numDevices = 0;
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numDevices);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numDevices);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_GT(numDevices, (cl_uint)0);
|
||||
@ -34,7 +32,7 @@ TEST_F(clGetDeviceIDsTests, GivenNonNullDevicesWhenGettingDeviceIdsThenDeviceIdI
|
||||
cl_uint numEntries = 1;
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
@ -42,22 +40,22 @@ TEST_F(clGetDeviceIDsTests, GivenNullPlatformWhenGettingDeviceIdsThenDeviceIdIsR
|
||||
cl_uint numEntries = 1;
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceIDsTests, GivenInvalidDeviceTypeWhenGettingDeviceIdsThenInvalidDeivceTypeErrorIsReturned) {
|
||||
TEST_F(clGetDeviceIDsTests, GivenInvalidDeviceTypeWhenGettingDeviceIdsThenInvalidDeviceTypeErrorIsReturned) {
|
||||
cl_uint numEntries = 1;
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, 0x0f00, numEntries, pDevices, nullptr);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, 0x0f00, numEntries, pDevices, nullptr);
|
||||
EXPECT_EQ(CL_INVALID_DEVICE_TYPE, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clGetDeviceIDsTests, GivenZeroNumEntriesAndNonNullDevicesWhenGettingDeviceIdsThenInvalidValueErrorIsReturned) {
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, 0, pDevices, nullptr);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, 0, pDevices, nullptr);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
@ -67,7 +65,7 @@ TEST_F(clGetDeviceIDsTests, GivenInvalidPlatformWhenGettingDeviceIdsThenInvalidP
|
||||
uint32_t trash[6] = {0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef};
|
||||
cl_platform_id p = reinterpret_cast<cl_platform_id>(trash);
|
||||
|
||||
retVal = clGetDeviceIDs(p, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
auto retVal = clGetDeviceIDs(p, CL_DEVICE_TYPE_GPU, numEntries, pDevices, nullptr);
|
||||
EXPECT_EQ(CL_INVALID_PLATFORM, retVal);
|
||||
}
|
||||
|
||||
@ -76,7 +74,7 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeAllWhenGettingDeviceIdsThenDeviceIdIs
|
||||
cl_uint numEntries = 1;
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_ALL, numEntries, pDevices, &numDevices);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_ALL, numEntries, pDevices, &numDevices);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_GT(numDevices, (cl_uint)0);
|
||||
}
|
||||
@ -86,7 +84,7 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeDefaultWhenGettingDeviceIdsThenDevice
|
||||
cl_uint numEntries = 1;
|
||||
cl_device_id pDevices[1];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_DEFAULT, numEntries, pDevices, &numDevices);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_DEFAULT, numEntries, pDevices, &numDevices);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_GT(numDevices, (cl_uint)0);
|
||||
}
|
||||
@ -94,7 +92,7 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeDefaultWhenGettingDeviceIdsThenDevice
|
||||
TEST_F(clGetDeviceIDsTests, GivenDeviceTypeCpuWhenGettingDeviceIdsThenDeviceNotFoundErrorIsReturned) {
|
||||
cl_uint numDevices = 0;
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_CPU, 0, nullptr, &numDevices);
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_CPU, 0, nullptr, &numDevices);
|
||||
|
||||
EXPECT_EQ(CL_DEVICE_NOT_FOUND, retVal);
|
||||
EXPECT_EQ(numDevices, (cl_uint)0);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(clGetDeviceInfoTests, givenOpenCLDeviceWhenAskedForSupportedSvmTypeCorrec
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
const HardwareInfo &hwInfo = pPlatform->getClDevice(testedRootDeviceIndex)->getHardwareInfo();
|
||||
const HardwareInfo &hwInfo = pDevice->getHardwareInfo();
|
||||
|
||||
cl_device_svm_capabilities expectedCaps = 0;
|
||||
if (hwInfo.capabilityTable.ftrSvm != 0) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef api_tests clGetExtensionFunctionAddressForPlatformTests;
|
||||
using clGetExtensionFunctionAddressForPlatformTests = Test<PlatformFixture>;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
|
@ -5,25 +5,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
#include "opencl/source/cl_device/cl_device.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "CL/cl_ext.h"
|
||||
#include "cl_api_tests.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct clGetPlatformInfoTests : public api_tests {
|
||||
struct clGetPlatformInfoTests : Test<PlatformFixture> {
|
||||
void SetUp() override {
|
||||
api_tests::SetUp();
|
||||
Test<PlatformFixture>::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete[] paramValue;
|
||||
api_tests::TearDown();
|
||||
Test<PlatformFixture>::TearDown();
|
||||
}
|
||||
|
||||
char *getPlatformInfoString(Platform *pPlatform, cl_platform_info paramName) {
|
||||
@ -40,6 +35,7 @@ struct clGetPlatformInfoTests : public api_tests {
|
||||
return value;
|
||||
}
|
||||
|
||||
size_t retSize = 0;
|
||||
char *paramValue = nullptr;
|
||||
};
|
||||
|
||||
@ -123,7 +119,7 @@ TEST_F(clGetPlatformInfoTests, GivenClPlatformHostTimerResolutionWhenGettingPlat
|
||||
|
||||
TEST_F(clGetPlatformInfoTests, GivenNullPlatformWhenGettingPlatformInfoStringThenClInvalidPlatformErrorIsReturned) {
|
||||
char extensions[512];
|
||||
retVal = clGetPlatformInfo(
|
||||
auto retVal = clGetPlatformInfo(
|
||||
nullptr, // invalid platform
|
||||
CL_PLATFORM_EXTENSIONS,
|
||||
sizeof(extensions),
|
||||
@ -135,7 +131,7 @@ TEST_F(clGetPlatformInfoTests, GivenNullPlatformWhenGettingPlatformInfoStringThe
|
||||
|
||||
TEST_F(clGetPlatformInfoTests, GivenInvalidParamNameWhenGettingPlatformInfoStringThenClInvalidValueErrorIsReturned) {
|
||||
char extensions[512];
|
||||
retVal = clGetPlatformInfo(
|
||||
auto retVal = clGetPlatformInfo(
|
||||
pPlatform,
|
||||
0, // invalid platform info enum
|
||||
sizeof(extensions),
|
||||
@ -147,7 +143,7 @@ TEST_F(clGetPlatformInfoTests, GivenInvalidParamNameWhenGettingPlatformInfoStrin
|
||||
|
||||
TEST_F(clGetPlatformInfoTests, GivenInvalidParamSizeWhenGettingPlatformInfoStringThenClInvalidValueErrorIsReturned) {
|
||||
char extensions[512];
|
||||
retVal = clGetPlatformInfo(
|
||||
auto retVal = clGetPlatformInfo(
|
||||
pPlatform,
|
||||
CL_PLATFORM_EXTENSIONS,
|
||||
0, // invalid size
|
||||
|
@ -5,20 +5,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
||||
#endif
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
#include "opencl/test/unit_test/api/cl_api_tests.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "opencl/source/cl_device/cl_device.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef api_tests clIcdGetPlatformIDsKHRTests;
|
||||
using clIcdGetPlatformIDsKHRTests = Test<PlatformFixture>;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
@ -48,7 +41,7 @@ TEST_F(clIcdGetPlatformIDsKHRTests, checkDeviceId) {
|
||||
cl_uint numPlatforms = 0;
|
||||
cl_uint numPlatformsIcd = 0;
|
||||
|
||||
retVal = clGetPlatformIDs(0, nullptr, &numPlatforms);
|
||||
auto retVal = clGetPlatformIDs(0, nullptr, &numPlatforms);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = clIcdGetPlatformIDsKHR(0, nullptr, &numPlatformsIcd);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
@ -24,7 +24,7 @@ class clReleaseCommandQueueTypeTests : public DeviceHostQueueFixture<T> {};
|
||||
TYPED_TEST_CASE(clReleaseCommandQueueTypeTests, QueueTypes);
|
||||
|
||||
TYPED_TEST(clReleaseCommandQueueTypeTests, GivenValidCmdQueueWhenReleasingCmdQueueThenSucessIsReturned) {
|
||||
if (std::is_same<TypeParam, DeviceQueue>::value && !castToObject<ClDevice>(this->devices[this->testedRootDeviceIndex])->getHardwareInfo().capabilityTable.supportsDeviceEnqueue) {
|
||||
if (std::is_same<TypeParam, DeviceQueue>::value && !this->pDevice->getHardwareInfo().capabilityTable.supportsDeviceEnqueue) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class clRetainReleaseCommandQueueTests : public DeviceHostQueueFixture<T> {};
|
||||
TYPED_TEST_CASE(clRetainReleaseCommandQueueTests, QueueTypes);
|
||||
|
||||
TYPED_TEST(clRetainReleaseCommandQueueTests, GivenValidCommandQueueWhenRetainingAndReleasingThenReferenceCountIsUpdatedCorrectly) {
|
||||
if (std::is_same<TypeParam, DeviceQueue>::value && !castToObject<ClDevice>(this->devices[this->testedRootDeviceIndex])->getHardwareInfo().capabilityTable.supportsDeviceEnqueue) {
|
||||
if (std::is_same<TypeParam, DeviceQueue>::value && !this->pDevice->getHardwareInfo().capabilityTable.supportsDeviceEnqueue) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,54 +5,60 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
|
||||
#include "cl_api_tests.h"
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef api_tests clRetainReleaseDeviceTests;
|
||||
struct clRetainReleaseDeviceTests : Test<PlatformFixture> {
|
||||
void SetUp() override {
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(maxRootDeviceCount);
|
||||
Test<PlatformFixture>::SetUp();
|
||||
}
|
||||
DebugManagerStateRestore restorer;
|
||||
const uint32_t rootDeviceIndex = 1u;
|
||||
};
|
||||
|
||||
namespace ULT {
|
||||
TEST_F(clRetainReleaseDeviceTests, GivenRootDeviceWhenRetainingThenReferenceCountIsOne) {
|
||||
cl_uint numEntries = numRootDevices;
|
||||
cl_device_id devices[numRootDevices];
|
||||
|
||||
retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, numEntries, devices,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clRetainDevice(testedClDevice);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clRetainDevice(testedClDevice);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
cl_uint theRef;
|
||||
retVal = clGetDeviceInfo(testedClDevice, CL_DEVICE_REFERENCE_COUNT,
|
||||
sizeof(cl_uint), &theRef, NULL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(1u, theRef);
|
||||
}
|
||||
|
||||
TEST_F(clRetainReleaseDeviceTests, GivenRootDeviceWhenReleasingThenReferenceCountIsOne) {
|
||||
constexpr cl_uint numEntries = numRootDevices;
|
||||
cl_device_id devices[numRootDevices];
|
||||
cl_uint numEntries = maxRootDeviceCount;
|
||||
cl_device_id devices[maxRootDeviceCount];
|
||||
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, numEntries, devices,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseDevice(testedClDevice);
|
||||
retVal = clRetainDevice(devices[rootDeviceIndex]);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseDevice(testedClDevice);
|
||||
retVal = clRetainDevice(devices[rootDeviceIndex]);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
cl_uint theRef;
|
||||
retVal = clGetDeviceInfo(testedClDevice, CL_DEVICE_REFERENCE_COUNT,
|
||||
retVal = clGetDeviceInfo(devices[rootDeviceIndex], CL_DEVICE_REFERENCE_COUNT,
|
||||
sizeof(cl_uint), &theRef, NULL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(1u, theRef);
|
||||
}
|
||||
|
||||
TEST_F(clRetainReleaseDeviceTests, GivenRootDeviceWhenReleasingThenReferenceCountIsOne) {
|
||||
constexpr cl_uint numEntries = maxRootDeviceCount;
|
||||
cl_device_id devices[maxRootDeviceCount];
|
||||
|
||||
auto retVal = clGetDeviceIDs(pPlatform, CL_DEVICE_TYPE_GPU, numEntries, devices,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseDevice(devices[rootDeviceIndex]);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseDevice(devices[rootDeviceIndex]);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
cl_uint theRef;
|
||||
retVal = clGetDeviceInfo(devices[rootDeviceIndex], CL_DEVICE_REFERENCE_COUNT,
|
||||
sizeof(cl_uint), &theRef, NULL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(1u, theRef);
|
||||
|
Reference in New Issue
Block a user