Skip to content

Commit 584da13

Browse files
aub_stream interfaces update
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 6dd0f0c commit 584da13

File tree

11 files changed

+110
-35
lines changed

11 files changed

+110
-35
lines changed

opencl/source/command_stream/definitions/command_stream_receiver_simulated_hw.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,6 +11,8 @@
1111

1212
#include "opencl/source/command_stream/command_stream_receiver_simulated_common_hw.h"
1313

14+
#include "third_party/aub_stream/headers/allocation_params.h"
15+
1416
namespace NEO {
1517
class GraphicsAllocation;
1618
template <typename GfxFamily>
@@ -55,8 +57,10 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
5557
? AubMemDump::DataTypeHintValues::TraceBatchBuffer
5658
: AubMemDump::DataTypeHintValues::TraceNotype;
5759

58-
auto pageSize = graphicsAllocation.getUsedPageSize();
59-
this->aubManager->writeMemory(gpuAddress, cpuAddress, size, this->getMemoryBank(&graphicsAllocation), hint, pageSize);
60+
aub_stream::AllocationParams allocationParams(gpuAddress, cpuAddress, size, this->getMemoryBank(&graphicsAllocation),
61+
hint, graphicsAllocation.getUsedPageSize());
62+
63+
this->aubManager->writeMemory2(allocationParams);
6064
}
6165

6266
void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) override {

opencl/source/helpers/hardware_context_controller.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,6 +11,7 @@
1111
#include "shared/source/helpers/constants.h"
1212
#include "shared/source/os_interface/os_context.h"
1313

14+
#include "third_party/aub_stream/headers/allocation_params.h"
1415
using namespace NEO;
1516

1617
HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t flags) {
@@ -47,16 +48,22 @@ void HardwareContextController::submit(uint64_t batchBufferGpuAddress, const voi
4748
}
4849
}
4950

