Use range-based for.

Change-Id: I758f6d5fcbf75baae454dedc9467532bc0b8c9d5
Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
This commit is contained in:
Piotr Fusik
2019-07-29 13:35:55 +02:00
committed by sys_ocldev
parent 2e3f77a3e9
commit dcd8728519
23 changed files with 154 additions and 186 deletions

View File

@ -1635,10 +1635,10 @@ void Kernel::getParentObjectCounts(ObjectCounts &objectCount) {
objectCount.samplerCount = 0;
DEBUG_BREAK_IF(!isParentKernel);
for (size_t i = 0; i < this->kernelArguments.size(); i++) {
if (kernelArguments[i].type == SAMPLER_OBJ) {
for (const auto &arg : this->kernelArguments) {
if (arg.type == SAMPLER_OBJ) {
objectCount.samplerCount++;
} else if (kernelArguments[i].type == IMAGE_OBJ) {
} else if (arg.type == IMAGE_OBJ) {
objectCount.imageCount++;
}
}
@ -1799,9 +1799,9 @@ void Kernel::ReflectionSurfaceHelper::getCurbeParams(std::vector<IGIL_KernelCurb
}
}
for (uint32_t i = 0; i < kernelInfo.patchInfo.dataParameterBuffers.size(); i++) {
if (kernelInfo.patchInfo.dataParameterBuffers[i]->Type == DATA_PARAMETER_KERNEL_ARGUMENT) {
curbeParamsOut.emplace_back(IGIL_KernelCurbeParams{DATA_PARAMETER_KERNEL_ARGUMENT, kernelInfo.patchInfo.dataParameterBuffers[i]->DataSize, kernelInfo.patchInfo.dataParameterBuffers[i]->Offset, kernelInfo.patchInfo.dataParameterBuffers[i]->ArgumentNumber});
for (auto param : kernelInfo.patchInfo.dataParameterBuffers) {
if (param->Type == DATA_PARAMETER_KERNEL_ARGUMENT) {
curbeParamsOut.emplace_back(IGIL_KernelCurbeParams{DATA_PARAMETER_KERNEL_ARGUMENT, param->DataSize, param->Offset, param->ArgumentNumber});
tokenMask |= ((uint64_t)1 << DATA_PARAMETER_KERNEL_ARGUMENT);
}
}
@ -2126,12 +2126,12 @@ void Kernel::patchEventPool(DeviceQueue *devQueue) {
void Kernel::patchBlocksSimdSize() {
BlockKernelManager *blockManager = program->getBlockKernelManager();
for (uint32_t i = 0; i < kernelInfo.childrenKernelsIdOffset.size(); i++) {
for (auto &idOffset : kernelInfo.childrenKernelsIdOffset) {
DEBUG_BREAK_IF(!(kernelInfo.childrenKernelsIdOffset[i].first < static_cast<uint32_t>(blockManager->getCount())));
DEBUG_BREAK_IF(!(idOffset.first < static_cast<uint32_t>(blockManager->getCount())));
const KernelInfo *blockInfo = blockManager->getBlockKernelInfo(kernelInfo.childrenKernelsIdOffset[i].first);
uint32_t *simdSize = reinterpret_cast<uint32_t *>(&crossThreadData[kernelInfo.childrenKernelsIdOffset[i].second]);
const KernelInfo *blockInfo = blockManager->getBlockKernelInfo(idOffset.first);
uint32_t *simdSize = reinterpret_cast<uint32_t *>(&crossThreadData[idOffset.second]);
*simdSize = blockInfo->getMaxSimdSize();
}
}

View File

@ -62,13 +62,11 @@ void Kernel::patchReflectionSurface(DeviceQueue *devQueue, PrintfHandler *printf
printfGpuAddress = printfSurface->getGpuAddress();
}
if (pBlockInfo->kernelArgInfo.size() > 0) {
for (uint32_t i = 0; i < pBlockInfo->kernelArgInfo.size(); i++) {
if (pBlockInfo->kernelArgInfo[i].isDeviceQueue) {
deviceQueueOffset = pBlockInfo->kernelArgInfo[i].kernelArgPatchInfoVector[0].crossthreadOffset;
deviceQueueSize = pBlockInfo->kernelArgInfo[i].kernelArgPatchInfoVector[0].size;
break;
}
for (const auto &arg : pBlockInfo->kernelArgInfo) {
if (arg.isDeviceQueue) {
deviceQueueOffset = arg.kernelArgPatchInfoVector[0].crossthreadOffset;
deviceQueueSize = arg.kernelArgPatchInfoVector[0].size;
break;
}
}

View File

@ -125,8 +125,8 @@ void WddmResidencyController::removeFromTrimCandidateListIfUsed(WddmAllocation *
void WddmResidencyController::checkTrimCandidateCount() {
if (DebugManager.flags.ResidencyDebugEnable.get()) {
uint32_t sum = 0;
for (size_t i = 0; i < trimCandidateList.size(); i++) {
if (trimCandidateList[i] != nullptr) {
for (auto trimCandidate : trimCandidateList) {
if (trimCandidate != nullptr) {
sum++;
}
}

View File

@ -29,11 +29,7 @@ BlockKernelManager::~BlockKernelManager() {
}
void BlockKernelManager::pushPrivateSurface(GraphicsAllocation *allocation, size_t ordinal) {
if (blockPrivateSurfaceArray.size() < blockKernelInfoArray.size()) {
blockPrivateSurfaceArray.resize(blockKernelInfoArray.size());
for (uint32_t i = 0; i < blockPrivateSurfaceArray.size(); i++) {
blockPrivateSurfaceArray[i] = nullptr;
}
blockPrivateSurfaceArray.resize(blockKernelInfoArray.size(), nullptr);
}
DEBUG_BREAK_IF(ordinal >= blockPrivateSurfaceArray.size());

View File

@ -117,8 +117,8 @@ cl_int Program::build(
if (isKernelDebugEnabled()) {
processDebugData();
if (pDevice->getSourceLevelDebugger()) {
for (size_t i = 0; i < kernelInfoArray.size(); i++) {
pDevice->getSourceLevelDebugger()->notifyKernelDebugData(kernelInfoArray[i]);
for (auto kernelInfo : kernelInfoArray) {
pDevice->getSourceLevelDebugger()->notifyKernelDebugData(kernelInfo);
}
}
}

View File

@ -132,8 +132,8 @@ cl_int Program::link(
if (isKernelDebugEnabled()) {
processDebugData();
for (size_t i = 0; i < kernelInfoArray.size(); i++) {
pDevice->getSourceLevelDebugger()->notifyKernelDebugData(kernelInfoArray[i]);
for (auto kernelInfo : kernelInfoArray) {
pDevice->getSourceLevelDebugger()->notifyKernelDebugData(kernelInfo);
}
}
} else {

View File

@ -51,11 +51,11 @@ const KernelInfo *Program::getKernelInfo(size_t ordinal) const {
std::string Program::getKernelNamesString() const {
std::string semiColonDelimitedKernelNameStr;
for (uint32_t i = 0; i < kernelInfoArray.size(); i++) {
semiColonDelimitedKernelNameStr += kernelInfoArray[i]->name;
if ((i + 1) != kernelInfoArray.size()) {
semiColonDelimitedKernelNameStr += ";";
for (auto kernelInfo : kernelInfoArray) {
if (!semiColonDelimitedKernelNameStr.empty()) {
semiColonDelimitedKernelNameStr += ';';
}
semiColonDelimitedKernelNameStr += kernelInfo->name;
}
return semiColonDelimitedKernelNameStr;

View File

@ -158,13 +158,13 @@ TEST_F(clEnqueueMigrateMemObjectsTests, GivenValidFlagsWhenMigratingMemObjsThenS
cl_mem_migration_flags validFlags[] = {0, CL_MIGRATE_MEM_OBJECT_HOST, CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED, CL_MIGRATE_MEM_OBJECT_HOST | CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED};
for (unsigned int i = 0; i < sizeof(validFlags) / sizeof(cl_mem_migration_flags); i++) {
for (auto validFlag : validFlags) {
cl_event eventReturned = nullptr;
auto Result = clEnqueueMigrateMemObjects(
pCommandQueue,
1,
&buffer,
validFlags[i],
validFlag,
0,
nullptr,
&eventReturned);
@ -193,15 +193,15 @@ TEST_F(clEnqueueMigrateMemObjectsTests, GivenInvalidFlagsWhenMigratingMemObjsThe
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer);
cl_mem_migration_flags validFlags[] = {(cl_mem_migration_flags)0xffffffff, CL_MIGRATE_MEM_OBJECT_HOST | (1 << 10), CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED | (1 << 10), (cl_mem_migration_flags)12345};
cl_mem_migration_flags invalidFlags[] = {(cl_mem_migration_flags)0xffffffff, CL_MIGRATE_MEM_OBJECT_HOST | (1 << 10), CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED | (1 << 10), (cl_mem_migration_flags)12345};
for (unsigned int i = 0; i < sizeof(validFlags) / sizeof(cl_mem_migration_flags); i++) {
for (auto invalidFlag : invalidFlags) {
cl_event eventReturned = nullptr;
auto Result = clEnqueueMigrateMemObjects(
pCommandQueue,
1,
&buffer,
validFlags[i],
invalidFlag,
0,
nullptr,
&eventReturned);

View File

@ -104,8 +104,8 @@ TEST_F(IntelTracingMtTest, SafeTracingFromMultipleThreads) {
started = true;
for (size_t i = 0; i < threads.size(); ++i) {
threads[i].join();
for (auto &thread : threads) {
thread.join();
}
status = clDisableTracingINTEL(handle);

View File

@ -383,8 +383,8 @@ HWCMDTEST_P(IGFX_GEN8_CORE, ParentKernelEnqueueTest, givenNonBlockedQueueWhenPar
bool dshAllocationResident = false;
for (uint32_t i = 0; i < mockCSR->madeResidentGfxAllocations.size(); i++) {
if (mockCSR->madeResidentGfxAllocations[i] == pDevQueue->getDshBuffer()) {
for (auto allocation : mockCSR->madeResidentGfxAllocations) {
if (allocation == pDevQueue->getDshBuffer()) {
dshAllocationResident = true;
break;
}

View File

@ -67,8 +67,8 @@ TEST_P(KernelReflectionSurfaceTest, GivenEmptyKernelInfoWhenPassedToGetCurbePara
// 3 params with Binding Table index of type 1024
EXPECT_EQ(3u, curbeParamsForBlock.size());
for (uint32_t i = 0; i < curbeParamsForBlock.size(); i++) {
EXPECT_EQ(1024u, curbeParamsForBlock[i].m_parameterType);
for (const auto &curbeParam : curbeParamsForBlock) {
EXPECT_EQ(1024u, curbeParam.m_parameterType);
}
EXPECT_EQ(0u, firstSSHTokenIndex);
}
@ -202,11 +202,11 @@ HWTEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithSetBindingTableStateAnd
EXPECT_NE(0u, curbeParams.size());
bool foundProperParam = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
if (curbeParams[i].m_parameterType == 1024u) {
EXPECT_EQ(btIndex, curbeParams[i].m_patchOffset);
EXPECT_EQ(8u, curbeParams[i].m_parameterSize);
EXPECT_EQ(0u, curbeParams[i].m_sourceOffset);
for (const auto &curbeParam : curbeParams) {
if (curbeParam.m_parameterType == 1024u) {
EXPECT_EQ(btIndex, curbeParam.m_patchOffset);
EXPECT_EQ(8u, curbeParam.m_parameterSize);
EXPECT_EQ(0u, curbeParam.m_sourceOffset);
foundProperParam = true;
break;
}
@ -254,11 +254,11 @@ HWTEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithBindingTableStateAndIma
EXPECT_EQ(1u, curbeParams.size());
bool foundProperParam = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
if (curbeParams[i].m_parameterType == 1024u) {
EXPECT_EQ(maxBTIndex, curbeParams[i].m_patchOffset);
EXPECT_EQ(8u, curbeParams[i].m_parameterSize);
EXPECT_EQ(0u, curbeParams[i].m_sourceOffset);
for (const auto &curbeParam : curbeParams) {
if (curbeParam.m_parameterType == 1024u) {
EXPECT_EQ(maxBTIndex, curbeParam.m_patchOffset);
EXPECT_EQ(8u, curbeParam.m_parameterSize);
EXPECT_EQ(0u, curbeParam.m_sourceOffset);
foundProperParam = true;
break;
}
@ -347,20 +347,20 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithBufferAndDataParameterBuf
EXPECT_LT(1u, curbeParams.size());
bool kernelArgumentTokenFound = false;
bool kernelArgumentSSHParamFound = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
for (const auto &curbeParam : curbeParams) {
if (iOpenCL::DATA_PARAMETER_KERNEL_ARGUMENT == curbeParams[i].m_parameterType) {
if (iOpenCL::DATA_PARAMETER_KERNEL_ARGUMENT == curbeParam.m_parameterType) {
kernelArgumentTokenFound = true;
EXPECT_EQ(0u, curbeParams[i].m_sourceOffset);
EXPECT_EQ(8u, curbeParams[i].m_parameterSize);
EXPECT_EQ(40u, curbeParams[i].m_patchOffset);
EXPECT_EQ(0u, curbeParam.m_sourceOffset);
EXPECT_EQ(8u, curbeParam.m_parameterSize);
EXPECT_EQ(40u, curbeParam.m_patchOffset);
}
// kernel arg SSH param
if (1024 == curbeParams[i].m_parameterType) {
if (1024 == curbeParam.m_parameterType) {
kernelArgumentSSHParamFound = true;
EXPECT_EQ(0u, curbeParams[i].m_sourceOffset);
EXPECT_EQ(0u, curbeParams[i].m_parameterSize);
EXPECT_EQ(0u, curbeParams[i].m_patchOffset);
EXPECT_EQ(0u, curbeParam.m_sourceOffset);
EXPECT_EQ(0u, curbeParam.m_parameterSize);
EXPECT_EQ(0u, curbeParam.m_patchOffset);
}
}
EXPECT_TRUE(kernelArgumentTokenFound);
@ -387,8 +387,8 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithBufferAndNoDataParameterB
MockKernel::ReflectionSurfaceHelperPublic::getCurbeParams(curbeParams, tokenMask, firstSSHTokenIndex, info, pPlatform->getDevice(0)->getHardwareInfo());
bool kernelArgumentTokenFound = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
if (iOpenCL::DATA_PARAMETER_KERNEL_ARGUMENT == curbeParams[i].m_parameterType) {
for (const auto &curbeParam : curbeParams) {
if (iOpenCL::DATA_PARAMETER_KERNEL_ARGUMENT == curbeParam.m_parameterType) {
kernelArgumentTokenFound = true;
}
}
@ -427,12 +427,12 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithLocalMemoryParameterWhenP
MockKernel::ReflectionSurfaceHelperPublic::getCurbeParams(curbeParams, tokenMask, firstSSHTokenIndex, info, pPlatform->getDevice(0)->getHardwareInfo());
bool localMemoryTokenFound = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
if (iOpenCL::DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES == curbeParams[i].m_parameterType) {
for (const auto &curbeParam : curbeParams) {
if (iOpenCL::DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES == curbeParam.m_parameterType) {
localMemoryTokenFound = true;
EXPECT_EQ(slmAlignment, curbeParams[i].m_sourceOffset);
EXPECT_EQ(0u, curbeParams[i].m_parameterSize);
EXPECT_EQ(crossThreadOffset, curbeParams[i].m_patchOffset);
EXPECT_EQ(slmAlignment, curbeParam.m_sourceOffset);
EXPECT_EQ(0u, curbeParam.m_parameterSize);
EXPECT_EQ(crossThreadOffset, curbeParam.m_patchOffset);
}
}
EXPECT_TRUE(localMemoryTokenFound);
@ -470,8 +470,8 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithoutLocalMemoryParameterWh
MockKernel::ReflectionSurfaceHelperPublic::getCurbeParams(curbeParams, tokenMask, firstSSHTokenIndex, info, pPlatform->getDevice(0)->getHardwareInfo());
bool localMemoryTokenFound = false;
for (size_t i = 0; i < curbeParams.size(); i++) {
if (iOpenCL::DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES == curbeParams[i].m_parameterType) {
for (const auto &curbeParam : curbeParams) {
if (iOpenCL::DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES == curbeParam.m_parameterType) {
localMemoryTokenFound = true;
}
}
@ -545,9 +545,9 @@ TEST_P(KernelReflectionSurfaceTest, getCurbeParamsReturnsVectorWithExpectedParam
if (pBlockInfo->name.find("kernel_reflection_dispatch_0") != std::string::npos) {
EXPECT_LT(1u, curbeParamsForBlock.size());
for (size_t i = 0; i < curbeParamsForBlock.size(); i++) {
for (const auto &curbeParams : curbeParamsForBlock) {
switch (curbeParamsForBlock[i].m_parameterType) {
switch (curbeParams.m_parameterType) {
case bufferType:
bufferFound = true;
break;
@ -932,74 +932,73 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithExecutionParametersWhenPa
EXPECT_LE(supportedExecutionParamTypes.size(), curbeParams.size());
uint32_t foundParams = 0;
for (uint32_t i = 0; i < supportedExecutionParamTypes.size(); i++) {
foundParams = 0;
for (uint32_t j = 0; j < curbeParams.size(); j++) {
if (supportedExecutionParamTypes[i] == curbeParams[j].m_parameterType) {
for (auto paramType : supportedExecutionParamTypes) {
auto foundParams = 0u;
auto j = 0;
for (const auto &curbeParam : curbeParams) {
if (paramType == curbeParam.m_parameterType) {
foundParams++;
uint32_t index = curbeParams[j].m_sourceOffset / sizeof(uint32_t);
uint32_t index = curbeParam.m_sourceOffset / sizeof(uint32_t);
switch (curbeParams[j].m_parameterType) {
switch (paramType) {
case iOpenCL::DATA_PARAMETER_LOCAL_WORK_SIZE:
if (j < 3) {
EXPECT_EQ(lwsOffsets[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(lwsOffsets[index], curbeParam.m_patchOffset);
} else {
EXPECT_EQ(lwsOffsets2[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(lwsOffsets2[index], curbeParam.m_patchOffset);
}
break;
case iOpenCL::DATA_PARAMETER_GLOBAL_WORK_SIZE:
EXPECT_EQ(gwsOffsets[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(gwsOffsets[index], curbeParam.m_patchOffset);
break;
case iOpenCL::DATA_PARAMETER_NUM_WORK_GROUPS:
EXPECT_EQ(numOffsets[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(numOffsets[index], curbeParam.m_patchOffset);
break;
case iOpenCL::DATA_PARAMETER_GLOBAL_WORK_OFFSET:
EXPECT_EQ(globalOffsetOffsets[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(globalOffsetOffsets[index], curbeParam.m_patchOffset);
break;
case iOpenCL::DATA_PARAMETER_ENQUEUED_LOCAL_WORK_SIZE:
EXPECT_EQ(enqueuedLocalWorkSizeOffsets[index], curbeParams[j].m_patchOffset);
EXPECT_EQ(enqueuedLocalWorkSizeOffsets[index], curbeParam.m_patchOffset);
break;
}
}
j++;
}
switch (supportedExecutionParamTypes[i]) {
switch (paramType) {
case iOpenCL::DATA_PARAMETER_LOCAL_WORK_SIZE:
EXPECT_EQ(6u, foundParams) << "Parameter token: " << supportedExecutionParamTypes[i];
EXPECT_EQ(6u, foundParams) << "Parameter token: " << paramType;
break;
case iOpenCL::DATA_PARAMETER_GLOBAL_WORK_SIZE:
case iOpenCL::DATA_PARAMETER_NUM_WORK_GROUPS:
case iOpenCL::DATA_PARAMETER_GLOBAL_WORK_OFFSET:
case iOpenCL::DATA_PARAMETER_ENQUEUED_LOCAL_WORK_SIZE:
EXPECT_EQ(3u, foundParams) << "Parameter token: " << supportedExecutionParamTypes[i];
EXPECT_EQ(3u, foundParams) << "Parameter token: " << paramType;
break;
}
}
for (uint32_t i = 0; i < supportedExecutionParamTypes.size(); i++) {
foundParams = 0;
for (auto paramType : supportedExecutionParamTypes) {
auto foundParams = 0u;
for (uint32_t j = 0; j < curbeParams.size(); j++) {
if (supportedExecutionParamTypes[i] == curbeParams[j].m_parameterType) {
for (const auto &curbeParam : curbeParams) {
if (paramType == curbeParam.m_parameterType) {
switch (curbeParams[j].m_parameterType) {
switch (paramType) {
case iOpenCL::DATA_PARAMETER_PARENT_EVENT:
EXPECT_EQ(parentEventOffset, curbeParams[j].m_patchOffset);
EXPECT_EQ(parentEventOffset, curbeParam.m_patchOffset);
foundParams++;
break;
case iOpenCL::DATA_PARAMETER_WORK_DIMENSIONS:
EXPECT_EQ(workDimOffset, curbeParams[j].m_patchOffset);
EXPECT_EQ(workDimOffset, curbeParam.m_patchOffset);
foundParams++;
break;
}
}
}
switch (supportedExecutionParamTypes[i]) {
switch (paramType) {
case iOpenCL::DATA_PARAMETER_PARENT_EVENT:
case iOpenCL::DATA_PARAMETER_WORK_DIMENSIONS:
EXPECT_EQ(1u, foundParams);
@ -1007,12 +1006,10 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithExecutionParametersWhenPa
}
}
uint64_t expectedTokens = 0;
for (uint32_t i = 0; i < supportedExecutionParamTypes.size(); i++) {
expectedTokens = (uint64_t)1 << supportedExecutionParamTypes[i];
if (supportedExecutionParamTypes[i] != iOpenCL::DATA_PARAMETER_NUM_HARDWARE_THREADS) {
EXPECT_TRUE((tokenMask & expectedTokens) > 0) << "Pramater Token: " << supportedExecutionParamTypes[i];
for (auto paramType : supportedExecutionParamTypes) {
if (paramType != iOpenCL::DATA_PARAMETER_NUM_HARDWARE_THREADS) {
auto expectedTokens = (uint64_t)1 << paramType;
EXPECT_TRUE((tokenMask & expectedTokens) > 0) << "Parameter Token: " << paramType;
}
}
}
@ -1080,19 +1077,17 @@ HWCMDTEST_P(IGFX_GEN8_CORE, KernelReflectionSurfaceWithQueueTest, ObtainKernelRe
}
}
if (pBlockInfo->kernelArgInfo.size() > 0) {
for (uint32_t i = 0; i < pBlockInfo->kernelArgInfo.size(); i++) {
if (pBlockInfo->kernelArgInfo[i].isDeviceQueue) {
for (const auto &arg : pBlockInfo->kernelArgInfo) {
if (arg.isDeviceQueue) {
auto *patchedPointer = ptrOffset(pCurbe, pBlockInfo->kernelArgInfo[i].kernelArgPatchInfoVector[0].crossthreadOffset);
if (pBlockInfo->kernelArgInfo[i].kernelArgPatchInfoVector[0].size == sizeof(uint32_t)) {
uint32_t *patchedValue = static_cast<uint32_t *>(patchedPointer);
uint64_t patchedValue64 = *patchedValue;
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), patchedValue64);
} else if (pBlockInfo->kernelArgInfo[i].kernelArgPatchInfoVector[0].size == sizeof(uint64_t)) {
uint64_t *patchedValue = static_cast<uint64_t *>(patchedPointer);
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), *patchedValue);
}
auto *patchedPointer = ptrOffset(pCurbe, arg.kernelArgPatchInfoVector[0].crossthreadOffset);
if (arg.kernelArgPatchInfoVector[0].size == sizeof(uint32_t)) {
uint32_t *patchedValue = static_cast<uint32_t *>(patchedPointer);
uint64_t patchedValue64 = *patchedValue;
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), patchedValue64);
} else if (arg.kernelArgPatchInfoVector[0].size == sizeof(uint64_t)) {
uint64_t *patchedValue = static_cast<uint64_t *>(patchedPointer);
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), *patchedValue);
}
}
}
@ -1144,9 +1139,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, KernelReflectionSurfaceWithQueueTest, ObtainKernelRe
if (pKernelHeader->m_ParentKernelImageCount > 0) {
uint32_t imageIndex = 0;
for (uint32_t i = 0; i < pKernel->getKernelInfo().kernelArgInfo.size(); i++) {
if (pKernel->getKernelInfo().kernelArgInfo[i].isImage) {
EXPECT_EQ(pKernel->getKernelInfo().kernelArgInfo[i].offsetHeap, pParentImageParams[imageIndex].m_ObjectID);
for (const auto &arg : pKernel->getKernelInfo().kernelArgInfo) {
if (arg.isImage) {
EXPECT_EQ(arg.offsetHeap, pParentImageParams[imageIndex].m_ObjectID);
imageIndex++;
}
}
@ -1154,9 +1149,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, KernelReflectionSurfaceWithQueueTest, ObtainKernelRe
if (pKernelHeader->m_ParentSamplerCount > 0) {
uint32_t samplerIndex = 0;
for (uint32_t i = 0; i < pKernel->getKernelInfo().kernelArgInfo.size(); i++) {
if (pKernel->getKernelInfo().kernelArgInfo[i].isSampler) {
EXPECT_EQ(OCLRT_ARG_OFFSET_TO_SAMPLER_OBJECT_ID(pKernel->getKernelInfo().kernelArgInfo[i].offsetHeap), pParentSamplerParams[samplerIndex].m_ObjectID);
for (const auto &arg : pKernel->getKernelInfo().kernelArgInfo) {
if (arg.isSampler) {
EXPECT_EQ(OCLRT_ARG_OFFSET_TO_SAMPLER_OBJECT_ID(arg.offsetHeap), pParentSamplerParams[samplerIndex].m_ObjectID);
samplerIndex++;
}
}

View File

@ -38,8 +38,7 @@ TEST_P(SnormSurfaceFormatAccessFlagsTests, givenSnormFormatWhenGetSurfaceFormatF
EXPECT_EQ(6u, referenceSnormSurfaceFormats.size());
cl_mem_flags flags = GetParam();
for (size_t i = 0u; i < referenceSnormSurfaceFormats.size(); i++) {
const auto &snormSurfaceFormat = referenceSnormSurfaceFormats[i];
for (const auto &snormSurfaceFormat : referenceSnormSurfaceFormats) {
auto format = Image::getSurfaceFormatFromTable(flags, &snormSurfaceFormat.OCLImageFormat);
EXPECT_NE(nullptr, format);
EXPECT_TRUE(memcmp(&snormSurfaceFormat, format, sizeof(SurfaceFormatInfo)) == 0);
@ -52,8 +51,8 @@ TEST_P(SnormSurfaceFormatTests, givenSnormOclFormatWhenCheckingrReadOnlySurfaceF
ArrayRef<const SurfaceFormatInfo> formatsTable = GetParam();
size_t snormFormatsFound = 0;
for (size_t i = 0; i < formatsTable.size(); ++i) {
auto oclFormat = formatsTable[i].OCLImageFormat;
for (const auto &format : formatsTable) {
auto oclFormat = format.OCLImageFormat;
if (CL_SNORM_INT8 == oclFormat.image_channel_data_type || CL_SNORM_INT16 == oclFormat.image_channel_data_type) {
EXPECT_TRUE(oclFormat.image_channel_order == CL_R || oclFormat.image_channel_order == CL_RG || oclFormat.image_channel_order == CL_RGBA);
snormFormatsFound++;

View File

@ -6,7 +6,6 @@
*/
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/array_count.h"
#include "runtime/helpers/convert_color.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/mem_obj/image.h"
@ -783,10 +782,9 @@ TEST_P(ValidParentImageFormatTest, givenParentChannelOrderWhenTestWithAllChannel
imageFormat.image_channel_data_type = CL_UNORM_INT8;
image.imageFormat = parentImageFormat;
bool retVal;
for (unsigned int i = 0; i < arrayCount(allChannelOrders); i++) {
imageFormat.image_channel_order = allChannelOrders[i];
retVal = image.hasValidParentImageFormat(imageFormat);
for (auto channelOrder : allChannelOrders) {
imageFormat.image_channel_order = channelOrder;
bool retVal = image.hasValidParentImageFormat(imageFormat);
EXPECT_EQ(imageFormat.image_channel_order == validChannelOrder, retVal);
}
};

View File

@ -5,7 +5,6 @@
*
*/
#include "runtime/helpers/array_count.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h"
@ -164,8 +163,8 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen
MemoryPool::System4KBPagesWith32BitGpuAddressing,
MemoryPool::SystemCpuInaccessible};
for (size_t i = 0; i < arrayCount(page4kPools); i++) {
MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 1, page4kPools[i], false);
for (auto pool : page4kPools) {
MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 1, pool, false);
EXPECT_EQ(MemoryConstants::pageSize, graphicsAllocation.getUsedPageSize());
}
@ -174,8 +173,8 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen
MemoryPool::System64KBPagesWith32BitGpuAddressing,
MemoryPool::LocalMemory};
for (size_t i = 0; i < arrayCount(page64kPools); i++) {
MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 1, page64kPools[i], false);
for (auto pool : page64kPools) {
MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 1, pool, false);
EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation.getUsedPageSize());
}

View File

@ -37,8 +37,8 @@ TEST(MemoryManagerTest, givenImageOrSharedResourceCopyWhenGraphicsAllocationInDe
GraphicsAllocation::AllocationType types[] = {GraphicsAllocation::AllocationType::IMAGE,
GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY};
for (uint32_t i = 0; i < arrayCount(types); i++) {
allocData.type = types[i];
for (auto type : types) {
allocData.type = type;
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);

View File

@ -5,30 +5,19 @@
*
*/
#include "runtime/helpers/array_count.h"
#include "runtime/memory_manager/memory_pool.h"
#include "gtest/gtest.h"
TEST(MemoryPool, givenSystemMemoryPoolTypesWhenIsSystemMemoryPoolIsCalledThenTrueIsReturned) {
MemoryPool::Type systemMemoryTypes[] = {MemoryPool::System4KBPages,
MemoryPool::System4KBPagesWith32BitGpuAddressing,
MemoryPool::System64KBPages,
MemoryPool::System64KBPagesWith32BitGpuAddressing};
for (size_t i = 0; i < arrayCount(systemMemoryTypes); i++) {
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(systemMemoryTypes[i]));
}
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System4KBPages));
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System4KBPagesWith32BitGpuAddressing));
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System64KBPages));
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(MemoryPool::System64KBPagesWith32BitGpuAddressing));
}
TEST(MemoryPool, givenNonSystemMemoryPoolTypesWhenIsSystemMemoryPoolIsCalledThenFalseIsReturned) {
MemoryPool::Type memoryTypes[] = {MemoryPool::MemoryNull,
MemoryPool::SystemCpuInaccessible,
MemoryPool::LocalMemory};
for (size_t i = 0; i < arrayCount(memoryTypes); i++) {
EXPECT_FALSE(MemoryPool::isSystemMemoryPool(memoryTypes[i]));
}
EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::MemoryNull));
EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::SystemCpuInaccessible));
EXPECT_FALSE(MemoryPool::isSystemMemoryPool(MemoryPool::LocalMemory));
}

View File

@ -14,7 +14,6 @@
#include "runtime/command_stream/preemption.h"
#include "runtime/event/event.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/array_count.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/mem_obj/image.h"
@ -3065,8 +3064,8 @@ TEST_F(DrmMemoryManagerBasic, givenImageOrSharedResourceCopyWhenGraphicsAllocati
GraphicsAllocation::AllocationType types[] = {GraphicsAllocation::AllocationType::IMAGE,
GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY};
for (uint32_t i = 0; i < arrayCount(types); i++) {
allocData.type = types[i];
for (auto type : types) {
allocData.type = type;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);

View File

@ -235,12 +235,12 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocatio
AllocationProperties propertiesBuffer(false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
AllocationProperties propertiesImage(false, 0, GraphicsAllocation::AllocationType::SHARED_IMAGE, false);
AllocationProperties *properties[2] = {&propertiesBuffer, &propertiesImage};
AllocationProperties *propertiesArray[2] = {&propertiesBuffer, &propertiesImage};
for (uint32_t i = 0; i < arrayCount(properties); i++) {
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, *properties[i], false);
for (auto properties : propertiesArray) {
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, *properties, false);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(properties[i]->allocationType, allocation->getAllocationType());
EXPECT_EQ(properties->allocationType, allocation->getAllocationType());
memoryManager->freeGraphicsMemory(allocation);
}
}

View File

@ -19,8 +19,8 @@ class IcdRestore : public SharingFactory {
IcdRestore() {
icdSnapshot = icdGlobalDispatchTable;
memcpy_s(savedState, sizeof(savedState), sharingContextBuilder, sizeof(sharingContextBuilder));
for (size_t i = 0; i < sizeof(sharingContextBuilder) / sizeof(*sharingContextBuilder); i++) {
sharingContextBuilder[i] = nullptr;
for (auto &builder : sharingContextBuilder) {
builder = nullptr;
}
}
@ -31,7 +31,7 @@ class IcdRestore : public SharingFactory {
template <typename F>
void registerSharing(SharingType type) {
auto object = std::unique_ptr<F>(new F);
auto object = std::make_unique<F>();
sharingContextBuilder[type] = object.get();
sharings.push_back(std::move(object));
}

View File

@ -789,9 +789,9 @@ TEST(glSharingBasicTest, givenCorrectFlagsWhenGettingSupportedFormatsThenCorrect
cl_GLenum glFormats[3] = {};
cl_uint numImageFormats = 0;
for (size_t i = 0; i < arrayCount(flags); i++) {
for (auto flag : flags) {
auto result = glSharingFunctions.getSupportedFormats(flags[i], image_type, arrayCount(glFormats), glFormats, &numImageFormats);
auto result = glSharingFunctions.getSupportedFormats(flag, image_type, arrayCount(glFormats), glFormats, &numImageFormats);
EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats);
@ -809,15 +809,15 @@ TEST(glSharingBasicTest, givenSupportedImageTypesWhenGettingSupportedFormatsThen
cl_GLenum glFormats[3] = {};
cl_uint numImageFormats = 0;
for (size_t i = 0; i < arrayCount(image_types); i++) {
for (auto image_type : image_types) {
auto result = glSharingFunctions.getSupportedFormats(flags, image_types[i], arrayCount(glFormats), glFormats, &numImageFormats);
auto result = glSharingFunctions.getSupportedFormats(flags, image_type, arrayCount(glFormats), glFormats, &numImageFormats);
EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats);
for (uint32_t formatIndex = 0; formatIndex < arrayCount(glFormats); formatIndex++) {
EXPECT_NE(GlSharing::gLToCLFormats.end(), GlSharing::gLToCLFormats.find(glFormats[formatIndex]));
for (auto glFormat : glFormats) {
EXPECT_NE(GlSharing::gLToCLFormats.end(), GlSharing::gLToCLFormats.find(glFormat));
}
}
}

View File

@ -33,14 +33,14 @@ class SharingFactoryStateRestore : public SharingFactory {
}
void clearCurrentState() {
for (size_t i = 0; i < sizeof(sharingContextBuilder) / sizeof(*sharingContextBuilder); i++) {
sharingContextBuilder[i] = nullptr;
for (auto &builder : sharingContextBuilder) {
builder = nullptr;
}
}
template <typename F>
void registerSharing(SharingType type) {
auto object = std::unique_ptr<F>(new F);
auto object = std::make_unique<F>();
sharingContextBuilder[type] = object.get();
sharings.push_back(std::move(object));
}

View File

@ -6,7 +6,6 @@
*/
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/helpers/array_count.h"
#include "runtime/sharings/va/va_sharing_functions.h"
#include "unit_tests/helpers/variable_backup.h"
#include "unit_tests/sharings/va/mock_va_sharing.h"
@ -160,13 +159,9 @@ TEST(VASharingFunctions, givenEnabledExtendedVaFormatsWhenQueryingSupportedForma
EXPECT_EQ(2u, sharingFunctions.supportedFormats.size());
size_t allFormatsFound = 0;
uint32_t fourCCExpected[] = {VA_FOURCC_NV12, VA_FOURCC_P010};
for (size_t i = 0; i < sharingFunctions.supportedFormats.size(); i++) {
for (size_t fourCCIndex = 0; fourCCIndex < arrayCount(fourCCExpected); fourCCIndex++) {
if (sharingFunctions.supportedFormats[0].fourcc == fourCCExpected[fourCCIndex]) {
allFormatsFound++;
}
for (const auto &supportedFormat : sharingFunctions.supportedFormats) {
if (supportedFormat.fourcc == VA_FOURCC_NV12 || supportedFormat.fourcc == VA_FOURCC_P010) {
allFormatsFound++;
}
}
EXPECT_EQ(2u, allFormatsFound);

View File

@ -546,11 +546,11 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat
VAImageFormat supportedFormat = {VA_FOURCC_NV12, VA_LSB_FIRST, 8, 0, 0, 0, 0, 0};
for (size_t i = 0; i < arrayCount(flags); i++) {
for (auto flag : flags) {
cl_int result = clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
&context,
flags[i],
flag,
image_type,
arrayCount(vaApiFormats),
vaApiFormats,