2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-02-27 11:39:32 +01:00
|
|
|
* Copyright (C) 2018-2019 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
|
|
|
|
|
#include "runtime/built_ins/built_ins.h"
|
|
|
|
|
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
|
|
|
|
#include "runtime/helpers/dispatch_info_builder.h"
|
2019-07-09 14:24:33 +02:00
|
|
|
#include "runtime/helpers/hw_helper.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:
|
|
|
|
|
BuiltInOp(BuiltIns &kernelsLib, Context &context, 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;
|
|
|
|
|
size_t numMemObjectsToTranslate = operationParams.memObjsForAuxTranslation->size();
|
|
|
|
|
resizeKernelInstances(numMemObjectsToTranslate);
|
|
|
|
|
multiDispatchInfo.setBuiltinOpParams(operationParams);
|
|
|
|
|
|
|
|
|
|
for (auto &memObj : *operationParams.memObjsForAuxTranslation) {
|
|
|
|
|
DispatchInfoBuilder<SplitDispatch::Dim::d1D, SplitDispatch::SplitMode::NoSplit> builder;
|
|
|
|
|
auto graphicsAllocation = memObj->getGraphicsAllocation();
|
|
|
|
|
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());
|
|
|
|
|
builder.setArg(0, memObj);
|
|
|
|
|
builder.setArgSvm(1, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
|
|
|
|
|
} else {
|
|
|
|
|
UNRECOVERABLE_IF(AuxTranslationDirection::NonAuxToAux != operationParams.auxTranslationDirection);
|
|
|
|
|
builder.setKernel(convertToAuxKernel[kernelInstanceNumber++].get());
|
|
|
|
|
builder.setArgSvm(0, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
|
|
|
|
|
builder.setArg(1, memObj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-07-15 11:19:43 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
static void dispatchPipeControlWithDcFlush(LinearStream &linearStream) {
|
|
|
|
|
PipeControlHelper<GfxFamily>::addPipeControl(linearStream, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
static void dispatchPipeControlWithoutDcFlush(LinearStream &linearStream) {
|
|
|
|
|
PipeControlHelper<GfxFamily>::addPipeControl(linearStream, false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 14:24:33 +02:00
|
|
|
template <typename GfxFamily>
|
|
|
|
|
void registerPipeControlProgramming(RegisteredMethodDispatcher<DispatchInfo::DispatchCommandMethodT> &dispatcher, bool dcFlush) const {
|
2019-07-15 11:19:43 +02:00
|
|
|
if (dcFlush) {
|
|
|
|
|
dispatcher.registerMethod(this->dispatchPipeControlWithDcFlush<GfxFamily>);
|
|
|
|
|
} else {
|
|
|
|
|
dispatcher.registerMethod(this->dispatchPipeControlWithoutDcFlush<GfxFamily>);
|
|
|
|
|
}
|
2019-07-09 14:24:33 +02:00
|
|
|
dispatcher.registerCommandsSizeEstimationMethod(PipeControlHelper<GfxFamily>::getSizeForSinglePipeControl);
|
|
|
|
|
}
|
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
|