50-
void HardwareContextController::writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) {
51+
void HardwareContextController::writeMemory(aub_stream::AllocationParams &allocationParams) {
5152
if (hardwareContexts.size() == 1u) {
52-
hardwareContexts.at(0)->writeMemory(gfxAddress, memory, size, memoryBanks, hint, pageSize);
53+
hardwareContexts.at(0)->writeMemory2(allocationParams);
5354
return;
5455
}
56+
57+
aub_stream::AllocationParams clonedParams = allocationParams;
58+
5559
for (auto bankId = 0u; bankId < hardwareContexts.size(); bankId++) {
5660
auto &hardwareContext = hardwareContexts.at(bankId);
57-
auto selectedBank = memoryBanks & (1 << bankId);
61+
62+
auto selectedBank = allocationParams.memoryBanks & (1 << bankId);
5863
UNRECOVERABLE_IF(selectedBank == 0);
59-
hardwareContext->writeMemory(gfxAddress, memory, size, memoryBanks & (1 << bankId), hint, pageSize);
64+
65+
clonedParams.memoryBanks = selectedBank;
66+
hardwareContext->writeMemory2(clonedParams);
6067
}
6168
}
6269

opencl/source/helpers/hardware_context_controller.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -13,6 +13,7 @@
1313
#include <vector>
1414

1515
namespace NEO {
16+
struct AllocationParams;
1617
class OsContext;
1718

1819
class HardwareContextController {
@@ -24,7 +25,7 @@ class HardwareContextController {
2425
void pollForCompletion();
2526
void expectMemory(uint64_t gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
2627
void submit(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead);
27-
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize);
28+
void writeMemory(aub_stream::AllocationParams &allocationParams);
2829

2930
void dumpBufferBIN(uint64_t gfxAddress, size_t size);
3031
void dumpSurface(const aub_stream::SurfaceInfo &surfaceInfo);

opencl/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,15 +1269,15 @@ HWTEST_F(AubCsrTest, WhenWriteWithAubManagerIsCalledThenAubManagerIsInvokedWithC
12691269
aubCsr->setupContext(*osContext);
12701270

12711271
aubCsr->writeMemoryWithAubManager(*allocation);
1272-
EXPECT_TRUE(aubManager.writeMemoryCalled);
1272+
EXPECT_TRUE(aubManager.writeMemory2Called);
12731273
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceBatchBuffer, aubManager.hintToWriteMemory);
12741274

12751275
aubManager.writeMemoryCalled = false;
12761276

12771277
auto allocation2 = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, true, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
12781278

12791279
aubCsr->writeMemoryWithAubManager(*allocation2);
1280-
EXPECT_TRUE(aubManager.writeMemoryCalled);
1280+
EXPECT_TRUE(aubManager.writeMemory2Called);
12811281
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, aubManager.hintToWriteMemory);
12821282

12831283
executionEnvironment->memoryManager->freeGraphicsMemory(allocation);
@@ -1310,13 +1310,13 @@ TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenSubmitMethodIsCall
13101310
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
13111311

13121312
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
1313-
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1313+
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
13141314

13151315
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1, false);
13161316

13171317
EXPECT_TRUE(mockHwContext0->submitCalled);
13181318
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
1319-
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1319+
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
13201320
}
13211321

13221322
TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenWriteMemoryIsCalledThenWholeMemoryBanksArePassed) {
@@ -1328,9 +1328,10 @@ TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenWriteMemoryIsCalle
13281328

13291329
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
13301330

1331-
hwContextContainer.writeMemory(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
1331+
aub_stream::AllocationParams params(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
1332+
hwContextContainer.writeMemory(params);
13321333

1333-
EXPECT_TRUE(mockHwContext0->writeMemoryCalled);
1334+
EXPECT_TRUE(mockHwContext0->writeMemory2Called);
13341335
EXPECT_EQ(3u, mockHwContext0->memoryBanksPassed);
13351336
}
13361337

@@ -1353,13 +1354,17 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
13531354
EXPECT_FALSE(mockHwContext0->submitCalled);
13541355
EXPECT_FALSE(mockHwContext1->submitCalled);
13551356
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1357+
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
13561358
EXPECT_FALSE(mockHwContext1->writeMemoryCalled);
1359+
EXPECT_FALSE(mockHwContext1->writeMemory2Called);
1360+
1361+
aub_stream::AllocationParams params(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
13571362

13581363
hwContextContainer.initialize();
13591364
hwContextContainer.pollForCompletion();
13601365
hwContextContainer.expectMemory(1, reinterpret_cast<const void *>(0x123), 2, 0);
13611366
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1, false);
1362-
hwContextContainer.writeMemory(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
1367+
hwContextContainer.writeMemory(params);
13631368

13641369
EXPECT_TRUE(mockHwContext0->initializeCalled);
13651370
EXPECT_TRUE(mockHwContext1->initializeCalled);
@@ -1369,8 +1374,10 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
13691374
EXPECT_TRUE(mockHwContext1->expectMemoryCalled);
13701375
EXPECT_TRUE(mockHwContext0->submitCalled);
13711376
EXPECT_TRUE(mockHwContext1->submitCalled);
1372-
EXPECT_TRUE(mockHwContext0->writeMemoryCalled);
1373-
EXPECT_TRUE(mockHwContext1->writeMemoryCalled);
1377+
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1378+
EXPECT_TRUE(mockHwContext0->writeMemory2Called);
1379+
EXPECT_FALSE(mockHwContext1->writeMemoryCalled);
1380+
EXPECT_TRUE(mockHwContext1->writeMemory2Called);
13741381
EXPECT_EQ(1u, mockHwContext0->memoryBanksPassed);
13751382
EXPECT_EQ(2u, mockHwContext1->memoryBanksPassed);
13761383
}

opencl/test/unit_test/mocks/mock_aub_manager.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
99

10+
#include "third_party/aub_stream/headers/allocation_params.h"
1011
#include "third_party/aub_stream/headers/aub_manager.h"
1112
#include "third_party/aub_stream/headers/aubstream.h"
1213
#include "third_party/aub_stream/headers/hardware_context.h"
@@ -26,6 +27,11 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
2627
writeMemoryPageSizePassed = pageSize;
2728
memoryBanksPassed = memoryBanks;
2829
}
30+
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
31+
writeMemory2Called = true;
32+
writeMemoryPageSizePassed = allocationParams.pageSize;
33+
memoryBanksPassed = allocationParams.memoryBanks;
34+
}
2935
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
3036
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
3137
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; }
@@ -37,6 +43,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
3743
bool writeAndSubmitCalled = false;
3844
bool submitCalled = false;
3945
bool writeMemoryCalled = false;
46+
bool writeMemory2Called = false;
4047
bool freeMemoryCalled = false;
4148
bool expectMemoryCalled = false;
4249
bool readMemoryCalled = false;
@@ -103,6 +110,12 @@ class MockAubManager : public aub_stream::AubManager {
103110
writeMemoryPageSizePassed = pageSize;
104111
}
105112

