2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-02-17 12:45:24 +01:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-07 09:22:55 +02:00
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/built_ins/built_ins.h"
|
|
|
|
|
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
|
|
|
|
#include "opencl/source/helpers/dispatch_info_builder.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2018-08-07 09:22:55 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-07-09 20:46:14 +02:00
|
|
|
template <>
|
|
|
|
|
class BuiltInOp<EBuiltInOps::AuxTranslation> : public BuiltinDispatchInfoBuilder {
|
2018-08-07 09:22:55 +02:00
|
|
|
public:
|
2020-02-20 08:12:44 +01:00
|
|
|
BuiltInOp(BuiltIns &kernelsLib, Device &device);
|
2019-07-09 14:24:33 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
bool buildDispatchInfosForAuxTranslation(MultiDispatchInfo &multiDispatchInfo, const BuiltinOpParams &operationParams) const {
|
|
|
|
|
size_t kernelInstanceNumber = 0;
|
2019-10-31 09:10:30 +01:00
|
|
|
size_t numMemObjectsToTranslate = multiDispatchInfo.getMemObjsForAuxTranslation()->size();
|
2019-07-09 14:24:33 +02:00
|
|
|
resizeKernelInstances(numMemObjectsToTranslate);
|
|
|
|
|
multiDispatchInfo.setBuiltinOpParams(operationParams);
|
|
|
|
|
|
2019-10-31 09:10:30 +01:00
|
|
|
for (auto &memObj : *multiDispatchInfo.getMemObjsForAuxTranslation()) {
|
2019-07-09 14:24:33 +02:00
|
|
|
DispatchInfoBuilder<SplitDispatch::Dim::d1D, SplitDispatch::SplitMode::NoSplit> builder;
|
|
|
|
|
size_t allocationSize = alignUp(memObj->getSize(), 512);
|
|
|
|
|
|
|
|
|
|
UNRECOVERABLE_IF(builder.getMaxNumDispatches() != 1);
|
|
|
|
|
|
|
|
|
|
if (kernelInstanceNumber == 0) {
|
|
|
|
|
// Before Kernel
|
2019-08-13 09:05:47 +02:00
|
|
|
registerPipeControlProgramming<GfxFamily>(builder.getDispatchInfo(0).dispatchInitCommands, true);
|
2019-07-09 14:24:33 +02:00
|
|
|
}
|
|
|
|
|
if (kernelInstanceNumber == numMemObjectsToTranslate - 1) {
|
|
|
|
|
// After Kernel
|
|
|
|
|
registerPipeControlProgramming<GfxFamily>(builder.getDispatchInfo(0).dispatchEpilogueCommands, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (AuxTranslationDirection::AuxToNonAux == operationParams.auxTranslationDirection) {
|
|
|
|
|
builder.setKernel(convertToNonAuxKernel[kernelInstanceNumber++].get());
|
|
|
|
|
} else {
|
|
|
|
|
UNRECOVERABLE_IF(AuxTranslationDirection::NonAuxToAux != operationParams.auxTranslationDirection);
|
|
|
|
|
builder.setKernel(convertToAuxKernel[kernelInstanceNumber++].get());
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 11:07:47 +02:00
|
|
|
builder.setArg(0, memObj);
|
|
|
|
|
builder.setArg(1, memObj);
|
|
|
|
|
|
2019-07-09 14:24:33 +02:00
|
|
|
size_t xGws = allocationSize / 16;
|
|
|
|
|
|
|
|
|
|
builder.setDispatchGeometry(Vec3<size_t>{xGws, 0, 0}, Vec3<size_t>{0, 0, 0}, Vec3<size_t>{0, 0, 0});
|
|
|
|
|
builder.bake(multiDispatchInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-08-07 09:22:55 +02:00
|
|
|
|
|
|
|
|
protected:
|
2019-11-13 10:12:44 +01:00
|
|
|
using RegisteredMethodDispatcherT = RegisteredMethodDispatcher<DispatchInfo::DispatchCommandMethodT,
|
|
|
|
|
DispatchInfo::EstimateCommandsMethodT>;
|
|
|
|
|
template <typename GfxFamily, bool dcFlush>
|
2019-11-09 19:02:25 +01:00
|
|
|
static void dispatchPipeControl(LinearStream &linearStream, TimestampPacketDependencies *) {
|
2020-02-17 12:45:24 +01:00
|
|
|
MemorySynchronizationCommands<GfxFamily>::addPipeControl(linearStream, dcFlush);
|
2019-07-15 11:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-09 19:02:25 +01:00
|
|
|
template <typename GfxFamily>
|
2020-02-20 16:09:41 +01:00
|
|
|
static size_t getSizeForSinglePipeControl(size_t) {
|
2020-02-17 12:45:24 +01:00
|
|
|
return MemorySynchronizationCommands<GfxFamily>::getSizeForSinglePipeControl();
|
2019-11-09 19:02:25 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-09 14:24:33 +02:00
|
|
|
template <typename GfxFamily>
|
2019-11-13 10:12:44 +01:00
|
|
|
void registerPipeControlProgramming(RegisteredMethodDispatcherT &dispatcher, bool dcFlush) const {
|
2019-07-15 11:19:43 +02:00
|
|
|
if (dcFlush) {
|
2019-11-13 10:12:44 +01:00
|
|
|
dispatcher.registerMethod(this->dispatchPipeControl<GfxFamily, true>);
|
2019-07-15 11:19:43 +02:00
|
|
|
} else {
|
2019-11-13 10:12:44 +01:00
|
|
|
dispatcher.registerMethod(this->dispatchPipeControl<GfxFamily, false>);
|
2019-07-15 11:19:43 +02:00
|
|
|
}
|
2019-11-09 19:02:25 +01:00
|
|
|
dispatcher.registerCommandsSizeEstimationMethod(this->getSizeForSinglePipeControl<GfxFamily>);
|
2019-07-09 14:24:33 +02:00
|
|
|
}
|
2019-07-15 11:19:43 +02:00
|
|
|
|
2018-08-07 09:22:55 +02:00
|
|
|
void resizeKernelInstances(size_t size) const;
|
|
|
|
|
Kernel *baseKernel = nullptr;
|
|
|
|
|
mutable std::vector<std::unique_ptr<Kernel>> convertToNonAuxKernel;
|
|
|
|
|
mutable std::vector<std::unique_ptr<Kernel>> convertToAuxKernel;
|
|
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|