mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
change ARRAY_COUNT macro to constexpr
Change-Id: I027c4e70e3b901f3ffb3c0971935ae67e971db07
This commit is contained in:

committed by
sys_ocldev

parent
d51c7ccdd4
commit
d3d8b6f905
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -38,6 +38,6 @@ static const HardwareInfo *DefaultPlatformDevices[] =
|
||||
&DEFAULT_PLATFORM::hwInfo,
|
||||
};
|
||||
|
||||
size_t numPlatformDevices = ARRAY_COUNT(DefaultPlatformDevices);
|
||||
size_t numPlatformDevices = arrayCount(DefaultPlatformDevices);
|
||||
const HardwareInfo **platformDevices = DefaultPlatformDevices;
|
||||
} // namespace OCLRT
|
||||
|
@ -270,7 +270,7 @@ GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {
|
||||
|
||||
IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType,
|
||||
size_t minRequiredSize) {
|
||||
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= ARRAY_COUNT(indirectHeap));
|
||||
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= arrayCount(indirectHeap));
|
||||
auto &heap = indirectHeap[heapType];
|
||||
GraphicsAllocation *heapMemory = nullptr;
|
||||
|
||||
@ -332,7 +332,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::releaseIndirectHeap(IndirectHeap::Type heapType) {
|
||||
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= ARRAY_COUNT(indirectHeap));
|
||||
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= arrayCount(indirectHeap));
|
||||
auto &heap = indirectHeap[heapType];
|
||||
|
||||
if (heap) {
|
||||
|
@ -36,6 +36,6 @@ static const HardwareInfo *DefaultPlatformDevices[] = {
|
||||
&DEFAULT_PLATFORM::hwInfo,
|
||||
};
|
||||
|
||||
size_t numPlatformDevices = ARRAY_COUNT(DefaultPlatformDevices);
|
||||
size_t numPlatformDevices = arrayCount(DefaultPlatformDevices);
|
||||
const HardwareInfo **platformDevices = DefaultPlatformDevices;
|
||||
} // namespace OCLRT
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -24,8 +24,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ARRAY_COUNT(x) static_cast<unsigned int>(sizeof(x) / sizeof(x[0]))
|
||||
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t arrayCount(const T (&)[N]) {
|
||||
return N;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -36,6 +36,6 @@ uint32_t initialHardwareTag = (uint32_t)-1;
|
||||
static const HardwareInfo *DefaultPlatformDevices[] = {
|
||||
&DEFAULT_PLATFORM::hwInfo};
|
||||
|
||||
size_t numPlatformDevices = ARRAY_COUNT(DefaultPlatformDevices);
|
||||
size_t numPlatformDevices = arrayCount(DefaultPlatformDevices);
|
||||
const HardwareInfo **platformDevices = DefaultPlatformDevices;
|
||||
} // namespace OCLRT
|
||||
|
@ -193,8 +193,8 @@ const SurfaceFormatInfo planarYuvSurfaceFormats[] = {
|
||||
{{CL_NV12_INTEL, CL_UNORM_INT8}, GMM_FORMAT_NV12, GFX3DSTATE_SURFACEFORMAT_NV12 , 0, 1, 1, 1}
|
||||
};
|
||||
|
||||
const size_t numPackedYuvSurfaceFormats = ARRAY_COUNT(packedYuvSurfaceFormats);
|
||||
const size_t numPlanarYuvSurfaceFormats = ARRAY_COUNT(planarYuvSurfaceFormats);
|
||||
const size_t numPackedYuvSurfaceFormats = arrayCount(packedYuvSurfaceFormats);
|
||||
const size_t numPlanarYuvSurfaceFormats = arrayCount(planarYuvSurfaceFormats);
|
||||
#endif
|
||||
|
||||
const SurfaceFormatInfo readOnlyDepthSurfaceFormats[] = {
|
||||
@ -209,13 +209,13 @@ const SurfaceFormatInfo readWriteDepthSurfaceFormats[] = {
|
||||
{{ CL_DEPTH, CL_UNORM_INT16}, GMM_FORMAT_R16_UNORM_TYPE, GFX3DSTATE_SURFACEFORMAT_R16_UNORM , 0, 1, 2, 2}
|
||||
};
|
||||
|
||||
const size_t numReadOnlyDepthSurfaceFormats = ARRAY_COUNT(readOnlyDepthSurfaceFormats);
|
||||
const size_t numReadWriteDepthSurfaceFormats = ARRAY_COUNT(readWriteDepthSurfaceFormats);
|
||||
const size_t numReadOnlyDepthSurfaceFormats = arrayCount(readOnlyDepthSurfaceFormats);
|
||||
const size_t numReadWriteDepthSurfaceFormats = arrayCount(readWriteDepthSurfaceFormats);
|
||||
|
||||
|
||||
const size_t numReadOnlySurfaceFormats = ARRAY_COUNT(readOnlySurfaceFormats);
|
||||
const size_t numWriteOnlySurfaceFormats = ARRAY_COUNT(writeOnlySurfaceFormats);
|
||||
const size_t numReadWriteSurfaceFormats = ARRAY_COUNT(readWriteSurfaceFormats);
|
||||
const size_t numReadOnlySurfaceFormats = arrayCount(readOnlySurfaceFormats);
|
||||
const size_t numWriteOnlySurfaceFormats = arrayCount(writeOnlySurfaceFormats);
|
||||
const size_t numReadWriteSurfaceFormats = arrayCount(readWriteSurfaceFormats);
|
||||
|
||||
// clang-format on
|
||||
} // namespace OCLRT
|
||||
|
@ -32,7 +32,7 @@ using namespace OCLRT;
|
||||
TEST(ContextMultiDevice, singleDevice) {
|
||||
cl_device_id devices[] = {
|
||||
MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)};
|
||||
auto numDevices = ARRAY_COUNT(devices);
|
||||
auto numDevices = static_cast<cl_uint>(arrayCount(devices));
|
||||
|
||||
auto retVal = CL_SUCCESS;
|
||||
auto pContext = Context::create<Context>(nullptr, DeviceVector(devices, numDevices),
|
||||
@ -68,7 +68,7 @@ TEST(ContextMultiDevice, eightDevices) {
|
||||
MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr),
|
||||
MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr),
|
||||
MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)};
|
||||
auto numDevices = ARRAY_COUNT(devices);
|
||||
auto numDevices = static_cast<cl_uint>(arrayCount(devices));
|
||||
ASSERT_EQ(8u, numDevices);
|
||||
|
||||
auto retVal = CL_SUCCESS;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -29,10 +29,10 @@ using namespace OCLRT;
|
||||
|
||||
const cl_mem_flags flagsForTests[] = {CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY, CL_MEM_READ_WRITE};
|
||||
|
||||
const std::tuple<const SurfaceFormatInfo *, const size_t> paramsForSnormTests[] = {
|
||||
std::make_tuple(readOnlySurfaceFormats, numReadOnlySurfaceFormats),
|
||||
std::make_tuple(writeOnlySurfaceFormats, numWriteOnlySurfaceFormats),
|
||||
std::make_tuple(readWriteSurfaceFormats, numReadWriteSurfaceFormats),
|
||||
const std::tuple<const SurfaceFormatInfo *, const size_t *> paramsForSnormTests[] = {
|
||||
std::make_tuple(readOnlySurfaceFormats, &numReadOnlySurfaceFormats),
|
||||
std::make_tuple(writeOnlySurfaceFormats, &numWriteOnlySurfaceFormats),
|
||||
std::make_tuple(readWriteSurfaceFormats, &numReadWriteSurfaceFormats),
|
||||
};
|
||||
|
||||
const std::array<SurfaceFormatInfo, 6> referenceSnormSurfaceFormats = {{
|
||||
@ -60,11 +60,11 @@ TEST_P(SnormSurfaceFormatAccessFlagsTests, givenSnormFormatWhenGetSurfaceFormatF
|
||||
}
|
||||
}
|
||||
|
||||
using SnormSurfaceFormatTests = ::testing::TestWithParam<std::tuple<const SurfaceFormatInfo *, const size_t>>;
|
||||
using SnormSurfaceFormatTests = ::testing::TestWithParam<std::tuple<const SurfaceFormatInfo *, const size_t *>>;
|
||||
|
||||
TEST_P(SnormSurfaceFormatTests, givenSnormOclFormatWhenCheckingrReadOnlySurfaceFormatsThenFindExactCount) {
|
||||
const SurfaceFormatInfo *formatsTable = std::get<0>(GetParam());
|
||||
size_t formatsTableCount = std::get<1>(GetParam());
|
||||
size_t formatsTableCount = *std::get<1>(GetParam());
|
||||
|
||||
size_t snormFormatsFound = 0;
|
||||
for (size_t i = 0; i < formatsTableCount; i++) {
|
||||
|
@ -809,7 +809,7 @@ TEST_P(ValidParentImageFormatTest, givenParentChannelOrderWhenTestWithAllChannel
|
||||
image.imageFormat = parentImageFormat;
|
||||
|
||||
bool retVal;
|
||||
for (unsigned int i = 0; i < ARRAY_COUNT(allChannelOrders); i++) {
|
||||
for (unsigned int i = 0; i < arrayCount(allChannelOrders); i++) {
|
||||
imageFormat.image_channel_order = allChannelOrders[i];
|
||||
retVal = image.hasValidParentImageFormat(imageFormat);
|
||||
EXPECT_EQ(imageFormat.image_channel_order == validChannelOrder, retVal);
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
extern Environment *gEnvironment;
|
||||
|
||||
namespace OCLRT {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -34,6 +34,6 @@ static const HardwareInfo *DefaultPlatformDevices[] = {
|
||||
&DEFAULT_TEST_PLATFORM::hwInfo,
|
||||
};
|
||||
|
||||
size_t numPlatformDevices = ARRAY_COUNT(DefaultPlatformDevices);
|
||||
size_t numPlatformDevices = arrayCount(DefaultPlatformDevices);
|
||||
const HardwareInfo **platformDevices = DefaultPlatformDevices;
|
||||
} // namespace OCLRT
|
||||
|
Reference in New Issue
Block a user