refactor: improve constexpr array usage

Gcc with o2 flag will allocate constexpr array on stack.
Static constexpr std::array will be initialized at compile time.

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2024-01-15 15:49:28 +00:00
committed by Compute-Runtime-Automation
parent dfc69c746a
commit ef8921247c
5 changed files with 19 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -558,10 +558,10 @@ TEST_F(KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectSta
pKernelInfo->kernelDescriptor.kernelAttributes.hasIndirectStatelessAccess = true;
constexpr std::array<AllocationTypeHelper, 4> allocationTypes = {{{AllocationType::buffer, false},
{AllocationType::buffer, true},
{AllocationType::bufferHostMemory, false},
{AllocationType::svmGpu, true}}};
static constexpr std::array<AllocationTypeHelper, 4> allocationTypes = {{{AllocationType::buffer, false},
{AllocationType::buffer, true},
{AllocationType::bufferHostMemory, false},
{AllocationType::svmGpu, true}}};
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
@@ -600,10 +600,10 @@ TEST_F(KernelArgBufferTest, givenSVMAllocsManagerWithCompressedSVMAllocationsWhe
DebugManagerStateRestore debugRestorer;
debugManager.flags.EnableStatelessCompression.set(1);
constexpr std::array<AllocationTypeHelper, 4> allocationTypes = {{{AllocationType::buffer, false},
{AllocationType::buffer, true},
{AllocationType::bufferHostMemory, false},
{AllocationType::svmGpu, true}}};
static constexpr std::array<AllocationTypeHelper, 4> allocationTypes = {{{AllocationType::buffer, false},
{AllocationType::buffer, true},
{AllocationType::bufferHostMemory, false},
{AllocationType::svmGpu, true}}};
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -753,7 +753,7 @@ TEST(OclocApiTests, GivenCommandWithoutArgsWhenOclocIsInvokedThenHelpIsPrinted)
}
TEST(OclocApiTests, GivenHelpArgumentWhenOclocIsInvokedThenHelpIsPrinted) {
constexpr std::array flagsToTest = {"-h", "--help"};
static constexpr std::array flagsToTest = {"-h", "--help"};
for (const auto helpFlag : flagsToTest) {
const char *argv[] = {
"ocloc",

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Intel Corporation
* Copyright (C) 2022-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -115,7 +115,7 @@ TEST_F(OclocIgcFacadeTest, GivenFailingCreationOfIgcDeviceContextWhenPreparingIg
}
TEST_F(OclocIgcFacadeTest, GivenInvalidIgcDeviceContextWhenPreparingIgcThenFailureIsReported) {
constexpr std::array invalidReturnFlags = {
static constexpr std::array invalidReturnFlags = {
&MockOclocIgcFacade::shouldReturnInvalidIgcPlatformHandle,
&MockOclocIgcFacade::shouldReturnInvalidGTSystemInfoHandle,
&MockOclocIgcFacade::shouldReturnInvalidIgcFeaturesAndWorkaroundsHandle};