2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2025-02-17 22:23:39 +08:00
|
|
|
* Copyright (C) 2018-2025 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2025-02-17 22:23:39 +08:00
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/registered_method_dispatcher.h"
|
|
|
|
#include "shared/source/helpers/vec.h"
|
|
|
|
#include "shared/source/utilities/stackvec.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
2020-12-22 08:03:25 +08:00
|
|
|
#include "opencl/source/kernel/kernel_objects_for_aux_translation.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <algorithm>
|
|
|
|
#include <memory>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2023-01-04 00:20:12 +08:00
|
|
|
class LinearStream;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class Kernel;
|
2020-11-16 19:08:30 +08:00
|
|
|
class ClDevice;
|
2019-11-10 02:02:25 +08:00
|
|
|
struct TimestampPacketDependencies;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class DispatchInfo {
|
2019-07-09 20:24:33 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2023-01-20 11:04:15 +08:00
|
|
|
using DispatchCommandMethodT = void(LinearStream &commandStream, TimestampPacketDependencies *timestampPacketDependencies, const RootDeviceEnvironment &rootDeviceEnvironment);
|
2023-01-26 11:58:18 +08:00
|
|
|
using EstimateCommandsMethodT = size_t(size_t, const RootDeviceEnvironment &rootDeviceEnvironment, bool);
|
2019-07-09 20:24:33 +08:00
|
|
|
|
2019-06-28 15:37:04 +08:00
|
|
|
DispatchInfo() = default;
|
2021-09-08 05:21:19 +08:00
|
|
|
DispatchInfo(ClDevice *device, Kernel *kernel, uint32_t dim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset)
|
2020-11-16 19:08:30 +08:00
|
|
|
: pClDevice(device), kernel(kernel), dim(dim), gws(gws), elws(elws), offset(offset) {}
|
2021-09-08 05:21:19 +08:00
|
|
|
DispatchInfo(ClDevice *device, Kernel *kernel, uint32_t dim, const Vec3<size_t> &gws, const Vec3<size_t> &elws, const Vec3<size_t> &offset, const Vec3<size_t> &agws, const Vec3<size_t> &lws, const Vec3<size_t> &twgs, const Vec3<size_t> &nwgs, const Vec3<size_t> &swgs)
|
2020-11-16 19:08:30 +08:00
|
|
|
: pClDevice(device), kernel(kernel), dim(dim), gws(gws), elws(elws), offset(offset), agws(agws), lws(lws), twgs(twgs), nwgs(nwgs), swgs(swgs) {}
|
|
|
|
|
|
|
|
ClDevice &getClDevice() const { return *pClDevice; }
|
|
|
|
void setClDevice(ClDevice *device) { pClDevice = device; }
|
2017-12-21 07:45:38 +08:00
|
|
|
bool usesSlm() const;
|
|
|
|
bool usesStatelessPrintfSurface() const;
|
2024-01-23 18:41:31 +08:00
|
|
|
uint32_t getRequiredScratchSize(uint32_t slotId) const;
|
2017-12-21 07:45:38 +08:00
|
|
|
void setKernel(Kernel *kernel) { this->kernel = kernel; }
|
|
|
|
Kernel *getKernel() const { return kernel; }
|
|
|
|
uint32_t getDim() const { return dim; }
|
|
|
|
void setDim(uint32_t dim) { this->dim = dim; }
|
|
|
|
const Vec3<size_t> &getGWS() const { return gws; };
|
|
|
|
void setGWS(const Vec3<size_t> &gws) { this->gws = gws; }
|
|
|
|
const Vec3<size_t> &getEnqueuedWorkgroupSize() const { return elws; };
|
|
|
|
void setEnqueuedWorkgroupSize(const Vec3<size_t> &elws) { this->elws = elws; }
|
|
|
|
const Vec3<size_t> &getOffset() const { return offset; };
|
|
|
|
void setOffsets(const Vec3<size_t> &offset) { this->offset = offset; }
|
|
|
|
const Vec3<size_t> &getActualWorkgroupSize() const { return agws; };
|
|
|
|
void setActualGlobalWorkgroupSize(const Vec3<size_t> &agws) { this->agws = agws; }
|
|
|
|
const Vec3<size_t> &getLocalWorkgroupSize() const { return lws; };
|
|
|
|
void setLWS(const Vec3<size_t> &lws) { this->lws = lws; }
|
|
|
|
const Vec3<size_t> &getTotalNumberOfWorkgroups() const { return twgs; };
|
|
|
|
void setTotalNumberOfWorkgroups(const Vec3<size_t> &twgs) { this->twgs = twgs; }
|
|
|
|
const Vec3<size_t> &getNumberOfWorkgroups() const { return nwgs; };
|
|
|
|
void setNumberOfWorkgroups(const Vec3<size_t> &nwgs) { this->nwgs = nwgs; }
|
|
|
|
const Vec3<size_t> &getStartOfWorkgroups() const { return swgs; };
|
|
|
|
void setStartOfWorkgroups(const Vec3<size_t> &swgs) { this->swgs = swgs; }
|
2019-01-14 22:56:29 +08:00
|
|
|
bool peekCanBePartitioned() const { return canBePartitioned; }
|
|
|
|
void setCanBePartitioned(bool canBePartitioned) { this->canBePartitioned = canBePartitioned; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-08-09 19:40:42 +08:00
|
|
|
RegisteredMethodDispatcher<DispatchCommandMethodT, EstimateCommandsMethodT> dispatchInitCommands{};
|
|
|
|
RegisteredMethodDispatcher<DispatchCommandMethodT, EstimateCommandsMethodT> dispatchEpilogueCommands{};
|
2019-07-09 20:24:33 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2020-11-16 19:08:30 +08:00
|
|
|
ClDevice *pClDevice = nullptr;
|
2019-01-14 22:56:29 +08:00
|
|
|
bool canBePartitioned = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
Kernel *kernel = nullptr;
|
|
|
|
uint32_t dim = 0;
|
|
|
|
|
2023-01-04 23:00:09 +08:00
|
|
|
Vec3<size_t> gws{0, 0, 0}; // global work size
|
|
|
|
Vec3<size_t> elws{0, 0, 0}; // enqueued local work size
|
|
|
|
Vec3<size_t> offset{0, 0, 0}; // global offset
|
|
|
|
Vec3<size_t> agws{0, 0, 0}; // actual global work size
|
|
|
|
Vec3<size_t> lws{0, 0, 0}; // local work size
|
|
|
|
Vec3<size_t> twgs{0, 0, 0}; // total number of work groups
|
|
|
|
Vec3<size_t> nwgs{0, 0, 0}; // number of work groups
|
|
|
|
Vec3<size_t> swgs{0, 0, 0}; // start of work groups
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2025-02-17 22:23:39 +08:00
|
|
|
struct MultiDispatchInfo : NEO::NonCopyableAndNonMovableClass {
|
2023-01-10 01:14:18 +08:00
|
|
|
~MultiDispatchInfo();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-27 19:59:47 +08:00
|
|
|
explicit MultiDispatchInfo(Kernel *mainKernel) : mainKernel(mainKernel) {}
|
2020-09-01 17:39:32 +08:00
|
|
|
explicit MultiDispatchInfo(const BuiltinOpParams &operationParams) : builtinOpParams(operationParams) {}
|
2018-08-16 21:47:25 +08:00
|
|
|
MultiDispatchInfo() = default;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
bool empty() const {
|
|
|
|
return dispatchInfos.size() == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool usesSlm() const {
|
|
|
|
for (const auto &dispatchInfo : dispatchInfos) {
|
|
|
|
if (dispatchInfo.usesSlm()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool usesStatelessPrintfSurface() const {
|
|
|
|
for (const auto &dispatchInfo : dispatchInfos) {
|
|
|
|
if (dispatchInfo.usesStatelessPrintfSurface()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-01-23 18:41:31 +08:00
|
|
|
uint32_t getRequiredScratchSize(uint32_t slotId) const {
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t ret = 0;
|
|
|
|
for (const auto &dispatchInfo : dispatchInfos) {
|
2024-01-23 18:41:31 +08:00
|
|
|
ret = std::max(ret, dispatchInfo.getRequiredScratchSize(slotId));
|
2019-06-28 15:37:04 +08:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-10-15 01:22:01 +08:00
|
|
|
void backupUnifiedMemorySyncRequirement();
|
2019-07-04 18:17:42 +08:00
|
|
|
|
2018-12-17 22:23:35 +08:00
|
|
|
DispatchInfo *begin() {
|
|
|
|
return dispatchInfos.begin();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
const DispatchInfo *begin() const {
|
|
|
|
return dispatchInfos.begin();
|
|
|
|
}
|
|
|
|
|
2018-12-17 22:23:35 +08:00
|
|
|
std::reverse_iterator<DispatchInfo *> rbegin() {
|
|
|
|
return dispatchInfos.rbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::reverse_iterator<const DispatchInfo *> crbegin() const {
|
|
|
|
return dispatchInfos.crbegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
DispatchInfo *end() {
|
|
|
|
return dispatchInfos.end();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
const DispatchInfo *end() const {
|
|
|
|
return dispatchInfos.end();
|
|
|
|
}
|
|
|
|
|
2018-12-17 22:23:35 +08:00
|
|
|
std::reverse_iterator<DispatchInfo *> rend() {
|
|
|
|
return dispatchInfos.rend();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::reverse_iterator<const DispatchInfo *> crend() const {
|
|
|
|
return dispatchInfos.crend();
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void push(const DispatchInfo &dispatchInfo) {
|
|
|
|
dispatchInfos.push_back(dispatchInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() const {
|
|
|
|
return dispatchInfos.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
StackVec<MemObj *, 2> &getRedescribedSurfaces() {
|
|
|
|
return redescribedSurfaces;
|
|
|
|
}
|
|
|
|
|
2023-01-10 01:14:18 +08:00
|
|
|
void pushRedescribedMemObj(std::unique_ptr<MemObj> memObj);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-16 21:47:25 +08:00
|
|
|
Kernel *peekMainKernel() const;
|
|
|
|
|
2019-10-24 14:08:44 +08:00
|
|
|
void setBuiltinOpParams(const BuiltinOpParams &builtinOpParams) {
|
2019-07-03 15:55:38 +08:00
|
|
|
this->builtinOpParams = builtinOpParams;
|
|
|
|
}
|
|
|
|
|
2019-07-03 15:30:30 +08:00
|
|
|
const BuiltinOpParams &peekBuiltinOpParams() const {
|
2019-07-03 15:55:38 +08:00
|
|
|
return builtinOpParams;
|
|
|
|
}
|
|
|
|
|
2022-04-06 00:47:19 +08:00
|
|
|
void setKernelObjsForAuxTranslation(std::unique_ptr<KernelObjsForAuxTranslation> &&kernelObjsForAuxTranslation) {
|
|
|
|
this->kernelObjsForAuxTranslation = std::move(kernelObjsForAuxTranslation);
|
2019-10-31 16:10:30 +08:00
|
|
|
}
|
|
|
|
|
2020-12-22 08:03:25 +08:00
|
|
|
const KernelObjsForAuxTranslation *getKernelObjsForAuxTranslation() const {
|
2022-04-06 00:47:19 +08:00
|
|
|
return kernelObjsForAuxTranslation.get();
|
2019-10-31 16:10:30 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2019-07-03 15:30:30 +08:00
|
|
|
BuiltinOpParams builtinOpParams = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
StackVec<DispatchInfo, 9> dispatchInfos;
|
|
|
|
StackVec<MemObj *, 2> redescribedSurfaces;
|
2022-04-06 00:47:19 +08:00
|
|
|
std::unique_ptr<const KernelObjsForAuxTranslation> kernelObjsForAuxTranslation;
|
2018-08-16 21:47:25 +08:00
|
|
|
Kernel *mainKernel = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2025-02-17 22:23:39 +08:00
|
|
|
|
|
|
|
static_assert(NEO::NonCopyableAndNonMovable<MultiDispatchInfo>);
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|