2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2023-01-12 01:04:14 +08:00
|
|
|
* Copyright (C) 2018-2023 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
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/helpers/blit_commands_helper.h"
|
|
|
|
#include "shared/source/helpers/completion_stamp.h"
|
2023-01-12 01:04:14 +08:00
|
|
|
#include "shared/source/helpers/map_operation_type.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
|
|
|
#include "shared/source/indirect_heap/indirect_heap.h"
|
|
|
|
#include "shared/source/utilities/iflist.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/properties_helper.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
class CommandQueue;
|
|
|
|
class CommandStreamReceiver;
|
2018-10-24 20:25:04 +08:00
|
|
|
class InternalAllocationStorage;
|
2017-12-21 07:45:38 +08:00
|
|
|
class Kernel;
|
|
|
|
class MemObj;
|
|
|
|
class Surface;
|
|
|
|
class PrintfHandler;
|
2021-03-25 02:21:13 +08:00
|
|
|
class HwTimeStamps;
|
2018-10-03 05:37:30 +08:00
|
|
|
class TimestampPacketContainer;
|
2018-12-21 20:05:21 +08:00
|
|
|
template <class T>
|
2021-03-25 02:21:13 +08:00
|
|
|
class TagNode;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
struct KernelOperation {
|
2019-07-19 03:15:50 +08:00
|
|
|
protected:
|
|
|
|
struct ResourceCleaner {
|
|
|
|
ResourceCleaner() = delete;
|
|
|
|
ResourceCleaner(InternalAllocationStorage *storageForAllocations) : storageForAllocations(storageForAllocations){};
|
|
|
|
|
|
|
|
template <typename ObjectT>
|
|
|
|
void operator()(ObjectT *object);
|
|
|
|
|
|
|
|
InternalAllocationStorage *storageForAllocations = nullptr;
|
|
|
|
} resourceCleaner{nullptr};
|
|
|
|
|
|
|
|
using LinearStreamUniquePtrT = std::unique_ptr<LinearStream, ResourceCleaner>;
|
|
|
|
using IndirectHeapUniquePtrT = std::unique_ptr<IndirectHeap, ResourceCleaner>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
KernelOperation() = delete;
|
|
|
|
KernelOperation(LinearStream *commandStream, InternalAllocationStorage &storageForAllocations) {
|
|
|
|
resourceCleaner.storageForAllocations = &storageForAllocations;
|
|
|
|
this->commandStream = LinearStreamUniquePtrT(commandStream, resourceCleaner);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setHeaps(IndirectHeap *dsh, IndirectHeap *ioh, IndirectHeap *ssh) {
|
|
|
|
this->dsh = IndirectHeapUniquePtrT(dsh, resourceCleaner);
|
|
|
|
this->ioh = IndirectHeapUniquePtrT(ioh, resourceCleaner);
|
|
|
|
this->ssh = IndirectHeapUniquePtrT(ssh, resourceCleaner);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-07-19 03:15:50 +08:00
|
|
|
~KernelOperation() {
|
|
|
|
if (ioh.get() == dsh.get()) {
|
|
|
|
ioh.release();
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-19 03:15:50 +08:00
|
|
|
LinearStreamUniquePtrT commandStream{nullptr, resourceCleaner};
|
|
|
|
IndirectHeapUniquePtrT dsh{nullptr, resourceCleaner};
|
|
|
|
IndirectHeapUniquePtrT ioh{nullptr, resourceCleaner};
|
|
|
|
IndirectHeapUniquePtrT ssh{nullptr, resourceCleaner};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-08-26 23:31:09 +08:00
|
|
|
CommandStreamReceiver *bcsCsr = nullptr;
|
2019-11-07 16:15:53 +08:00
|
|
|
BlitPropertiesContainer blitPropertiesContainer;
|
2019-09-02 19:54:57 +08:00
|
|
|
bool blitEnqueue = false;
|
2019-07-19 03:15:50 +08:00
|
|
|
size_t surfaceStateHeapSizeEM = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2019-07-23 03:28:59 +08:00
|
|
|
class Command : public IFNode<Command> {
|
|
|
|
public:
|
|
|
|
// returns command's taskCount obtained from completion stamp
|
|
|
|
// as acquired from command stream receiver
|
2022-11-22 21:53:59 +08:00
|
|
|
virtual CompletionStamp &submit(TaskCountType taskLevel, bool terminated) = 0;
|
2019-07-23 03:28:59 +08:00
|
|
|
|
|
|
|
Command() = delete;
|
|
|
|
Command(CommandQueue &commandQueue);
|
|
|
|
Command(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation);
|
|
|
|
|
|
|
|
virtual ~Command();
|
|
|
|
virtual LinearStream *getCommandStream() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-11-16 18:59:18 +08:00
|
|
|
void setTimestampPacketNode(TimestampPacketContainer ¤t, TimestampPacketDependencies &&dependencies);
|
2019-07-23 03:28:59 +08:00
|
|
|
void setEventsRequest(EventsRequest &eventsRequest);
|
2019-09-04 15:33:21 +08:00
|
|
|
void makeTimestampPacketsResident(CommandStreamReceiver &commandStreamReceiver);
|
2019-07-23 03:28:59 +08:00
|
|
|
|
2021-03-25 02:21:13 +08:00
|
|
|
TagNodeBase *timestamp = nullptr;
|
2019-07-23 03:28:59 +08:00
|
|
|
CompletionStamp completionStamp = {};
|
|
|
|
|
|
|
|
protected:
|
2021-12-20 22:32:06 +08:00
|
|
|
bool terminated = false;
|
2019-07-23 03:28:59 +08:00
|
|
|
CommandQueue &commandQueue;
|
|
|
|
std::unique_ptr<KernelOperation> kernelOperation;
|
|
|
|
std::unique_ptr<TimestampPacketContainer> currentTimestampPacketNodes;
|
2019-11-16 18:59:18 +08:00
|
|
|
std::unique_ptr<TimestampPacketDependencies> timestampPacketDependencies;
|
2019-07-23 03:28:59 +08:00
|
|
|
EventsRequest eventsRequest = {0, nullptr, nullptr};
|
|
|
|
std::vector<cl_event> eventsWaitlist;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandMapUnmap : public Command {
|
|
|
|
public:
|
|
|
|
CommandMapUnmap(MapOperationType operationType, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly,
|
|
|
|
CommandQueue &commandQueue);
|
|
|
|
~CommandMapUnmap() override = default;
|
2022-11-22 21:53:59 +08:00
|
|
|
CompletionStamp &submit(TaskCountType taskLevel, bool terminated) override;
|
2019-07-23 03:28:59 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
MemObj &memObj;
|
|
|
|
MemObjSizeArray copySize;
|
|
|
|
MemObjOffsetArray copyOffset;
|
|
|
|
bool readOnly;
|
|
|
|
MapOperationType operationType;
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class CommandComputeKernel : public Command {
|
|
|
|
public:
|
2022-03-01 23:14:04 +08:00
|
|
|
CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> &kernelOperation, std::vector<Surface *> surfaces,
|
2021-12-07 16:40:35 +08:00
|
|
|
bool flushDC, bool usesSLM, uint32_t commandType, std::unique_ptr<PrintfHandler> &&printfHandler,
|
2023-01-12 17:59:50 +08:00
|
|
|
PreemptionMode preemptionMode, Kernel *kernel, uint32_t kernelCount, TagNodeBase *multiRootDeviceSyncNode);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
~CommandComputeKernel() override;
|
|
|
|
|
2022-11-22 21:53:59 +08:00
|
|
|
CompletionStamp &submit(TaskCountType taskLevel, bool terminated) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-30 14:18:50 +08:00
|
|
|
LinearStream *getCommandStream() override { return kernelOperation->commandStream.get(); }
|
2021-06-17 20:06:57 +08:00
|
|
|
Kernel *peekKernel() const { return kernel; }
|
2021-09-22 21:16:09 +08:00
|
|
|
PrintfHandler *peekPrintfHandler() const { return printfHandler.get(); }
|
2018-08-30 14:18:50 +08:00
|
|
|
|
2019-01-11 16:00:11 +08:00
|
|
|
protected:
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<Surface *> surfaces;
|
|
|
|
bool flushDC;
|
|
|
|
bool slmUsed;
|
2021-12-07 16:40:35 +08:00
|
|
|
uint32_t commandType;
|
2017-12-21 07:45:38 +08:00
|
|
|
std::unique_ptr<PrintfHandler> printfHandler;
|
|
|
|
Kernel *kernel;
|
|
|
|
uint32_t kernelCount;
|
2018-03-02 05:43:04 +08:00
|
|
|
PreemptionMode preemptionMode;
|
2023-01-12 17:59:50 +08:00
|
|
|
TagNodeBase *multiRootDeviceSyncNode;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2019-09-02 18:49:36 +08:00
|
|
|
class CommandWithoutKernel : public Command {
|
2017-12-21 07:45:38 +08:00
|
|
|
public:
|
2019-07-23 03:28:59 +08:00
|
|
|
using Command::Command;
|
2022-11-22 21:53:59 +08:00
|
|
|
CompletionStamp &submit(TaskCountType taskLevel, bool terminated) override;
|
|
|
|
TaskCountType dispatchBlitOperation();
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|