Skip to content

Commit

Permalink
Add blit copy implementation for L0
Browse files Browse the repository at this point in the history
Change-Id: I327a4cf977e166cb648ee9f3a79374f7cefa7b1b
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
  • Loading branch information
MaciejPlewka authored and Compute-Runtime-Automation committed Apr 9, 2020
1 parent 3ce0450 commit 691a4ea
Show file tree
Hide file tree
Showing 30 changed files with 961 additions and 171 deletions.
5 changes: 4 additions & 1 deletion level_zero/core/source/cmdlist/cmdlist.cpp
Expand Up @@ -77,9 +77,12 @@ void CommandList::eraseResidencyContainerEntry(NEO::GraphicsAllocation *allocati
}
}

bool CommandList::isCopyOnly() const {
return isCopyOnlyCmdList;
}

NEO::PreemptionMode CommandList::obtainFunctionPreemptionMode(Kernel *kernel) {
auto functionAttributes = kernel->getImmutableData()->getDescriptor().kernelAttributes;

NEO::PreemptionFlags flags = {};
flags.flags.disabledMidThreadPreemptionKernel = functionAttributes.flags.requiresDisabledMidThreadPreemption;
flags.flags.usesFencesForReadWriteImages = functionAttributes.flags.usesFencesForReadWriteImages;
Expand Down
8 changes: 5 additions & 3 deletions level_zero/core/source/cmdlist/cmdlist.h
Expand Up @@ -117,10 +117,10 @@ struct CommandList : _ze_command_list_handle_t {
virtual ze_result_t appendMIBBEnd() = 0;
virtual ze_result_t appendMINoop() = 0;

static CommandList *create(uint32_t productFamily, Device *device);
static CommandList *create(uint32_t productFamily, Device *device, bool isCopyOnly);
static CommandList *createImmediate(uint32_t productFamily, Device *device,
const ze_command_queue_desc_t *desc,
bool internalUsage);
bool internalUsage, bool isCopyOnly);

static CommandList *fromHandle(ze_command_list_handle_t handle) {
return static_cast<CommandList *>(handle);
Expand All @@ -147,6 +147,7 @@ struct CommandList : _ze_command_list_handle_t {
void removeHostPtrAllocations();
void eraseDeallocationContainerEntry(NEO::GraphicsAllocation *allocation);
void eraseResidencyContainerEntry(NEO::GraphicsAllocation *allocation);
bool isCopyOnly() const;

enum CommandListType : uint32_t {
TYPE_REGULAR = 0u,
Expand All @@ -161,14 +162,15 @@ struct CommandList : _ze_command_list_handle_t {
std::vector<Kernel *> printfFunctionContainer;

virtual ze_result_t executeCommandListImmediate(bool performMigration) = 0;
virtual bool initialize(Device *device) = 0;
virtual bool initialize(Device *device, bool isCopyOnly) = 0;
virtual ~CommandList();
NEO::CommandContainer commandContainer;

protected:
std::map<const void *, NEO::GraphicsAllocation *> hostPtrMap;
uint32_t commandListPerThreadScratchSize = 0u;
NEO::PreemptionMode commandListPreemptionMode = NEO::PreemptionMode::Initial;
bool isCopyOnlyCmdList = false;
};

using CommandListAllocatorFn = CommandList *(*)(uint32_t);
Expand Down
57 changes: 35 additions & 22 deletions level_zero/core/source/cmdlist/cmdlist_hw.h
Expand Up @@ -35,7 +35,7 @@ struct CommandListCoreFamily : CommandListImp {

using CommandListImp::CommandListImp;

bool initialize(Device *device) override;
bool initialize(Device *device, bool isCopyOnly) override;
virtual void programL3(bool isSLMused);

ze_result_t close() override;
Expand Down Expand Up @@ -124,26 +124,39 @@ struct CommandListCoreFamily : CommandListImp {
ze_result_t executeCommandListImmediate(bool performMigration) override;

protected:
ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
uint64_t dstOffset, void *srcPtr,
NEO::GraphicsAllocation *srcPtrAlloc,
uint64_t srcOffset, uint32_t size,
uint32_t elementSize, Builtin builtin);

ze_result_t appendMemoryCopyKernel2d(const void *dstptr, const void *srcptr,
Builtin builtin, const ze_copy_region_t *dstRegion,
uint32_t dstPitch, size_t dstOffset,
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
size_t srcOffset, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);

ze_result_t appendMemoryCopyKernel3d(const void *dstptr, const void *srcptr,
Builtin builtin, const ze_copy_region_t *dstRegion,
uint32_t dstPitch, uint32_t dstSlicePitch, size_t dstOffset,
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
uint32_t srcSlicePitch, size_t srcOffset,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents);
MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
uint64_t dstOffset, void *srcPtr,
NEO::GraphicsAllocation *srcPtrAlloc,
uint64_t srcOffset, uint32_t size,
uint32_t elementSize, Builtin builtin);

MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyBlit(NEO::GraphicsAllocation *dstPtrAlloc,
uint64_t dstOffset,
NEO::GraphicsAllocation *srcPtrAlloc,
uint64_t srcOffset, uint32_t size);

MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyBlitRegion(const void *srcptr,
const void *dstptr,
ze_copy_region_t srcRegion,
ze_copy_region_t dstRegion, Vec3<size_t> copySize,
size_t srcRowPitch, size_t srcSlicePitch,
size_t dstRowPitch, size_t dstSlicePitch,
size_t srcSize, size_t dstSize);

MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernel2d(const void *dstptr, const void *srcptr,
Builtin builtin, const ze_copy_region_t *dstRegion,
uint32_t dstPitch, size_t dstOffset,
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
size_t srcOffset, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);

MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernel3d(const void *dstptr, const void *srcptr,
Builtin builtin, const ze_copy_region_t *dstRegion,
uint32_t dstPitch, uint32_t dstSlicePitch, size_t dstOffset,
const ze_copy_region_t *srcRegion, uint32_t srcPitch,
uint32_t srcSlicePitch, size_t srcOffset,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents);

ze_result_t appendLaunchKernelWithParams(ze_kernel_handle_t hKernel,
const ze_group_count_t *pThreadGroupDimensions,
Expand All @@ -160,7 +173,7 @@ struct CommandListCoreFamily : CommandListImp {
void appendSignalEventPostWalker(ze_event_handle_t hEvent);

uint64_t getInputBufferSize(NEO::ImageType imageType, uint64_t bytesPerPixel, const ze_image_region_t *region);
AlignedAllocationData getAlignedAllocation(Device *device, const void *buffer, uint64_t bufferSize);
virtual AlignedAllocationData getAlignedAllocation(Device *device, const void *buffer, uint64_t bufferSize);
ze_result_t addEventsToCmdList(ze_event_handle_t hEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);
};

Expand Down

0 comments on commit 691a4ea

Please sign in to comment.