Skip to content

Commit 552a126

Browse files
Refactor blit buffer call
Resolves: NEO-3241 Change-Id: I726135ae55d1e0fcbacd80620e827ee5c7c0c8dc Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
1 parent 5ab8748 commit 552a126

36 files changed

+290
-76
lines changed

common/helpers/bit_helpers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ constexpr bool isBitSet(uint64_t field, uint64_t bitPosition) {
1717
return (field & (1ull << bitPosition));
1818
}
1919

20+
constexpr bool isAnyBitSet(uint64_t field, uint64_t checkedBits) {
21+
return ((field & checkedBits) != 0);
22+
}
23+
2024
constexpr bool isValueSet(uint64_t field, uint64_t value) {
2125
assert(value != 0);
2226
return ((field & value) == value);
@@ -26,4 +30,11 @@ constexpr bool isFieldValid(uint64_t field, uint64_t acceptedBits) {
2630
return ((field & (~acceptedBits)) == 0);
2731
}
2832

33+
constexpr uint64_t setBits(uint64_t field, bool newValue, uint64_t bitsToModify) {
34+
if (newValue) {
35+
return (field | bitsToModify);
36+
}
37+
return (field & (~bitsToModify));
38+
}
39+
2940
} // namespace NEO

runtime/command_queue/cpu_data_transfer_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
124124
}
125125
if (!unmapInfo.readOnly) {
126126
auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation();
127-
graphicsAllocation->setAubWritable(true);
128-
graphicsAllocation->setTbxWritable(true);
127+
graphicsAllocation->setAubWritable(true, GraphicsAllocation::defaultBank);
128+
graphicsAllocation->setTbxWritable(true, GraphicsAllocation::defaultBank);
129129
}
130130
break;
131131
case CL_COMMAND_READ_BUFFER:

runtime/command_stream/aub_command_stream_receiver_hw_base.inl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(uint64_t gpuAddress, voi
624624

625625
template <typename GfxFamily>
626626
bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
627-
if (!gfxAllocation.isAubWritable()) {
627+
if (!this->isAubWritable(gfxAllocation)) {
628628
return false;
629629
}
630630

@@ -651,7 +651,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
651651
}
652652

653653
if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) {
654-
gfxAllocation.setAubWritable(false);
654+
this->setAubWritable(false, gfxAllocation);
655655
}
656656

657657
return true;
@@ -714,10 +714,11 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
714714

715715
for (auto &gfxAllocation : allocationsForResidency) {
716716
if (dumpAubNonWritable) {
717-
gfxAllocation->setAubWritable(true);
717+
this->setAubWritable(true, *gfxAllocation);
718718
}
719719
if (!writeMemory(*gfxAllocation)) {
720-
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable()));
720+
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) ||
721+
!this->isAubWritable(*gfxAllocation)));
721722
}
722723
gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId());
723724
}

runtime/command_stream/command_stream_receiver_simulated_common_hw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
5454
virtual void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) = 0;
5555
virtual void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) = 0;
5656

57+
virtual void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) = 0;
58+
virtual bool isAubWritable(GraphicsAllocation &graphicsAllocation) const = 0;
59+
virtual void setTbxWritable(bool writable, GraphicsAllocation &graphicsAllocation) = 0;
60+
virtual bool isTbxWritable(GraphicsAllocation &graphicsAllocation) const = 0;
61+
5762
size_t getPreferredTagPoolSize() const override { return 1; }
5863

5964
aub_stream::AubManager *aubManager = nullptr;

runtime/command_stream/command_stream_receiver_with_aub_dump.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace NEO {
1414

15-
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE];
15+
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE];
1616

1717
template <typename BaseCSR>
1818
CommandStreamReceiverWithAUBDump<BaseCSR>::CommandStreamReceiverWithAUBDump(const std::string &baseName, ExecutionEnvironment &executionEnvironment)

runtime/command_stream/create_command_stream_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace NEO {
1717

18-
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE];
18+
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE];
1919

2020
CommandStreamReceiver *createCommandStreamImpl(ExecutionEnvironment &executionEnvironment) {
2121
auto funcCreate = commandStreamReceiverFactory[executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily];

runtime/command_stream/definitions/command_stream_receiver_simulated_hw.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,18 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
2929
return new PhysicalAddressAllocator();
3030
}
3131
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override{};
32+
33+
void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) override {
34+
graphicsAllocation.setAubWritable(writable, getMemoryBank(&graphicsAllocation));
35+
}
36+
bool isAubWritable(GraphicsAllocation &graphicsAllocation) const override {
37+
return graphicsAllocation.isAubWritable(getMemoryBank(&graphicsAllocation));
38+
}
39+
void setTbxWritable(bool writable, GraphicsAllocation &graphicsAllocation) override {
40+
graphicsAllocation.setTbxWritable(writable, getMemoryBank(&graphicsAllocation));
41+
}
42+
bool isTbxWritable(GraphicsAllocation &graphicsAllocation) const override {
43+
return graphicsAllocation.isTbxWritable(getMemoryBank(&graphicsAllocation));
44+
}
3245
};
3346
} // namespace NEO

runtime/command_stream/tbx_command_stream_receiver_hw.inl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(uint64_t gpuAddress, voi
363363

364364
template <typename GfxFamily>
365365
bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
366-
if (!gfxAllocation.isTbxWritable()) {
366+
if (!this->isTbxWritable(gfxAllocation)) {
367367
return false;
368368
}
369369

@@ -381,7 +381,7 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
381381
}
382382

383383
if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) {
384-
gfxAllocation.setTbxWritable(false);
384+
this->setTbxWritable(false, gfxAllocation);
385385
}
386386

387387
return true;
@@ -413,7 +413,8 @@ template <typename GfxFamily>
413413
void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
414414
for (auto &gfxAllocation : allocationsForResidency) {
415415
if (!writeMemory(*gfxAllocation)) {
416-
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isTbxWritable()));
416+
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) ||
417+
!this->isTbxWritable(*gfxAllocation)));
417418
}
418419
gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId());
419420
}

runtime/context/context.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class MemoryManager;
2525
class SharingFunctions;
2626
class SVMAllocsManager;
2727

28+
enum class BlitOperationResult {
29+
Unsupported,
30+
Fail,
31+
Success
32+
};
33+
2834
template <>
2935
struct OpenCLObjectMapper<_cl_context> {
3036
typedef class Context DerivedType;
@@ -127,6 +133,7 @@ class Context : public BaseObject<_cl_context> {
127133
ContextType peekContextType() { return this->contextType; }
128134

129135
MOCKABLE_VIRTUAL CommandStreamReceiver *getCommandStreamReceiverForBlitOperation(MemObj &memObj) const;
136+
MOCKABLE_VIRTUAL BlitOperationResult blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const;
130137

131138
protected:
132139
Context(void(CL_CALLBACK *pfnNotify)(const char *, const void *, size_t, void *) = nullptr,

runtime/context/context_extra.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ cl_int Context::processExtraProperties(cl_context_properties propertyType, cl_co
1818
CommandStreamReceiver *Context::getCommandStreamReceiverForBlitOperation(MemObj &memObj) const {
1919
return nullptr;
2020
}
21+
22+
BlitOperationResult Context::blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const {
23+
return BlitOperationResult::Unsupported;
24+
}
2125
} // namespace NEO

0 commit comments

Comments
 (0)