Rename platformDevices -> defaultHwInfo [1/n]

create new variable defaultHwInfo as a std::unqiue_ptr<HardwareInfo>
replace platformDevices with defaultHwInfo in opencl/test/unit_test/api

Related-To: NEO-4499

Change-Id: I75b924e5b8a3a18f4ff9fdc3e598192569e102f7
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-03-23 10:23:43 +01:00
committed by sys_ocldev
parent 7bd910c94b
commit 6082cb3aeb
20 changed files with 80 additions and 87 deletions

View File

@@ -18,7 +18,7 @@ void api_fixture_using_aligned_memory_manager::SetUp() {
retVal = CL_SUCCESS;
retSize = 0;
device = new MockClDevice{MockDevice::createWithNewExecutionEnvironment<MockAlignedMallocManagerDevice>(*platformDevices)};
device = new MockClDevice{MockDevice::createWithNewExecutionEnvironment<MockAlignedMallocManagerDevice>(defaultHwInfo.get())};
cl_device_id deviceId = device;
context = Context::create<MockContext>(nullptr, ClDeviceVector(&deviceId, 1), nullptr, nullptr, retVal);

View File

@@ -68,7 +68,7 @@ TEST_F(clCreateImageTest, GivenNullHostPtrWhenCreatingImageThenImageIsCreatedAnd
}
HWTEST_F(clCreateImageTest, GivenDeviceThatDoesntSupportImagesWhenCreatingTiledImageThenInvalidOperationErrorIsReturned) {
MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0], 0)};
MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get(), 0)};
MockContext mockContext{&mockClDevice};
mockClDevice.sharedDeviceInfo.imageSupport = CL_FALSE;
@@ -97,7 +97,7 @@ HWTEST_F(clCreateImageTest, GivenDeviceThatDoesntSupportImagesWhenCreatingTiledI
}
HWTEST_F(clCreateImageTest, GivenDeviceThatDoesntSupportImagesWhenCreatingNonTiledImageThenCreate) {
MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0], 0)};
MockClDevice mockClDevice{MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get(), 0)};
MockContext mockContext{&mockClDevice};
mockClDevice.sharedDeviceInfo.imageSupport = CL_FALSE;
@@ -312,7 +312,7 @@ TEST_F(clCreateImageTest, GivenNonZeroPitchWhenCreatingImageFromBufferThenImageI
auto buffer = clCreateBuffer(pContext, CL_MEM_READ_WRITE, 4096 * 9, nullptr, nullptr);
auto &helper = HwHelper::get(renderCoreFamily);
HardwareInfo hardwareInfo = *platformDevices[0];
HardwareInfo hardwareInfo = *defaultHwInfo;
imageDesc.mem_object = buffer;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;

View File

@@ -28,7 +28,7 @@ struct clCreateSubDevicesTests : ::testing::Test {
void setup(int numberOfDevices) {
DebugManager.flags.CreateMultipleSubDevices.set(numberOfDevices);
mockDeviceCreateSingleDeviceBackup = (numberOfDevices == 1);
device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
outDevicesCount = numberOfDevices;
}
};

View File

@@ -146,7 +146,7 @@ TEST_F(clEnqueueSVMFreeTests, GivenZeroNumOfSVMPointersAndNullSVMPointersWhenFre
}
TEST_F(clEnqueueSVMFreeTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMFreeThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -126,7 +126,7 @@ TEST_F(clEnqueueSVMMapTests, GivenValidParametersWhenMappingSVMThenSuccessIsRetu
}
TEST_F(clEnqueueSVMMapTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMMapThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -126,7 +126,7 @@ TEST_F(clEnqueueSVMMemFillTests, GivenValidParametersWhenFillingSVMMemoryThenSuc
}
TEST_F(clEnqueueSVMMemFillTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMMemFillThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -159,7 +159,7 @@ TEST_F(clEnqueueSVMMemcpyTests, GivenZeroSizeWhenCopyingSVMMemoryThenSuccessIsRe
}
TEST_F(clEnqueueSVMMemcpyTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMMemcpyThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -309,7 +309,7 @@ TEST_F(clEnqueueSVMMigrateMemTests, GivenSameContextCommandQueueAndEventsWhenMig
}
TEST_F(clEnqueueSVMMigrateMemTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMMigrateMemThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -98,7 +98,7 @@ TEST_F(clEnqueueSVMUnmapTests, GivenValidParametersWhenUnmappingSvmThenSuccessIs
}
TEST_F(clEnqueueSVMUnmapTests, GivenDeviceNotSupportingSvmWhenEnqueuingSVMUnmapThenInvalidOperationErrorIsReturned) {
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -45,7 +45,7 @@ TEST_F(clGetDeviceInfoTests, givenNeoDeviceWhenAskedForSliceCountThenNumberOfSli
paramValue,
&paramRetSize);
EXPECT_EQ(platformDevices[0]->gtSystemInfo.SliceCount, numSlices);
EXPECT_EQ(defaultHwInfo->gtSystemInfo.SliceCount, numSlices);
}
TEST_F(clGetDeviceInfoTests, GivenGpuDeviceWhenGettingDeviceInfoThenDeviceTypeGpuIsReturned) {
@@ -113,7 +113,7 @@ TEST(clGetDeviceFineGrainedTests, givenDebugFlagForFineGrainedOverrideWhenItIsUs
DebugManager.flags.ForceFineGrainedSVMSupport.set(0);
cl_device_svm_capabilities svmCaps;
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
@@ -138,7 +138,7 @@ TEST(clGetDeviceFineGrainedTests, givenDebugFlagForFineGrainedOverrideWhenItIsUs
DebugManager.flags.ForceFineGrainedSVMSupport.set(1);
cl_device_svm_capabilities svmCaps;
auto hwInfo = *platformDevices[0];
auto hwInfo = *defaultHwInfo;
auto pDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));

View File

@@ -53,7 +53,7 @@ TEST_F(clGetSupportedImageFormatsTests, givenInvalidContextWhenGettingSupportIma
}
TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSupportImageFormatsThenCLSuccessReturned) {
HardwareInfo hwInfo = *platformDevices[0];
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.supportsImages = false;
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
cl_device_id clDevice = device.get();
@@ -75,7 +75,7 @@ TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSu
}
TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageAndNullPointerToNumFormatsWhenGettingSupportImageFormatsThenCLSuccessReturned) {
HardwareInfo hwInfo = *platformDevices[0];
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.supportsImages = false;
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
cl_device_id clDevice = device.get();

View File

@@ -21,7 +21,7 @@ TEST_F(clSVMFreeTests, GivenNullPtrWhenFreeingSvmThenNoAction) {
}
TEST_F(clSVMFreeTests, GivenContextWithDeviceNotSupportingSvmWhenFreeingSvmThenNoAction) {
HardwareInfo hwInfo = *platformDevices[0];
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.capabilityTable.ftrSvm = false;
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));

View File

@@ -43,7 +43,7 @@ bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment) {
}
auto currentHwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
if (currentHwInfo->platform.eProductFamily == IGFX_UNKNOWN && currentHwInfo->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE) {
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(platformDevices[0]);
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
}
if (ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
uint32_t numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u;

View File

@@ -47,7 +47,7 @@ typedef Test<DrmTestsFixture> DrmTests;
void initializeTestedDevice() {
for (uint32_t i = 0; deviceDescriptorTable[i].eGtType != GTTYPE::GTTYPE_UNDEFINED; i++) {
if (platformDevices[0]->platform.eProductFamily == deviceDescriptorTable[i].pHwInfo->platform.eProductFamily) {
if (defaultHwInfo->platform.eProductFamily == deviceDescriptorTable[i].pHwInfo->platform.eProductFamily) {
deviceId = deviceDescriptorTable[i].deviceId;
break;
}
@@ -303,7 +303,7 @@ TEST(AllocatorHelper, givenExpectedSizeToReserveWhenGetSizeToReserveCalledThenEx
}
TEST(DrmMemoryManagerCreate, whenCallCreateMemoryManagerThenDrmMemoryManagerIsCreated) {
MockExecutionEnvironment executionEnvironment(*platformDevices);
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto drm = new DrmMockSuccess(*executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
@@ -340,6 +340,9 @@ int main(int argc, char **argv) {
listeners.Append(customEventListener);
}
defaultHwInfo = std::make_unique<HardwareInfo>();
*defaultHwInfo = DEFAULT_TEST_PLATFORM::hwInfo;
initializeTestedDevice();
auto retVal = RUN_ALL_TESTS();

View File

@@ -43,7 +43,7 @@ TEST(GmmHelperTest, whenCreateGmmHelperWithoutOsInterfaceThenPassedFileDescripto
uint32_t expectedFileDescriptor = 0u;
gmmHelper.reset(new GmmHelper(nullptr, platformDevices[0]));
gmmHelper.reset(new GmmHelper(nullptr, defaultHwInfo.get()));
EXPECT_EQ(expectedFileDescriptor, passedInputArgs.FileDescriptor);
}
} // namespace NEO

View File

@@ -65,8 +65,8 @@ bool disabled = false;
using namespace NEO;
TestEnvironment *gEnvironment;
PRODUCT_FAMILY productFamily = IGFX_SKYLAKE;
GFXCORE_FAMILY renderCoreFamily = IGFX_GEN9_CORE;
PRODUCT_FAMILY productFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eProductFamily;
GFXCORE_FAMILY renderCoreFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eRenderCoreFamily;
extern std::string lastTest;
bool generateRandomInput = false;
@@ -155,7 +155,7 @@ void cleanTestHelpers() {
}
std::string getHardwarePrefix() {
std::string s = hardwarePrefix[platformDevices[0]->platform.eProductFamily];
std::string s = hardwarePrefix[defaultHwInfo->platform.eProductFamily];
return s;
}
@@ -200,8 +200,7 @@ int main(int argc, char **argv) {
#endif
::testing::InitGoogleMock(&argc, argv);
HardwareInfo device = DEFAULT_TEST_PLATFORM::hwInfo;
::productFamily = device.platform.eProductFamily;
HardwareInfo hwInfoForTests = DEFAULT_TEST_PLATFORM::hwInfo;
uint32_t euPerSubSlice = 0;
uint32_t sliceCount = 0;
@@ -234,27 +233,28 @@ int main(int argc, char **argv) {
if (::isdigit(argv[i][0])) {
int productValue = atoi(argv[i]);
if (productValue > 0 && productValue < IGFX_MAX_PRODUCT && hardwarePrefix[productValue] != nullptr) {
::productFamily = static_cast<PRODUCT_FAMILY>(productValue);
productFamily = static_cast<PRODUCT_FAMILY>(productValue);
} else {
::productFamily = IGFX_UNKNOWN;
productFamily = IGFX_UNKNOWN;
}
} else {
::productFamily = IGFX_UNKNOWN;
productFamily = IGFX_UNKNOWN;
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (hardwarePrefix[j] == nullptr)
continue;
if (strcmp(hardwarePrefix[j], argv[i]) == 0) {
::productFamily = static_cast<PRODUCT_FAMILY>(j);
productFamily = static_cast<PRODUCT_FAMILY>(j);
break;
}
}
}
if (::productFamily == IGFX_UNKNOWN) {
if (productFamily == IGFX_UNKNOWN) {
std::cout << "unknown or unsupported product family has been set: " << argv[i] << std::endl;
return -1;
} else {
std::cout << "product family: " << hardwarePrefix[::productFamily] << " (" << ::productFamily << ")" << std::endl;
std::cout << "product family: " << hardwarePrefix[productFamily] << " (" << productFamily << ")" << std::endl;
}
hwInfoForTests = *hardwareInfoTable[productFamily];
}
} else if (!strcmp("--slices", argv[i])) {
++i;
@@ -296,28 +296,21 @@ int main(int argc, char **argv) {
}
}
productFamily = hwInfoForTests.platform.eProductFamily;
renderCoreFamily = hwInfoForTests.platform.eRenderCoreFamily;
uint32_t threadsPerEu = hwInfoConfigFactory[productFamily]->threadsPerEu;
PLATFORM platform;
auto hardwareInfo = hardwareInfoTable[productFamily];
if (!hardwareInfo) {
return -1;
}
platform = hardwareInfo->platform;
PLATFORM &platform = hwInfoForTests.platform;
if (revId != -1) {
platform.usRevId = revId;
}
HardwareInfo hwInfo = *hardwareInfo;
uint64_t hwInfoConfig = defaultHardwareInfoConfigTable[productFamily];
setHwInfoValuesFromConfig(hwInfoConfig, hwInfo);
setHwInfoValuesFromConfig(hwInfoConfig, hwInfoForTests);
// set Gt and FeatureTable to initial state
hardwareInfoSetup[productFamily](&hwInfo, setupFeatureTableAndWorkaroundTable, hwInfoConfig);
FeatureTable featureTable = hwInfo.featureTable;
GT_SYSTEM_INFO gtSystemInfo = hwInfo.gtSystemInfo;
WorkaroundTable workaroundTable = hwInfo.workaroundTable;
hardwareInfoSetup[productFamily](&hwInfoForTests, setupFeatureTableAndWorkaroundTable, hwInfoConfig);
GT_SYSTEM_INFO &gtSystemInfo = hwInfoForTests.gtSystemInfo;
// and adjust dynamic values if not secified
sliceCount = sliceCount > 0 ? sliceCount : gtSystemInfo.SliceCount;
@@ -334,17 +327,8 @@ int main(int argc, char **argv) {
gtSystemInfo.IsDynamicallyPopulated = false;
// clang-format on
::productFamily = platform.eProductFamily;
::renderCoreFamily = platform.eRenderCoreFamily;
device.platform = platform;
device.gtSystemInfo = gtSystemInfo;
device.featureTable = featureTable;
device.workaroundTable = workaroundTable;
device.capabilityTable = hardwareInfo->capabilityTable;
binaryNameSuffix.append(familyName[device.platform.eRenderCoreFamily]);
binaryNameSuffix.append(device.capabilityTable.platformType);
binaryNameSuffix.append(familyName[hwInfoForTests.platform.eRenderCoreFamily]);
binaryNameSuffix.append(hwInfoForTests.capabilityTable.platformType);
std::string nBinaryKernelFiles = getRunPath(argv[0]);
nBinaryKernelFiles.append("/");
@@ -375,8 +359,11 @@ int main(int argc, char **argv) {
}
#endif
platformDevices = new const HardwareInfo *[1];
platformDevices[0] = &device;
defaultHwInfo = std::make_unique<HardwareInfo>();
*defaultHwInfo = hwInfoForTests;
platformDevices = new HardwareInfo *[1];
*platformDevices = defaultHwInfo.get();
auto &listeners = ::testing::UnitTest::GetInstance()->listeners();
if (useDefaultListener == false) {
@@ -400,7 +387,7 @@ int main(int argc, char **argv) {
retrieveBinaryKernelFilename(igcDebugVars.fileName, KernelBinaryHelper::BUILT_INS + "_", ".gen");
gEnvironment->setMockFileNames(fclDebugVars.fileName, igcDebugVars.fileName);
gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, device);
gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, hwInfoForTests);
#if defined(__linux__)
//ULTs timeout
@@ -453,8 +440,6 @@ int main(int argc, char **argv) {
retVal = RUN_ALL_TESTS();
cleanTestHelpers();
delete[] platformDevices;
return retVal;
}

View File

@@ -38,7 +38,7 @@ struct MockRootDeviceEnvironment : public RootDeviceEnvironment {
struct MockExecutionEnvironment : ExecutionEnvironment {
~MockExecutionEnvironment() override = default;
MockExecutionEnvironment() : MockExecutionEnvironment(platformDevices[0]) {}
MockExecutionEnvironment() : MockExecutionEnvironment(defaultHwInfo.get()) {}
MockExecutionEnvironment(const HardwareInfo *hwInfo) : MockExecutionEnvironment(hwInfo, true, 1u) {
}
MockExecutionEnvironment(const HardwareInfo *hwInfo, bool useMockAubCenter, uint32_t numRootDevices) {
@@ -51,7 +51,7 @@ struct MockExecutionEnvironment : ExecutionEnvironment {
if (hwInfo) {
rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(hwInfo);
} else {
rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(platformDevices[0]);
rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
}
}