2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-22 16:28:27 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/per_thread_data.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-06 17:35:59 +08:00
|
|
|
#include <array>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
size_t PerThreadDataHelper::sendPerThreadData(
|
|
|
|
LinearStream &indirectHeap,
|
|
|
|
uint32_t simd,
|
2019-12-17 15:55:09 +08:00
|
|
|
uint32_t grfSize,
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t numChannels,
|
2018-08-06 17:35:59 +08:00
|
|
|
const size_t localWorkSizes[3],
|
2018-08-08 18:49:36 +08:00
|
|
|
const std::array<uint8_t, 3> &workgroupWalkOrder,
|
|
|
|
bool hasKernelOnlyImages) {
|
2017-12-21 07:45:38 +08:00
|
|
|
auto offsetPerThreadData = indirectHeap.getUsed();
|
|
|
|
if (numChannels) {
|
|
|
|
auto localWorkSize = localWorkSizes[0] * localWorkSizes[1] * localWorkSizes[2];
|
2019-12-17 15:55:09 +08:00
|
|
|
auto sizePerThreadDataTotal = getPerThreadDataSizeTotal(simd, grfSize, numChannels, localWorkSize);
|
2017-12-21 07:45:38 +08:00
|
|
|
auto pDest = indirectHeap.getSpace(sizePerThreadDataTotal);
|
|
|
|
|
|
|
|
// Generate local IDs
|
|
|
|
DEBUG_BREAK_IF(numChannels != 3);
|
2018-08-06 17:35:59 +08:00
|
|
|
generateLocalIDs(pDest, static_cast<uint16_t>(simd),
|
|
|
|
std::array<uint16_t, 3>{{static_cast<uint16_t>(localWorkSizes[0]),
|
|
|
|
static_cast<uint16_t>(localWorkSizes[1]),
|
|
|
|
static_cast<uint16_t>(localWorkSizes[2])}},
|
2018-08-08 18:49:36 +08:00
|
|
|
std::array<uint8_t, 3>{{workgroupWalkOrder[0], workgroupWalkOrder[1], workgroupWalkOrder[2]}},
|
2019-12-17 15:55:09 +08:00
|
|
|
hasKernelOnlyImages, grfSize);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
return offsetPerThreadData;
|
|
|
|
}
|
|
|
|
|
2019-12-17 15:55:09 +08:00
|
|
|
uint32_t PerThreadDataHelper::getThreadPayloadSize(const iOpenCL::SPatchThreadPayload &threadPayload, uint32_t simd, uint32_t grfSize) {
|
2020-02-24 20:21:37 +08:00
|
|
|
uint32_t multiplier = static_cast<uint32_t>(getGRFsPerThread(simd, grfSize));
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t threadPayloadSize = 0;
|
2019-12-17 15:55:09 +08:00
|
|
|
threadPayloadSize = getNumLocalIdChannels(threadPayload) * multiplier * grfSize;
|
|
|
|
threadPayloadSize += (threadPayload.HeaderPresent) ? grfSize : 0;
|
|
|
|
threadPayloadSize += (threadPayload.LocalIDFlattenedPresent) ? (grfSize * multiplier) : 0;
|
|
|
|
threadPayloadSize += (threadPayload.UnusedPerThreadConstantPresent) ? grfSize : 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
return threadPayloadSize;
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|