2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2024-03-07 16:50:57 +00:00
|
|
|
* Copyright (C) 2018-2024 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
|
2023-01-20 13:01:19 +00:00
|
|
|
#include "shared/source/command_stream/csr_definitions.h"
|
2023-01-11 15:32:55 +00:00
|
|
|
#include "shared/source/helpers/completion_stamp.h"
|
2023-01-20 13:01:19 +00:00
|
|
|
#include "shared/source/helpers/engine_node_helper.h"
|
2023-01-11 17:04:14 +00:00
|
|
|
#include "shared/source/helpers/map_operation_type.h"
|
2023-01-20 13:01:19 +00:00
|
|
|
#include "shared/source/helpers/timestamp_packet_container.h"
|
|
|
|
|
#include "shared/source/indirect_heap/indirect_heap_type.h"
|
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2023-01-03 16:20:12 +00:00
|
|
|
#include "shared/source/sku_info/sku_info_base.h"
|
2023-01-11 15:32:55 +00:00
|
|
|
#include "shared/source/unified_memory/unified_memory.h"
|
2021-09-09 16:57:09 +00:00
|
|
|
#include "shared/source/utilities/range.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2023-01-11 15:32:55 +00:00
|
|
|
#include "opencl/source/api/cl_types.h"
|
2021-08-26 16:38:39 +00:00
|
|
|
#include "opencl/source/command_queue/copy_engine_state.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/helpers/base_object.h"
|
2020-06-24 13:32:09 +02:00
|
|
|
#include "opencl/source/helpers/enqueue_properties.h"
|
2023-01-11 15:32:55 +00:00
|
|
|
#include "opencl/source/helpers/properties_helper.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <cstdint>
|
2023-04-20 00:18:51 +00:00
|
|
|
#include <optional>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-03-22 13:40:41 +01:00
|
|
|
class BarrierCommand;
|
2017-12-21 00:45:38 +01:00
|
|
|
class Buffer;
|
2020-01-14 14:32:11 +01:00
|
|
|
class ClDevice;
|
2017-12-21 00:45:38 +01:00
|
|
|
class Context;
|
2018-10-29 10:38:53 +01:00
|
|
|
class Event;
|
2018-02-08 22:59:03 +01:00
|
|
|
class EventBuilder;
|
2018-10-29 10:38:53 +01:00
|
|
|
class FlushStampTracker;
|
2017-12-21 00:45:38 +01:00
|
|
|
class Image;
|
|
|
|
|
class IndirectHeap;
|
|
|
|
|
class Kernel;
|
2023-01-20 13:01:19 +00:00
|
|
|
class LinearStream;
|
2018-10-29 10:38:53 +01:00
|
|
|
class PerformanceCounters;
|
2023-01-20 13:01:19 +00:00
|
|
|
class PrintfHandler;
|
|
|
|
|
enum class WaitStatus;
|
|
|
|
|
struct BuiltinOpParams;
|
|
|
|
|
struct CsrSelectionArgs;
|
2018-12-17 15:23:35 +01:00
|
|
|
struct MultiDispatchInfo;
|
2023-01-20 13:01:19 +00:00
|
|
|
struct TimestampPacketDependencies;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-24 12:00:27 +01:00
|
|
|
enum class QueuePriority {
|
2023-12-19 07:40:17 +00:00
|
|
|
low,
|
|
|
|
|
medium,
|
|
|
|
|
high
|
2018-01-24 12:00:27 +01:00
|
|
|
};
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <>
|
|
|
|
|
struct OpenCLObjectMapper<_cl_command_queue> {
|
|
|
|
|
typedef class CommandQueue DerivedType;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandQueue : public BaseObject<_cl_command_queue> {
|
|
|
|
|
public:
|
|
|
|
|
static const cl_ulong objectMagic = 0x1234567890987654LL;
|
|
|
|
|
|
2020-01-21 09:35:12 +01:00
|
|
|
static CommandQueue *create(Context *context,
|
|
|
|
|
ClDevice *device,
|
2017-12-21 00:45:38 +01:00
|
|
|
const cl_queue_properties *properties,
|
2020-01-21 09:35:12 +01:00
|
|
|
bool internalUsage,
|
2017-12-21 00:45:38 +01:00
|
|
|
cl_int &errcodeRet);
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
static cl_int getErrorCodeFromTaskCount(TaskCountType taskCount);
|
2022-11-04 13:57:42 +00:00
|
|
|
|
2020-03-04 15:28:58 +01:00
|
|
|
CommandQueue() = delete;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-07-02 11:34:07 +00:00
|
|
|
CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties, bool internalUsage);
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
CommandQueue &operator=(const CommandQueue &) = delete;
|
|
|
|
|
CommandQueue(const CommandQueue &) = delete;
|
|
|
|
|
|
|
|
|
|
~CommandQueue() override;
|
|
|
|
|
|
|
|
|
|
// API entry points
|
2021-06-15 12:24:35 +00:00
|
|
|
virtual cl_int enqueueCopyImage(Image *srcImage, Image *dstImage, const size_t *srcOrigin, const size_t *dstOrigin,
|
|
|
|
|
const size_t *region, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
2020-03-04 15:28:58 +01:00
|
|
|
|
|
|
|
|
virtual cl_int enqueueFillImage(Image *image, const void *fillColor, const size_t *origin, const size_t *region,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueFillBuffer(Buffer *buffer, const void *pattern, size_t patternSize, size_t offset,
|
|
|
|
|
size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
2021-03-08 17:27:24 +01:00
|
|
|
virtual cl_int enqueueKernel(Kernel *kernel, cl_uint workDim, const size_t *globalWorkOffset, const size_t *globalWorkSize,
|
2020-03-04 15:28:58 +01:00
|
|
|
const size_t *localWorkSize, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueBarrierWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-08 22:59:03 +01:00
|
|
|
MOCKABLE_VIRTUAL void *enqueueMapBuffer(Buffer *buffer, cl_bool blockingMap,
|
|
|
|
|
cl_map_flags mapFlags, size_t offset,
|
|
|
|
|
size_t size, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event,
|
|
|
|
|
cl_int &errcodeRet);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-08 22:59:03 +01:00
|
|
|
MOCKABLE_VIRTUAL void *enqueueMapImage(Image *image, cl_bool blockingMap,
|
|
|
|
|
cl_map_flags mapFlags, const size_t *origin,
|
|
|
|
|
const size_t *region, size_t *imageRowPitch,
|
|
|
|
|
size_t *imageSlicePitch, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event, cl_int &errcodeRet);
|
|
|
|
|
|
|
|
|
|
MOCKABLE_VIRTUAL cl_int enqueueUnmapMemObject(MemObj *memObj, void *mappedPtr, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-03-04 15:28:58 +01:00
|
|
|
virtual cl_int enqueueSVMMap(cl_bool blockingMap, cl_map_flags mapFlags, void *svmPtr, size_t size,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event, bool externalAppCall) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueSVMUnmap(void *svmPtr, cl_uint numEventsInWaitList, const cl_event *eventWaitList,
|
|
|
|
|
cl_event *event, bool externalAppCall) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueSVMFree(cl_uint numSvmPointers, void *svmPointers[],
|
2017-12-21 00:45:38 +01:00
|
|
|
void(CL_CALLBACK *pfnFreeFunc)(cl_command_queue queue,
|
|
|
|
|
cl_uint numSvmPointers,
|
|
|
|
|
void *svmPointers[],
|
|
|
|
|
void *userData),
|
2020-03-04 15:28:58 +01:00
|
|
|
void *userData, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueSVMMemcpy(cl_bool blockingCopy, void *dstPtr, const void *srcPtr, size_t size, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueSVMMemFill(void *svmPtr, const void *pattern, size_t patternSize,
|
|
|
|
|
size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueMigrateMemObjects(cl_uint numMemObjects, const cl_mem *memObjects, cl_mem_migration_flags flags,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueSVMMigrateMem(cl_uint numSvmPointers, const void **svmPointers, const size_t *sizes,
|
|
|
|
|
const cl_mem_migration_flags flags, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueCopyBuffer(Buffer *srcBuffer, Buffer *dstBuffer, size_t srcOffset, size_t dstOffset,
|
|
|
|
|
size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr,
|
|
|
|
|
GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region,
|
|
|
|
|
size_t rowPitch, size_t slicePitch, void *ptr, GraphicsAllocation *mapAllocation,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueWriteBuffer(Buffer *buffer, cl_bool blockingWrite, size_t offset, size_t cb,
|
|
|
|
|
const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueWriteImage(Image *dstImage, cl_bool blockingWrite, const size_t *origin,
|
|
|
|
|
const size_t *region, size_t inputRowPitch, size_t inputSlicePitch,
|
|
|
|
|
const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin,
|
|
|
|
|
const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueWriteBufferRect(Buffer *buffer, cl_bool blockingWrite, const size_t *bufferOrigin,
|
|
|
|
|
const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch,
|
|
|
|
|
size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch,
|
|
|
|
|
const void *ptr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueReadBufferRect(Buffer *buffer, cl_bool blockingRead, const size_t *bufferOrigin,
|
|
|
|
|
const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch,
|
|
|
|
|
size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch,
|
|
|
|
|
void *ptr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueCopyBufferToImage(Buffer *srcBuffer, Image *dstImage, size_t srcOffset,
|
|
|
|
|
const size_t *dstOrigin, const size_t *region,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int enqueueCopyImageToBuffer(Image *srcImage, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *region,
|
|
|
|
|
size_t dstOffset, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
cl_int enqueueAcquireSharedObjects(cl_uint numObjects,
|
|
|
|
|
const cl_mem *memObjects,
|
|
|
|
|
cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList,
|
|
|
|
|
cl_event *oclEvent,
|
|
|
|
|
cl_uint cmdType);
|
|
|
|
|
|
|
|
|
|
cl_int enqueueReleaseSharedObjects(cl_uint numObjects,
|
|
|
|
|
const cl_mem *memObjects,
|
|
|
|
|
cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList,
|
|
|
|
|
cl_event *oclEvent,
|
|
|
|
|
cl_uint cmdType);
|
|
|
|
|
|
2019-04-03 13:15:07 +02:00
|
|
|
MOCKABLE_VIRTUAL void *cpuDataTransferHandler(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &retVal);
|
2018-02-08 22:59:03 +01:00
|
|
|
|
2020-03-04 15:28:58 +01:00
|
|
|
virtual cl_int enqueueResourceBarrier(BarrierCommand *resourceBarrier, cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList, cl_event *event) = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int finish() = 0;
|
|
|
|
|
|
|
|
|
|
virtual cl_int flush() = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-08-26 11:26:44 +02:00
|
|
|
void updateFromCompletionStamp(const CompletionStamp &completionStamp, Event *outEvent);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-07-22 20:55:09 +02:00
|
|
|
virtual bool isCacheFlushCommand(uint32_t commandType) const { return false; }
|
2019-03-22 13:40:41 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
cl_int getCommandQueueInfo(cl_command_queue_info paramName,
|
|
|
|
|
size_t paramValueSize, void *paramValue,
|
|
|
|
|
size_t *paramValueSizeRet);
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
TagAddressType getHwTag() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
volatile TagAddressType *getHwTagAddress() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-07-25 12:28:31 +00:00
|
|
|
MOCKABLE_VIRTUAL bool isCompleted(TaskCountType gpgpuTaskCount, const Range<CopyEngineState> &bcsStates);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-03-04 08:39:42 +00:00
|
|
|
bool isWaitForTimestampsEnabled() const;
|
2023-07-13 15:48:26 +00:00
|
|
|
virtual bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, WaitStatus &status, TimestampPacketContainer *mainContainer, TimestampPacketContainer *deferredContainer) = 0;
|
2021-11-17 15:05:48 +00:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
MOCKABLE_VIRTUAL bool isQueueBlocked();
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
MOCKABLE_VIRTUAL WaitStatus waitUntilComplete(TaskCountType gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait);
|
|
|
|
|
MOCKABLE_VIRTUAL WaitStatus waitUntilComplete(TaskCountType gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) {
|
2022-02-22 12:51:29 +00:00
|
|
|
return this->waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, true, false);
|
2021-10-21 01:29:53 +02:00
|
|
|
}
|
2022-02-28 10:24:05 +00:00
|
|
|
MOCKABLE_VIRTUAL WaitStatus waitForAllEngines(bool blockedQueue, PrintfHandler *printfHandler, bool cleanTemporaryAllocationsList);
|
|
|
|
|
MOCKABLE_VIRTUAL WaitStatus waitForAllEngines(bool blockedQueue, PrintfHandler *printfHandler) {
|
|
|
|
|
return this->waitForAllEngines(blockedQueue, printfHandler, true);
|
2021-10-21 01:29:53 +02:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
static TaskCountType getTaskLevelFromWaitList(TaskCountType taskLevel,
|
|
|
|
|
cl_uint numEventsInWaitList,
|
|
|
|
|
const cl_event *eventWaitList);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-04-29 08:02:40 +00:00
|
|
|
void initializeGpgpu() const;
|
|
|
|
|
void initializeGpgpuInternals() const;
|
2019-11-24 14:50:41 +01:00
|
|
|
MOCKABLE_VIRTUAL CommandStreamReceiver &getGpgpuCommandStreamReceiver() const;
|
2022-04-25 11:06:41 +00:00
|
|
|
MOCKABLE_VIRTUAL CommandStreamReceiver *getBcsCommandStreamReceiver(aub_stream::EngineType bcsEngineType);
|
|
|
|
|
CommandStreamReceiver *getBcsForAuxTranslation();
|
|
|
|
|
MOCKABLE_VIRTUAL CommandStreamReceiver &selectCsrForBuiltinOperation(const CsrSelectionArgs &args);
|
2022-05-19 10:06:08 +00:00
|
|
|
void constructBcsEngine(bool internalUsage);
|
|
|
|
|
MOCKABLE_VIRTUAL void initializeBcsEngine(bool internalUsage);
|
2022-07-20 15:05:27 +00:00
|
|
|
void constructBcsEnginesForSplit();
|
|
|
|
|
void prepareHostPtrSurfaceForSplit(bool split, GraphicsAllocation &allocation);
|
|
|
|
|
CommandStreamReceiver &selectCsrForHostPtrAllocation(bool split, CommandStreamReceiver &csr);
|
|
|
|
|
void releaseMainCopyEngine();
|
2020-01-14 14:32:11 +01:00
|
|
|
Device &getDevice() const noexcept;
|
2020-10-22 12:14:54 +02:00
|
|
|
ClDevice &getClDevice() const { return *device; }
|
2019-02-21 16:59:10 +01:00
|
|
|
Context &getContext() const { return *context; }
|
|
|
|
|
Context *getContextPtr() const { return context; }
|
2022-04-29 08:02:40 +00:00
|
|
|
EngineControl &getGpgpuEngine() const {
|
|
|
|
|
this->initializeGpgpu();
|
|
|
|
|
return *gpgpuEngine;
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-08-24 08:48:59 +02:00
|
|
|
MOCKABLE_VIRTUAL LinearStream &getCS(size_t minRequiredSize);
|
2023-01-11 15:32:55 +00:00
|
|
|
IndirectHeap &getIndirectHeap(IndirectHeapType heapType,
|
2018-04-16 16:39:00 +02:00
|
|
|
size_t minRequiredSize);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-01-11 15:32:55 +00:00
|
|
|
void allocateHeapMemory(IndirectHeapType heapType,
|
2018-04-05 15:12:28 +02:00
|
|
|
size_t minRequiredSize, IndirectHeap *&indirectHeap);
|
|
|
|
|
|
2021-11-12 11:02:17 +00:00
|
|
|
static bool isAssignEngineRoundRobinEnabled();
|
2021-12-09 11:59:52 +00:00
|
|
|
static bool isTimestampWaitEnabled();
|
2021-11-12 11:02:17 +00:00
|
|
|
|
2023-01-11 15:32:55 +00:00
|
|
|
MOCKABLE_VIRTUAL void releaseIndirectHeap(IndirectHeapType heapType);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-01-11 15:32:55 +00:00
|
|
|
void releaseVirtualEvent();
|
2019-02-04 13:08:47 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
cl_command_queue_properties getCommandQueueProperties() const {
|
|
|
|
|
return commandQueueProperties;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 12:25:29 +02:00
|
|
|
bool isProfilingEnabled() const {
|
2017-12-21 00:45:38 +01:00
|
|
|
return !!(this->getCommandQueueProperties() & CL_QUEUE_PROFILING_ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 12:25:29 +02:00
|
|
|
bool isOOQEnabled() const {
|
2017-12-21 00:45:38 +01:00
|
|
|
return !!(this->getCommandQueueProperties() & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 12:25:29 +02:00
|
|
|
bool isPerfCountersEnabled() const {
|
2017-12-21 00:45:38 +01:00
|
|
|
return perfCountersEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PerformanceCounters *getPerfCounters();
|
|
|
|
|
|
2019-12-19 12:58:02 +01:00
|
|
|
bool setPerfCountersEnabled();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-05 11:33:30 +01:00
|
|
|
void setIsSpecialCommandQueue(bool newValue) {
|
|
|
|
|
this->isSpecialCommandQueue = newValue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 17:12:01 +02:00
|
|
|
bool isSpecial() {
|
|
|
|
|
return this->isSpecialCommandQueue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-24 12:00:27 +01:00
|
|
|
QueuePriority getPriority() const {
|
|
|
|
|
return priority;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 11:18:34 +01:00
|
|
|
QueueThrottle getThrottle() const {
|
|
|
|
|
return throttle;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-29 15:39:50 +02:00
|
|
|
const TimestampPacketContainer *getTimestampPacketContainer() const {
|
|
|
|
|
return timestampPacketContainer.get();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 17:12:32 +02:00
|
|
|
const std::vector<uint64_t> &getPropertiesVector() const { return propertiesVector; }
|
|
|
|
|
|
2018-02-08 22:59:03 +01:00
|
|
|
void enqueueBlockedMapUnmapOperation(const cl_event *eventWaitList,
|
|
|
|
|
size_t numEventsInWaitlist,
|
|
|
|
|
MapOperationType opType,
|
|
|
|
|
MemObj *memObj,
|
2018-02-17 22:26:28 +01:00
|
|
|
MemObjSizeArray ©Size,
|
|
|
|
|
MemObjOffsetArray ©Offset,
|
|
|
|
|
bool readOnly,
|
2018-02-08 22:59:03 +01:00
|
|
|
EventBuilder &externalEventBuilder);
|
|
|
|
|
|
2018-03-21 12:58:30 +01:00
|
|
|
MOCKABLE_VIRTUAL bool setupDebugSurface(Kernel *kernel);
|
|
|
|
|
|
2020-11-24 13:29:07 +00:00
|
|
|
bool validateCapability(cl_command_queue_capabilities_intel capability) const;
|
2020-12-14 18:07:09 +00:00
|
|
|
bool validateCapabilitiesForEventWaitList(cl_uint numEventsInWaitList, const cl_event *waitList) const;
|
|
|
|
|
bool validateCapabilityForOperation(cl_command_queue_capabilities_intel capability, cl_uint numEventsInWaitList, const cl_event *waitList, const cl_event *outEvent) const;
|
2021-02-11 13:26:05 +00:00
|
|
|
cl_uint getQueueFamilyIndex() const;
|
2020-11-25 18:10:05 +00:00
|
|
|
cl_uint getQueueIndexWithinFamily() const { return queueIndexWithinFamily; }
|
|
|
|
|
bool isQueueFamilySelected() const { return queueFamilySelected; }
|
2020-11-24 13:29:07 +00:00
|
|
|
|
2019-02-10 17:50:54 +01:00
|
|
|
bool getRequiresCacheFlushAfterWalker() const {
|
|
|
|
|
return requiresCacheFlushAfterWalker;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-08 12:06:22 +00:00
|
|
|
template <typename PtrType>
|
|
|
|
|
static PtrType convertAddressWithOffsetToGpuVa(PtrType ptr, InternalMemoryType memoryType, GraphicsAllocation &allocation);
|
2021-11-02 15:17:05 +00:00
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
void updateBcsTaskCount(aub_stream::EngineType bcsEngineType, TaskCountType newBcsTaskCount);
|
|
|
|
|
TaskCountType peekBcsTaskCount(aub_stream::EngineType bcsEngineType) const;
|
2019-10-22 11:25:14 +02:00
|
|
|
|
2020-06-26 11:21:07 +02:00
|
|
|
void updateLatestSentEnqueueType(EnqueueProperties::Operation newEnqueueType) { this->latestSentEnqueueType = newEnqueueType; }
|
2021-12-09 16:18:18 +00:00
|
|
|
EnqueueProperties::Operation peekLatestSentEnqueueOperation() { return this->latestSentEnqueueType; }
|
2020-06-26 11:21:07 +02:00
|
|
|
|
2021-12-29 14:28:21 +00:00
|
|
|
void setupBarrierTimestampForBcsEngines(aub_stream::EngineType engineType, TimestampPacketDependencies ×tampPacketDependencies);
|
|
|
|
|
void processBarrierTimestampForBcsEngine(aub_stream::EngineType bcsEngineType, TimestampPacketDependencies &blitDependencies);
|
|
|
|
|
void setLastBcsPacket(aub_stream::EngineType bcsEngineType);
|
|
|
|
|
void fillCsrDependenciesWithLastBcsPackets(CsrDependencies &csrDeps);
|
|
|
|
|
void clearLastBcsPackets();
|
|
|
|
|
|
2023-09-12 14:17:52 +00:00
|
|
|
void setStallingCommandsOnNextFlush(const bool isStallingCommandsOnNextFlushRequired) {
|
|
|
|
|
stallingCommandsOnNextFlushRequired = isStallingCommandsOnNextFlushRequired;
|
|
|
|
|
if (!isStallingCommandsOnNextFlushRequired) {
|
|
|
|
|
dcFlushRequiredOnStallingCommandsOnNextFlush = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-28 12:20:30 +00:00
|
|
|
bool isStallingCommandsOnNextFlushRequired() const { return stallingCommandsOnNextFlushRequired; }
|
|
|
|
|
|
2023-07-13 09:26:41 +00:00
|
|
|
void setDcFlushRequiredOnStallingCommandsOnNextFlush(const bool isDcFlushRequiredOnStallingCommandsOnNextFlush) { dcFlushRequiredOnStallingCommandsOnNextFlush = isDcFlushRequiredOnStallingCommandsOnNextFlush; }
|
|
|
|
|
bool isDcFlushRequiredOnStallingCommandsOnNextFlush() const { return dcFlushRequiredOnStallingCommandsOnNextFlush; }
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
// taskCount of last task
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType taskCount = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
// current taskLevel. Used for determining if a PIPE_CONTROL is needed.
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType taskLevel = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
std::unique_ptr<FlushStampTracker> flushStamp;
|
|
|
|
|
|
|
|
|
|
// virtual event that holds last Enqueue information
|
2018-12-06 09:21:28 +01:00
|
|
|
Event *virtualEvent = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-21 16:59:10 +01:00
|
|
|
size_t estimateTimestampPacketNodesCount(const MultiDispatchInfo &dispatchInfo) const;
|
|
|
|
|
|
2019-08-21 03:50:47 -07:00
|
|
|
uint64_t getSliceCount() const { return sliceCount; }
|
|
|
|
|
|
2021-06-21 17:39:40 +00:00
|
|
|
TimestampPacketContainer *getDeferredTimestampPackets() const { return deferredTimestampPackets.get(); }
|
|
|
|
|
|
2019-10-11 12:54:10 +08:00
|
|
|
uint64_t dispatchHints = 0;
|
|
|
|
|
|
2021-12-07 08:40:35 +00:00
|
|
|
bool isTextureCacheFlushNeeded(uint32_t commandType) const;
|
|
|
|
|
|
2023-03-02 10:49:50 +00:00
|
|
|
const std::array<CopyEngineState, bcsInfoMaskSize> &peekActiveBcsStates() const { return bcsStates; }
|
|
|
|
|
|
2023-08-11 10:22:19 +00:00
|
|
|
void handlePostCompletionOperations(bool checkQueueCompletion);
|
2023-07-05 19:13:19 +00:00
|
|
|
|
2023-11-23 13:58:58 +00:00
|
|
|
bool getHeaplessModeEnabled() const { return this->heaplessModeEnabled; }
|
2024-03-07 16:50:57 +00:00
|
|
|
bool getHeaplessStateInitEnabled() const { return this->heaplessStateInitEnabled; }
|
2023-11-23 13:58:58 +00:00
|
|
|
|
2023-12-07 11:13:18 +00:00
|
|
|
bool isBcsSplitInitialized() const { return this->bcsSplitInitialized; }
|
2024-04-19 14:20:27 +00:00
|
|
|
bool isBcs() const { return isCopyOnly; };
|
2023-12-07 11:13:18 +00:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2018-02-08 22:59:03 +01:00
|
|
|
void *enqueueReadMemObjForMap(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &errcodeRet);
|
|
|
|
|
cl_int enqueueWriteMemObjForUnmap(MemObj *memObj, void *mappedPtr, EventsRequest &eventsRequest);
|
|
|
|
|
|
|
|
|
|
void *enqueueMapMemObject(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &errcodeRet);
|
|
|
|
|
cl_int enqueueUnmapMemObject(TransferProperties &transferProperties, EventsRequest &eventsRequest);
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
virtual void obtainTaskLevelAndBlockedStatus(TaskCountType &taskLevel, cl_uint &numEventsInWaitList, const cl_event *&eventWaitList, bool &blockQueueStatus, unsigned int commandType){};
|
2021-06-22 13:16:27 +00:00
|
|
|
bool isBlockedCommandStreamRequired(uint32_t commandType, const EventsRequest &eventsRequest, bool blockedQueue, bool isMarkerWithProfiling) const;
|
2018-02-01 13:40:30 +01:00
|
|
|
|
2021-08-25 16:03:15 +00:00
|
|
|
MOCKABLE_VIRTUAL void obtainNewTimestampPacketNodes(size_t numberOfNodes, TimestampPacketContainer &previousNodes, bool clearAllDependencies, CommandStreamReceiver &csr);
|
2020-05-27 17:12:32 +02:00
|
|
|
void storeProperties(const cl_queue_properties *properties);
|
2018-12-06 09:21:28 +01:00
|
|
|
void processProperties(const cl_queue_properties *properties);
|
2021-08-16 18:24:13 +00:00
|
|
|
void overrideEngine(aub_stream::EngineType engineType, EngineUsage engineUsage);
|
2019-05-30 14:36:12 +02:00
|
|
|
bool bufferCpuCopyAllowed(Buffer *buffer, cl_command_type commandType, cl_bool blocking, size_t size, void *ptr,
|
|
|
|
|
cl_uint numEventsInWaitList, const cl_event *eventWaitList);
|
2019-06-13 11:05:31 +02:00
|
|
|
void providePerformanceHint(TransferProperties &transferProperties);
|
2019-06-13 09:56:06 +02:00
|
|
|
bool queueDependenciesClearRequired() const;
|
2021-09-06 17:04:14 +00:00
|
|
|
bool blitEnqueueAllowed(const CsrSelectionArgs &args) const;
|
2023-04-04 09:51:38 +02:00
|
|
|
MOCKABLE_VIRTUAL bool migrateMultiGraphicsAllocationsIfRequired(const BuiltinOpParams &operationParams, CommandStreamReceiver &csr);
|
2021-12-06 10:01:46 +00:00
|
|
|
|
|
|
|
|
inline bool shouldFlushDC(uint32_t commandType, PrintfHandler *printfHandler) const {
|
|
|
|
|
return (commandType == CL_COMMAND_READ_BUFFER ||
|
|
|
|
|
commandType == CL_COMMAND_READ_BUFFER_RECT ||
|
|
|
|
|
commandType == CL_COMMAND_READ_IMAGE ||
|
|
|
|
|
commandType == CL_COMMAND_SVM_MAP ||
|
|
|
|
|
printfHandler ||
|
|
|
|
|
isTextureCacheFlushNeeded(commandType));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-06 17:04:14 +00:00
|
|
|
MOCKABLE_VIRTUAL bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image) const;
|
2019-08-02 15:56:28 +02:00
|
|
|
void aubCaptureHook(bool &blocking, bool &clearAllDependencies, const MultiDispatchInfo &multiDispatchInfo);
|
2022-03-30 12:19:43 +00:00
|
|
|
void assignDataToOverwrittenBcsNode(TagNodeBase *node);
|
2018-08-28 14:11:25 +02:00
|
|
|
|
2023-08-11 10:22:19 +00:00
|
|
|
void registerGpgpuCsrClient();
|
|
|
|
|
void registerBcsCsrClient(CommandStreamReceiver &bcsCsr);
|
|
|
|
|
|
|
|
|
|
void unregisterGpgpuCsrClient();
|
|
|
|
|
void unregisterBcsCsrClient(CommandStreamReceiver &bcsCsr);
|
|
|
|
|
|
|
|
|
|
void unregisterGpgpuAndBcsCsrClients();
|
|
|
|
|
|
2018-11-22 13:57:10 +01:00
|
|
|
Context *context = nullptr;
|
2020-01-14 14:32:11 +01:00
|
|
|
ClDevice *device = nullptr;
|
2022-04-29 08:02:40 +00:00
|
|
|
mutable EngineControl *gpgpuEngine = nullptr;
|
2021-09-24 16:32:20 +00:00
|
|
|
std::array<EngineControl *, bcsInfoMaskSize> bcsEngines = {};
|
2023-04-20 00:18:51 +00:00
|
|
|
std::optional<aub_stream::EngineType> bcsQueueEngineType{};
|
2023-09-14 07:35:58 +00:00
|
|
|
size_t bcsEngineCount = bcsInfoMaskSize;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-12-06 09:21:28 +01:00
|
|
|
cl_command_queue_properties commandQueueProperties = 0;
|
2020-05-27 17:12:32 +02:00
|
|
|
std::vector<uint64_t> propertiesVector;
|
2020-11-25 18:10:05 +00:00
|
|
|
|
2020-12-08 12:40:04 +00:00
|
|
|
cl_command_queue_capabilities_intel queueCapabilities = CL_QUEUE_DEFAULT_CAPABILITIES_INTEL;
|
2020-11-25 18:10:05 +00:00
|
|
|
cl_uint queueFamilyIndex = 0;
|
|
|
|
|
cl_uint queueIndexWithinFamily = 0;
|
|
|
|
|
bool queueFamilySelected = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-12-19 07:40:17 +00:00
|
|
|
QueuePriority priority = QueuePriority::medium;
|
2018-12-06 09:21:28 +01:00
|
|
|
QueueThrottle throttle = QueueThrottle::MEDIUM;
|
2023-12-13 16:09:52 +00:00
|
|
|
EnqueueProperties::Operation latestSentEnqueueType = EnqueueProperties::Operation::none;
|
2019-08-21 03:50:47 -07:00
|
|
|
uint64_t sliceCount = QueueSliceCount::defaultSliceCount;
|
2021-10-06 15:19:50 +00:00
|
|
|
std::array<CopyEngineState, bcsInfoMaskSize> bcsStates = {};
|
2018-01-24 12:00:27 +01:00
|
|
|
|
2018-12-06 09:21:28 +01:00
|
|
|
bool perfCountersEnabled = false;
|
2022-09-06 17:30:55 +00:00
|
|
|
bool isInternalUsage = false;
|
2020-09-25 16:42:45 +02:00
|
|
|
bool isCopyOnly = false;
|
2022-04-25 11:06:41 +00:00
|
|
|
bool bcsAllowed = false;
|
|
|
|
|
bool bcsInitialized = false;
|
2022-08-19 10:36:31 +00:00
|
|
|
|
2022-07-20 15:05:27 +00:00
|
|
|
bool bcsSplitInitialized = false;
|
2022-08-30 12:29:12 +00:00
|
|
|
BcsInfoMask splitEngines = EngineHelpers::oddLinkedCopyEnginesMask;
|
2023-05-12 10:36:06 +00:00
|
|
|
BcsInfoMask h2dEngines = NEO::EngineHelpers::h2dCopyEngineMask;
|
|
|
|
|
BcsInfoMask d2hEngines = NEO::EngineHelpers::d2hCopyEngineMask;
|
2023-05-16 11:15:43 +00:00
|
|
|
size_t minimalSizeForBcsSplit = 16 * MemoryConstants::megaByte;
|
2020-09-25 16:42:45 +02:00
|
|
|
|
2018-12-06 09:21:28 +01:00
|
|
|
LinearStream *commandStream = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-01-05 11:33:30 +01:00
|
|
|
bool isSpecialCommandQueue = false;
|
2019-02-10 17:50:54 +01:00
|
|
|
bool requiresCacheFlushAfterWalker = false;
|
2018-02-15 16:13:22 +01:00
|
|
|
|
2021-06-14 16:57:09 +00:00
|
|
|
std::unique_ptr<TimestampPacketContainer> deferredTimestampPackets;
|
2023-01-19 16:11:39 +00:00
|
|
|
std::unique_ptr<TimestampPacketContainer> deferredMultiRootSyncNodes;
|
2018-10-02 14:37:30 -07:00
|
|
|
std::unique_ptr<TimestampPacketContainer> timestampPacketContainer;
|
2022-06-27 17:20:50 +00:00
|
|
|
|
2021-12-29 14:28:21 +00:00
|
|
|
struct BcsTimestampPacketContainers {
|
|
|
|
|
TimestampPacketContainer lastBarrierToWaitFor;
|
|
|
|
|
TimestampPacketContainer lastSignalledPacket;
|
|
|
|
|
};
|
|
|
|
|
std::array<BcsTimestampPacketContainers, bcsInfoMaskSize> bcsTimestampPacketContainers;
|
2023-02-28 12:20:30 +00:00
|
|
|
bool stallingCommandsOnNextFlushRequired = false;
|
2023-07-13 09:26:41 +00:00
|
|
|
bool dcFlushRequiredOnStallingCommandsOnNextFlush = false;
|
2023-03-13 14:30:26 +00:00
|
|
|
bool splitBarrierRequired = false;
|
2023-08-11 10:22:19 +00:00
|
|
|
bool gpgpuCsrClientRegistered = false;
|
2023-11-23 13:58:58 +00:00
|
|
|
bool heaplessModeEnabled = false;
|
2024-03-07 16:50:57 +00:00
|
|
|
bool heaplessStateInitEnabled = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2021-11-08 12:06:22 +00:00
|
|
|
template <typename PtrType>
|
|
|
|
|
PtrType CommandQueue::convertAddressWithOffsetToGpuVa(PtrType ptr, InternalMemoryType memoryType, GraphicsAllocation &allocation) {
|
|
|
|
|
// If this is device or shared USM pointer, it is already a gpuVA and we don't have to do anything.
|
|
|
|
|
// Otherwise, we assume this is a cpuVA and we have to convert to gpuVA, while preserving offset from allocation start.
|
2023-12-13 10:09:37 +00:00
|
|
|
const bool isCpuPtr = (memoryType != InternalMemoryType::deviceUnifiedMemory) && (memoryType != InternalMemoryType::sharedUnifiedMemory);
|
2021-11-08 12:06:22 +00:00
|
|
|
if (isCpuPtr) {
|
|
|
|
|
size_t dstOffset = ptrDiff(ptr, allocation.getUnderlyingBuffer());
|
|
|
|
|
ptr = reinterpret_cast<PtrType>(allocation.getGpuAddress() + dstOffset);
|
|
|
|
|
}
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 09:35:12 +01:00
|
|
|
using CommandQueueCreateFunc = CommandQueue *(*)(Context *context, ClDevice *device, const cl_queue_properties *properties, bool internalUsage);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|