/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include "runtime/command_stream/linear_stream.h" #include "runtime/indirect_heap/indirect_heap.h" #include "runtime/utilities/iflist.h" #include "runtime/helpers//completion_stamp.h" #include #include namespace OCLRT { class CommandQueue; class CommandStreamReceiver; class Kernel; class MemObj; class Surface; class PrintfHandler; struct HwTimeStamps; 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; } HwTimeStamps *timestamp = nullptr; CompletionStamp completionStamp = {}; }; class CommandMapUnmap : public Command { public: CommandMapUnmap(MapOperationType op, MemObj &memObj, CommandStreamReceiver &csr, CommandQueue &cmdQ); ~CommandMapUnmap() override; CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; private: MemObj &memObj; CommandStreamReceiver &csr; CommandQueue &cmdQ; MapOperationType op; }; struct KernelOperation { KernelOperation(std::unique_ptr commandStream, std::unique_ptr dsh, std::unique_ptr ish, std::unique_ptr ioh, std::unique_ptr ssh) : commandStream(std::move(commandStream)), dsh(std::move(dsh)), ish(std::move(ish)), ioh(std::move(ioh)), ssh(std::move(ssh)), instructionHeapSizeEM(0), surfaceStateHeapSizeEM(0), doNotFreeISH(false) { } ~KernelOperation(); std::unique_ptr commandStream; std::unique_ptr dsh; std::unique_ptr ish; std::unique_ptr ioh; std::unique_ptr ssh; size_t instructionHeapSizeEM; size_t surfaceStateHeapSizeEM; bool doNotFreeISH; }; class CommandComputeKernel : public Command { public: CommandComputeKernel(CommandQueue &commandQueue, CommandStreamReceiver &commandStreamReceiver, std::unique_ptr kernelResources, std::vector &surfaces, bool flushDC, bool usesSLM, bool ndRangeKernel, std::unique_ptr printfHandler, Kernel *kernel = nullptr, uint32_t kernelCount = 0); ~CommandComputeKernel() override; CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; LinearStream *getCommandStream() override { return kernelOperation->commandStream.get(); } private: CommandQueue &commandQueue; CommandStreamReceiver &commandStreamReceiver; std::unique_ptr kernelOperation; std::vector surfaces; bool flushDC; bool slmUsed; bool NDRangeKernel; std::unique_ptr printfHandler; Kernel *kernel; uint32_t kernelCount; }; class CommandMarker : public Command { public: CommandMarker(CommandQueue &cmdQ, CommandStreamReceiver &csr, unsigned int clCommandType, unsigned int commandSize) : cmdQ(cmdQ), csr(csr), clCommandType(clCommandType), commandSize(commandSize) { } CompletionStamp &submit(uint32_t taskLevel, bool terminated) override; private: CommandQueue &cmdQ; CommandStreamReceiver &csr; unsigned int clCommandType; unsigned int commandSize; }; } // namespace OCLRT