2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-01-11 09:00:11 +01:00
|
|
|
* Copyright (C) 2017-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
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
2018-03-01 22:43:04 +01:00
|
|
|
#include "runtime/helpers/completion_stamp.h"
|
|
|
|
|
#include "runtime/helpers/hw_info.h"
|
2018-02-17 22:26:28 +01:00
|
|
|
#include "runtime/helpers/properties_helper.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/indirect_heap/indirect_heap.h"
|
|
|
|
|
#include "runtime/utilities/iflist.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
class CommandQueue;
|
|
|
|
|
class CommandStreamReceiver;
|
2018-10-24 14:25:04 +02:00
|
|
|
class InternalAllocationStorage;
|
2017-12-21 00:45:38 +01:00
|
|
|
class Kernel;
|
|
|
|
|
class MemObj;
|
|
|
|
|
class Surface;
|
|
|
|
|
class PrintfHandler;
|
|
|
|
|
struct HwTimeStamps;
|
2018-10-02 14:37:30 -07:00
|
|
|
class TimestampPacketContainer;
|
2018-12-21 13:05:21 +01:00
|
|
|
template <class T>
|
|
|
|
|
struct TagNode;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
enum MapOperationType {
|
|
|
|
|
MAP,
|
|
|
|
|
UNMAP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Command : public IFNode<Command> {
|
|
|
|
|
public:
|
|
|
|
|
// returns command's taskCount obtained from completion stamp
|
|
|
|
|
// as acquired from command stream receiver
|
|
|
|
|
virtual CompletionStamp &submit(uint32_t taskLevel, bool terminated) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ~Command() = default;
|
|
|
|
|
virtual LinearStream *getCommandStream() {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2018-12-21 13:05:21 +01:00
|
|
|
TagNode<HwTimeStamps> *timestamp = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
CompletionStamp completionStamp = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandMapUnmap : public Command {
|
|
|
|
|
public:
|
2018-02-17 22:26:28 +01:00
|
|
|
CommandMapUnmap(MapOperationType op, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly,
|
|
|
|
|
CommandStreamReceiver &csr, CommandQueue &cmdQ);
|
2018-01-05 11:33:30 +01:00
|
|
|
~CommandMapUnmap() override;
|
2017-12-21 00:45:38 +01:00
|
|
|
CompletionStamp &submit(uint32_t taskLevel, bool terminated) override;
|
|
|
|
|
|
|
|
|
|
private:
|
2018-01-05 11:33:30 +01:00
|
|
|
MemObj &memObj;
|
2018-02-17 22:26:28 +01:00
|
|
|
MemObjSizeArray copySize;
|
|
|
|
|
MemObjOffsetArray copyOffset;
|
|
|
|
|
bool readOnly;
|
2017-12-21 00:45:38 +01:00
|
|
|
CommandStreamReceiver &csr;
|
|
|
|
|
CommandQueue &cmdQ;
|
|
|
|
|
MapOperationType op;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct KernelOperation {
|
2018-04-05 15:12:28 +02:00
|
|
|
KernelOperation(std::unique_ptr<LinearStream> commandStream, std::unique_ptr<IndirectHeap> dsh, std::unique_ptr<IndirectHeap> ioh, std::unique_ptr<IndirectHeap> ssh,
|
2018-10-24 14:25:04 +02:00
|
|
|
InternalAllocationStorage &storageForAllocations)
|
2017-12-21 00:45:38 +01:00
|
|
|
: commandStream(std::move(commandStream)), dsh(std::move(dsh)),
|
2018-03-28 19:21:07 +02:00
|
|
|
ioh(std::move(ioh)), ssh(std::move(ssh)),
|
2018-10-24 14:25:04 +02:00
|
|
|
surfaceStateHeapSizeEM(0), doNotFreeISH(false), storageForAllocations(storageForAllocations) {
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~KernelOperation();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<LinearStream> commandStream;
|
|
|
|
|
std::unique_ptr<IndirectHeap> dsh;
|
|
|
|
|
std::unique_ptr<IndirectHeap> ioh;
|
|
|
|
|
std::unique_ptr<IndirectHeap> ssh;
|
|
|
|
|
|
|
|
|
|
size_t surfaceStateHeapSizeEM;
|
|
|
|
|
bool doNotFreeISH;
|
2018-10-24 14:25:04 +02:00
|
|
|
InternalAllocationStorage &storageForAllocations;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandComputeKernel : public Command {
|
|
|
|
|
public:
|
2018-09-19 10:34:33 -07:00
|
|
|
CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr<KernelOperation> kernelResources, std::vector<Surface *> &surfaces,
|
2018-03-01 22:43:04 +01:00
|
|
|
bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr<PrintfHandler> printfHandler,
|
|
|
|
|
PreemptionMode preemptionMode, Kernel *kernel = nullptr, uint32_t kernelCount = 0);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
~CommandComputeKernel() override;
|
|
|
|
|
|
|
|
|
|
CompletionStamp &submit(uint32_t taskLevel, bool terminated) override;
|
|
|
|
|
|
2018-08-30 08:18:50 +02:00
|
|
|
LinearStream *getCommandStream() override { return kernelOperation->commandStream.get(); }
|
|
|
|
|
|
2018-10-02 14:37:30 -07:00
|
|
|
void setTimestampPacketNode(TimestampPacketContainer ¤t, TimestampPacketContainer &previous);
|
2019-01-11 09:00:11 +01:00
|
|
|
void setEventsRequest(EventsRequest &eventsRequest);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-01-11 09:00:11 +01:00
|
|
|
protected:
|
2017-12-21 00:45:38 +01:00
|
|
|
CommandQueue &commandQueue;
|
|
|
|
|
std::unique_ptr<KernelOperation> kernelOperation;
|
|
|
|
|
std::vector<Surface *> surfaces;
|
|
|
|
|
bool flushDC;
|
|
|
|
|
bool slmUsed;
|
|
|
|
|
bool NDRangeKernel;
|
|
|
|
|
std::unique_ptr<PrintfHandler> printfHandler;
|
|
|
|
|
Kernel *kernel;
|
|
|
|
|
uint32_t kernelCount;
|
2018-03-01 22:43:04 +01:00
|
|
|
PreemptionMode preemptionMode;
|
2018-10-02 14:37:30 -07:00
|
|
|
std::unique_ptr<TimestampPacketContainer> currentTimestampPacketNodes;
|
|
|
|
|
std::unique_ptr<TimestampPacketContainer> previousTimestampPacketNodes;
|
2018-09-19 10:34:33 -07:00
|
|
|
EventsRequest eventsRequest = {0, nullptr, nullptr};
|
2019-01-11 09:00:11 +01:00
|
|
|
std::vector<cl_event> eventsWaitlist;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandMarker : public Command {
|
|
|
|
|
public:
|
2018-04-09 16:39:32 +02:00
|
|
|
CommandMarker(CommandQueue &cmdQ, CommandStreamReceiver &csr, uint32_t clCommandType, uint32_t commandSize)
|
2017-12-21 00:45:38 +01:00
|
|
|
: cmdQ(cmdQ), csr(csr), clCommandType(clCommandType), commandSize(commandSize) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompletionStamp &submit(uint32_t taskLevel, bool terminated) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CommandQueue &cmdQ;
|
|
|
|
|
CommandStreamReceiver &csr;
|
2018-04-09 16:39:32 +02:00
|
|
|
uint32_t clCommandType;
|
|
|
|
|
uint32_t commandSize;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
} // namespace OCLRT
|