Code cleanup - constexpr for bitness ults

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2021-05-24 13:49:09 +00:00
committed by Compute-Runtime-Automation
parent 72a0621dc2
commit 7fdab76d96
19 changed files with 42 additions and 48 deletions

View File

@@ -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) {

View File

@@ -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) \

View File

@@ -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;