mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Code cleanup - constexpr for bitness ults
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
72a0621dc2
commit
7fdab76d96
@@ -377,7 +377,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
itorCmd = find<MEDIA_VFE_STATE *>(itorfirstBBEnd, cmdList.end());
|
||||
itorCmdForStateBase = find<STATE_BASE_ADDRESS *>(itorWalker, cmdList.end());
|
||||
ASSERT_NE(itorWalker, itorCmd);
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
ASSERT_NE(itorCmdForStateBase, itorCmd);
|
||||
} else {
|
||||
//no SBA not dirty
|
||||
@@ -421,9 +421,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
ASSERT_NE(finalItorToSBA, cmdList.end());
|
||||
auto *finalSba2 = (STATE_BASE_ADDRESS *)*finalItorToSBA;
|
||||
auto GSBaddress = finalSba2->getGeneralStateBaseAddress();
|
||||
if (is32bit) {
|
||||
if constexpr (is32bit) {
|
||||
EXPECT_EQ(0u, GSBaddress);
|
||||
} else if (is64bit) {
|
||||
} else {
|
||||
EXPECT_EQ(graphicsAllocation2->getGpuAddress(), GSBaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll
|
||||
typedef typename PARSE::MEDIA_VFE_STATE MEDIA_VFE_STATE;
|
||||
typedef typename PARSE::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
CommandStreamReceiver *csr = &pDevice->getGpgpuCommandStreamReceiver();
|
||||
auto memoryManager = csr->getMemoryManager();
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
|
||||
@@ -702,7 +702,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
if (sharedDeviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
|
||||
} else {
|
||||
EXPECT_EQ(0u, GSHaddress);
|
||||
@@ -813,7 +813,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNdRangeKer
|
||||
if (sharedDeviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress);
|
||||
} else {
|
||||
EXPECT_EQ(0u, GSHaddress);
|
||||
@@ -883,7 +883,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenForced32BitAllocationsModeSto
|
||||
std::unique_ptr<GraphicsAllocation> allocationReusable = commandStreamReceiver->getInternalAllocationStorage()->obtainReusableAllocation(4096, GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||
|
||||
if (allocationReusable.get() != nullptr) {
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_NE(scratchAllocation, allocationReusable.get());
|
||||
}
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(allocationReusable.release());
|
||||
@@ -891,7 +891,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenForced32BitAllocationsModeSto
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenForced32BitAllocationsModeStore32bitWhenFlushingTaskThenScratchAllocationStoredOnTemporaryAllocationList) {
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.Force32bitAddressing.set(true);
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ TEST_F(DeviceGetCapsTest, givenForce32bitAddressingWhenCapsAreCreatedThenDeviceR
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
const auto &caps = device->getDeviceInfo();
|
||||
const auto &sharedCaps = device->getSharedDeviceInfo();
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(sharedCaps.force32BitAddressess);
|
||||
} else {
|
||||
EXPECT_FALSE(sharedCaps.force32BitAddressess);
|
||||
|
||||
@@ -126,7 +126,7 @@ TEST_F(DeviceTest, WhenDeviceIsCreatedThenOsTimeIsNotNull) {
|
||||
TEST_F(DeviceTest, GivenDebugVariableForcing32BitAllocationsWhenDeviceIsCreatedThenMemoryManagerHasForce32BitFlagSet) {
|
||||
DebugManager.flags.Force32bitAddressing.set(true);
|
||||
auto pDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess);
|
||||
EXPECT_TRUE(pDevice->getMemoryManager()->peekForce32BitAllocations());
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@ BXTTEST_F(BxtDeviceCaps, WhenCheckingProfilingTimerResolutionThenCorrectResoluti
|
||||
BXTTEST_F(BxtDeviceCaps, givenBxtDeviceWhenAskedFor32BitSupportThenCorrectValuesAreReturned) {
|
||||
const auto &sharedCaps = pDevice->getDeviceInfo();
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(memoryManager->peekForce32BitAllocations());
|
||||
EXPECT_TRUE(sharedCaps.force32BitAddressess);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ GLKTEST_F(Gen9DeviceCaps, givenGlkDeviceWhenAskedForDoubleSupportThenTrueIsRetur
|
||||
GLKTEST_F(Gen9DeviceCaps, GlkIs32BitOsAllocatorAvailable) {
|
||||
const auto &caps = pDevice->getDeviceInfo();
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(memoryManager->peekForce32BitAllocations());
|
||||
EXPECT_TRUE(caps.force32BitAddressess);
|
||||
} else {
|
||||
|
||||
@@ -614,7 +614,7 @@ TEST_F(KernelPrivateSurfaceTest, WhenPrivateSurfaceAllocationFailsThenOutOfResou
|
||||
}
|
||||
|
||||
TEST_F(KernelPrivateSurfaceTest, given32BitDeviceWhenKernelIsCreatedThenPrivateSurfaceIs32BitAllocation) {
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
pDevice->getMemoryManager()->setForce32BitAllocations(true);
|
||||
|
||||
auto pKernelInfo = std::make_unique<MockKernelInfo>();
|
||||
|
||||
@@ -559,7 +559,7 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, sizeof(memory), memory, retVal));
|
||||
ASSERT_NE(nullptr, buffer.get());
|
||||
auto taskCountSent = device->getGpgpuCommandStreamReceiver().peekLatestFlushedTaskCount();
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_LT(taskCount, taskCountSent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -96,7 +96,7 @@ TEST_F(ImageFromSubBufferTest, GivenSubBufferWithOffsetGreaterThan4gbWhenCreatin
|
||||
uint64_t offsetExpected = 0;
|
||||
cl_buffer_region region = {0, size / 2};
|
||||
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
offsetExpected = 8 * GB;
|
||||
region = {static_cast<size_t>(offsetExpected), size / 2};
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingWhen
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
|
||||
}
|
||||
alignedFree(host_ptr);
|
||||
|
||||
@@ -313,7 +313,7 @@ TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedType
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(allocation->is32BitAllocation());
|
||||
EXPECT_EQ(MemoryPool::System4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool());
|
||||
} else {
|
||||
@@ -461,7 +461,7 @@ TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMus
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(allocation->is32BitAllocation());
|
||||
} else {
|
||||
EXPECT_FALSE(allocation->is32BitAllocation());
|
||||
|
||||
@@ -568,7 +568,7 @@ HWTEST_F(MemoryAllocatorTest, givenStatefulKernelWithPrintfWhenPrintfSurfaceIsCr
|
||||
|
||||
TEST_F(MemoryAllocatorTest, given32BitDeviceWhenPrintfSurfaceIsCreatedThen32BitAllocationsIsMade) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
DebugManager.flags.Force32bitAddressing.set(true);
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
|
||||
@@ -2816,4 +2816,4 @@ TEST(MemoryManagerTest, givenDuplicateRootDeviceIndicesWhenCreatingMultiGraphics
|
||||
EXPECT_EQ(mockRootDeviceIndex, allocation->getRootDeviceIndex());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ TEST(DrmMemoryManagerTest2, givenDrmMemoryManagerWhengetSystemSharedMemoryIsCall
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, GivenBitnessWhenGettingMaxApplicationAddressThenCorrectValueIsReturned) {
|
||||
uint64_t maxAddr = memoryManager->getMaxApplicationAddress();
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_EQ(maxAddr, MemoryConstants::max64BitAppAddress);
|
||||
} else {
|
||||
EXPECT_EQ(maxAddr, MemoryConstants::max32BitAppAddress);
|
||||
|
||||
@@ -628,7 +628,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitness
|
||||
|
||||
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, true);
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(gpuAllocation->is32BitAllocation());
|
||||
|
||||
uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex(), gpuAllocation->isAllocatedInLocalMemoryPool());
|
||||
@@ -652,7 +652,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndNotRequiredSpecificBit
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
|
||||
EXPECT_FALSE(gpuAllocation->is32BitAllocation());
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
uint64_t base = 0;
|
||||
EXPECT_EQ(base, gpuAllocation->getGpuBaseAddress());
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ TEST_F(ProgramDataTest, GivenDeviceForcing32BitMessagesWhenConstAllocationIsPres
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), constSize));
|
||||
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
|
||||
}
|
||||
}
|
||||
@@ -419,7 +419,7 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa
|
||||
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), globalSize));
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_TRUE(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -2166,7 +2166,7 @@ TEST_F(Program32BitTests, givenDeviceWithForce32BitAddressingOnWhenProgramIsCrea
|
||||
auto internalOptions = program.getInitInternalOptions();
|
||||
std::string s1 = internalOptions;
|
||||
size_t pos = s1.find(NEO::CompilerOptions::arch32bit.data());
|
||||
if (is64bit) {
|
||||
if constexpr (is64bit) {
|
||||
EXPECT_NE(pos, std::string::npos);
|
||||
} else {
|
||||
EXPECT_EQ(pos, std::string::npos);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "shared/test/common/test_macros/test_checks_shared.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
|
||||
@@ -16,10 +15,6 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
bool TestChecks::is64Bit() {
|
||||
return ::is64bit;
|
||||
}
|
||||
|
||||
bool TestChecks::supportsBlitter(const HardwareInfo *pHardwareInfo) {
|
||||
auto engines = HwHelper::get(::renderCoreFamily).getGpgpuEngineInstances(*pHardwareInfo);
|
||||
for (const auto &engine : engines) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/constants.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -15,7 +17,6 @@ class Device;
|
||||
struct HardwareInfo;
|
||||
|
||||
namespace TestChecks {
|
||||
bool is64Bit();
|
||||
bool supportsBlitter(const HardwareInfo *pHardwareInfo);
|
||||
bool supportsImages(const HardwareInfo &hardwareInfo);
|
||||
bool supportsImages(const std::unique_ptr<HardwareInfo> &pHardwareInfo);
|
||||
@@ -26,14 +27,14 @@ bool supportsSvm(const Device *pDevice);
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
#define REQUIRE_32BIT_OR_SKIP() \
|
||||
if (NEO::TestChecks::is64Bit() == true) { \
|
||||
GTEST_SKIP(); \
|
||||
#define REQUIRE_32BIT_OR_SKIP() \
|
||||
if constexpr (::is64bit == true) { \
|
||||
GTEST_SKIP(); \
|
||||
}
|
||||
|
||||
#define REQUIRE_64BIT_OR_SKIP() \
|
||||
if (NEO::TestChecks::is64Bit() == false) { \
|
||||
GTEST_SKIP(); \
|
||||
#define REQUIRE_64BIT_OR_SKIP() \
|
||||
if constexpr (::is64bit == false) { \
|
||||
GTEST_SKIP(); \
|
||||
}
|
||||
|
||||
#define REQUIRE_SVM_OR_SKIP(param) \
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
static const bool is64Bit = (sizeof(void *) == 8);
|
||||
|
||||
template <class T, uint32_t level, uint32_t bits = 9>
|
||||
class MockPageTable : public PageTable<T, level, bits> {
|
||||
public:
|
||||
@@ -105,7 +103,7 @@ class GGTTPageTable : public PDPE {
|
||||
class PageTableFixture {
|
||||
protected:
|
||||
const size_t pageSize = 1 << 12;
|
||||
const uintptr_t refAddr = uintptr_t(1) << (is64Bit ? 46 : 31);
|
||||
const uintptr_t refAddr = uintptr_t(1) << (is64bit ? 46 : 31);
|
||||
MockPhysicalAddressAllocator allocator;
|
||||
uint64_t startAddress = 0x1000;
|
||||
|
||||
@@ -176,11 +174,11 @@ TEST_F(PageTableTests48, WhenAssigningWalkerThenWalkIsExecutedCorrectly) {
|
||||
}
|
||||
|
||||
TEST_F(PageTableTests48, givenReservedPhysicalAddressWhenPageWalkIsCalledThenPageTablesAreFilledWithProperAddresses) {
|
||||
if (is64Bit) {
|
||||
if constexpr (is64bit) {
|
||||
std::unique_ptr<MockPML4> pageTable(std::make_unique<MockPML4>(&allocator));
|
||||
|
||||
int shiftPML4 = is64Bit ? (9 + 9 + 9 + 12) : 0;
|
||||
int shiftPDP = is64Bit ? (9 + 9 + 12) : 0;
|
||||
int shiftPML4 = (9 + 9 + 9 + 12);
|
||||
int shiftPDP = (9 + 9 + 12);
|
||||
|
||||
uintptr_t gpuVa = (uintptr_t(0x1) << (shiftPML4)) | (uintptr_t(0x1) << (shiftPDP)) | (uintptr_t(0x1) << (9 + 12)) | 0x100;
|
||||
|
||||
@@ -208,11 +206,11 @@ TEST_F(PageTableTests48, givenReservedPhysicalAddressWhenPageWalkIsCalledThenPag
|
||||
}
|
||||
|
||||
TEST_F(PageTableTests48, givenBigGpuAddressWhenPageWalkIsCalledThenPageTablesAreFilledWithProperAddresses) {
|
||||
if (is64Bit) {
|
||||
if constexpr (is64bit) {
|
||||
std::unique_ptr<MockPML4> pageTable(std::make_unique<MockPML4>(&allocator));
|
||||
|
||||
int shiftPML4 = is64Bit ? (47) : 0;
|
||||
int shiftPDP = is64Bit ? (9 + 9 + 12) : 0;
|
||||
int shiftPML4 = 47;
|
||||
int shiftPDP = (9 + 9 + 12);
|
||||
|
||||
uintptr_t gpuVa = (uintptr_t(0x1) << (shiftPML4)) | (uintptr_t(0x1) << (shiftPDP)) | (uintptr_t(0x1) << (9 + 12)) | 0x100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user