/* * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "runtime/command_stream/linear_stream.h" #include "runtime/helpers/completion_stamp.h" #include "runtime/helpers/hw_info.h" #include "runtime/helpers/properties_helper.h" #include "runtime/indirect_heap/indirect_heap.h" #include "runtime/utilities/iflist.h" #include #include namespace NEO { class CommandQueue; class CommandStreamReceiver; class InternalAllocationStorage; class Kernel; class MemObj; class Surface; class PrintfHandler; struct HwTimeStamps; class TimestampPacketContainer; template struct TagNode; enum MapOperationType { MAP, UNMAP }; class Command : public IFNode { 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; } TagNode *timestamp = nullptr; CompletionStamp completionStamp = {}; }; class CommandMapUnmap : public Command { public: CommandMapUnmap(MapOperationType op, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly, CommandStreamReceiver &csr, CommandQueue &cmdQ); ~CommandMapUnmap() override = default; CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; private: MemObj &memObj; MemObjSizeArray copySize; MemObjOffsetArray copyOffset; bool readOnly; CommandStreamReceiver &csr; CommandQueue &cmdQ; MapOperationType op; }; struct KernelOperation { KernelOperation(std::unique_ptr commandStream, std::unique_ptr dsh, std::unique_ptr ioh, std::unique_ptr ssh, InternalAllocationStorage &storageForAllocations) : commandStream(std::move(commandStream)), dsh(std::move(dsh)), ioh(std::move(ioh)), ssh(std::move(ssh)), surfaceStateHeapSizeEM(0), doNotFreeISH(false), storageForAllocations(storageForAllocations) { } ~KernelOperation(); std::unique_ptr commandStream; std::unique_ptr dsh; std::unique_ptr ioh; std::unique_ptr ssh; size_t surfaceStateHeapSizeEM; bool doNotFreeISH; InternalAllocationStorage &storageForAllocations; }; class CommandComputeKernel : public Command { public: CommandComputeKernel(CommandQueue &commandQueue, std::unique_ptr kernelResources, std::vector &surfaces, bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr printfHandler, PreemptionMode preemptionMode, Kernel *kernel = nullptr, uint32_t kernelCount = 0); ~CommandComputeKernel() override; CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; LinearStream *getCommandStream() override { return kernelOperation->commandStream.get(); } void setTimestampPacketNode(TimestampPacketContainer ¤t, TimestampPacketContainer &previous); void setEventsRequest(EventsRequest &eventsRequest); protected: CommandQueue &commandQueue; std::unique_ptr kernelOperation; std::vector surfaces; bool flushDC; bool slmUsed; bool NDRangeKernel; std::unique_ptr printfHandler; Kernel *kernel; uint32_t kernelCount; PreemptionMode preemptionMode; std::unique_ptr currentTimestampPacketNodes; std::unique_ptr previousTimestampPacketNodes; EventsRequest eventsRequest = {0, nullptr, nullptr}; std::vector eventsWaitlist; }; class CommandMarker : public Command { public: CommandMarker(CommandQueue &cmdQ, CommandStreamReceiver &csr, uint32_t clCommandType, uint32_t commandSize) : cmdQ(cmdQ), csr(csr), clCommandType(clCommandType), commandSize(commandSize) { (void)this->cmdQ; (void)this->clCommandType; (void)this->commandSize; } CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; private: CommandQueue &cmdQ; CommandStreamReceiver &csr; uint32_t clCommandType; uint32_t commandSize; }; } // namespace NEO