113+
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
114+
writeMemory2Called = true;
115+
hintToWriteMemory = allocationParams.hint;
116+
writeMemoryPageSizePassed = allocationParams.pageSize;
117+
}
118+
106119
void writePageTableEntries(uint64_t gfxAddress, size_t size, uint32_t memoryBanks, int hint,
107120
std::vector<PageInfo> &lastLevelPages, size_t pageSize) override {
108121
writePageTableEntriesCalled = true;
@@ -125,6 +138,7 @@ class MockAubManager : public aub_stream::AubManager {
125138
bool addCommentCalled = false;
126139
std::string receivedComment = "";
127140
bool writeMemoryCalled = false;
141+
bool writeMemory2Called = false;
128142
bool writePageTableEntriesCalled = false;
129143
bool writePhysicalMemoryPagesCalled = false;
130144
bool freeMemoryCalled = false;

shared/source/os_interface/aub_memory_operations_handler.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -10,6 +10,8 @@
1010
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
1111
#include "shared/source/memory_manager/graphics_allocation.h"
1212

13+
#include "third_party/aub_stream/headers/allocation_params.h"
14+
1315
#include <algorithm>
1416

1517
namespace NEO {
@@ -25,12 +27,12 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device,
2527
auto lock = acquireLock(resourcesLock);
2628
int hint = AubMemDump::DataTypeHintValues::TraceNotype;
2729
for (const auto &allocation : gfxAllocations) {
28-
aubManager->writeMemory(allocation->getGpuAddress(),
29-
allocation->getUnderlyingBuffer(),
30-
allocation->getUnderlyingBufferSize(),
31-
allocation->storageInfo.getMemoryBanks(),
32-
hint,
33-
allocation->getUsedPageSize());
30+
aubManager->writeMemory2({allocation->getGpuAddress(),
31+
allocation->getUnderlyingBuffer(),
32+
allocation->getUnderlyingBufferSize(),
33+
allocation->storageInfo.getMemoryBanks(),
34+
hint,
35+
allocation->getUsedPageSize()});
3436
residentAllocations.push_back(allocation);
3537
}
3638
return MemoryOperationsStatus::SUCCESS;

shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -24,7 +24,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThe
2424
auto memoryOperationsInterface = getMemoryOperationsHandler();
2525
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
2626
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
27-
EXPECT_TRUE(aubManager.writeMemoryCalled);
27+
EXPECT_TRUE(aubManager.writeMemory2Called);
2828
}
2929

3030
TEST_F(AubMemoryOperationsHandlerTests, givenAllocationWhenMakeResidentCalledThenTraceNotypeHintReturned) {
@@ -63,4 +63,4 @@ TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenEvictCalledTh
6363
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
6464
auto result = memoryOperationsInterface->evict(nullptr, allocation);
6565
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
66-
}
66+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include <cstddef>
10+
#include <cstdint>
11+
12+
namespace aub_stream {
13+
14+
struct AllocationParams {
15+
AllocationParams() = delete;
16+
AllocationParams(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize)
17+
: gfxAddress(gfxAddress), size(size), pageSize(pageSize), memoryBanks(memoryBanks), hint(hint), memory(memory) {
18+
}
19+
uint64_t gfxAddress = 0;
20+
size_t size = 0;
21+
size_t pageSize;
22+
uint32_t memoryBanks;
23+
int hint = 0;
24+
const void *memory = nullptr;
25+
26+
struct AdditionalParams {
27+
bool compressionEnabled = false;
28+
} additionalParams;
29+
};
30+
31+
} // namespace aub_stream

third_party/aub_stream/headers/aub_manager.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77

88
#pragma once
9+
#include "page_info.h"
10+
911
#include <cstdint>
1012
#include <string>
1113
#include <vector>
12-
#include "page_info.h"
1314

1415
namespace aub_stream {
1516

17+
struct AllocationParams;
1618
struct HardwareContext;
1719

1820
class AubManager {
@@ -28,7 +30,7 @@ class AubManager {
2830
virtual void pause(bool onoff) = 0;
2931

3032
virtual void addComment(const char *message) = 0;
31-
virtual void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks,int hint, size_t pageSize) = 0;
33+
virtual void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) = 0;
3234
virtual void writePageTableEntries(uint64_t gfxAddress, size_t size, uint32_t memoryBanks, int hint,
3335
std::vector<PageInfo> &lastLevelPages, size_t pageSize) = 0;
3436

@@ -37,6 +39,8 @@ class AubManager {
3739

3840
static AubManager *create(uint32_t productFamily, uint32_t devicesCount, uint64_t memoryBankSize, uint32_t stepping,
3941
bool localMemorySupported, uint32_t streamMode, uint64_t gpuAddressSpace);
42+
43+
virtual void writeMemory2(AllocationParams allocationParams) = 0;
4044
};
4145

4246
} // namespace aub_stream

third_party/aub_stream/headers/hardware_context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
*/
77

88
#pragma once
9-
#include <cstdint>
109
#include <cstddef>
10+
#include <cstdint>
1111

1212
namespace aub_stream {
1313

14+
struct AllocationParams;
1415
struct SurfaceInfo;
1516

1617
struct HardwareContext {
@@ -25,6 +26,7 @@ struct HardwareContext {
2526
virtual void dumpBufferBIN(uint64_t gfxAddress, size_t size) = 0;
2627
virtual void dumpSurface(const SurfaceInfo &surfaceInfo) = 0;
2728
virtual ~HardwareContext() = default;
29+
virtual void writeMemory2(AllocationParams allocationParams) = 0;
2830
};
2931

3032
} // namespace aub_stream

0 commit comments

Comments
 (0)