aub_stream interfaces update

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-02-16 10:20:34 +00:00
committed by Compute-Runtime-Automation
parent 6dd0f0c728
commit 584da13ff8
11 changed files with 110 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,8 @@
#include "opencl/source/command_stream/command_stream_receiver_simulated_common_hw.h"
#include "third_party/aub_stream/headers/allocation_params.h"
namespace NEO {
class GraphicsAllocation;
template <typename GfxFamily>
@@ -55,8 +57,10 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo
? AubMemDump::DataTypeHintValues::TraceBatchBuffer
: AubMemDump::DataTypeHintValues::TraceNotype;
auto pageSize = graphicsAllocation.getUsedPageSize();
this->aubManager->writeMemory(gpuAddress, cpuAddress, size, this->getMemoryBank(&graphicsAllocation), hint, pageSize);
aub_stream::AllocationParams allocationParams(gpuAddress, cpuAddress, size, this->getMemoryBank(&graphicsAllocation),
hint, graphicsAllocation.getUsedPageSize());
this->aubManager->writeMemory2(allocationParams);
}
void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) override {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,7 @@
#include "shared/source/helpers/constants.h"
#include "shared/source/os_interface/os_context.h"
#include "third_party/aub_stream/headers/allocation_params.h"
using namespace NEO;
HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t flags) {
@@ -47,16 +48,22 @@ void HardwareContextController::submit(uint64_t batchBufferGpuAddress, const voi
}
}
void HardwareContextController::writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) {
void HardwareContextController::writeMemory(aub_stream::AllocationParams &allocationParams) {
if (hardwareContexts.size() == 1u) {
hardwareContexts.at(0)->writeMemory(gfxAddress, memory, size, memoryBanks, hint, pageSize);
hardwareContexts.at(0)->writeMemory2(allocationParams);
return;
}
aub_stream::AllocationParams clonedParams = allocationParams;
for (auto bankId = 0u; bankId < hardwareContexts.size(); bankId++) {
auto &hardwareContext = hardwareContexts.at(bankId);
auto selectedBank = memoryBanks & (1 << bankId);
auto selectedBank = allocationParams.memoryBanks & (1 << bankId);
UNRECOVERABLE_IF(selectedBank == 0);
hardwareContext->writeMemory(gfxAddress, memory, size, memoryBanks & (1 << bankId), hint, pageSize);
clonedParams.memoryBanks = selectedBank;
hardwareContext->writeMemory2(clonedParams);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -13,6 +13,7 @@
#include <vector>
namespace NEO {
struct AllocationParams;
class OsContext;
class HardwareContextController {
@@ -24,7 +25,7 @@ class HardwareContextController {
void pollForCompletion();
void expectMemory(uint64_t gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
void submit(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead);
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize);
void writeMemory(aub_stream::AllocationParams &allocationParams);
void dumpBufferBIN(uint64_t gfxAddress, size_t size);
void dumpSurface(const aub_stream::SurfaceInfo &surfaceInfo);

View File

@@ -1269,7 +1269,7 @@ HWTEST_F(AubCsrTest, WhenWriteWithAubManagerIsCalledThenAubManagerIsInvokedWithC
aubCsr->setupContext(*osContext);
aubCsr->writeMemoryWithAubManager(*allocation);
EXPECT_TRUE(aubManager.writeMemoryCalled);
EXPECT_TRUE(aubManager.writeMemory2Called);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceBatchBuffer, aubManager.hintToWriteMemory);
aubManager.writeMemoryCalled = false;
@@ -1277,7 +1277,7 @@ HWTEST_F(AubCsrTest, WhenWriteWithAubManagerIsCalledThenAubManagerIsInvokedWithC
auto allocation2 = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, true, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
aubCsr->writeMemoryWithAubManager(*allocation2);
EXPECT_TRUE(aubManager.writeMemoryCalled);
EXPECT_TRUE(aubManager.writeMemory2Called);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, aubManager.hintToWriteMemory);
executionEnvironment->memoryManager->freeGraphicsMemory(allocation);
@@ -1310,13 +1310,13 @@ TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenSubmitMethodIsCall
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1, false);
EXPECT_TRUE(mockHwContext0->submitCalled);
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
}
TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenWriteMemoryIsCalledThenWholeMemoryBanksArePassed) {
@@ -1328,9 +1328,10 @@ TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenWriteMemoryIsCalle
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
hwContextContainer.writeMemory(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
aub_stream::AllocationParams params(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
hwContextContainer.writeMemory(params);
EXPECT_TRUE(mockHwContext0->writeMemoryCalled);
EXPECT_TRUE(mockHwContext0->writeMemory2Called);
EXPECT_EQ(3u, mockHwContext0->memoryBanksPassed);
}
@@ -1353,13 +1354,17 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
EXPECT_FALSE(mockHwContext0->submitCalled);
EXPECT_FALSE(mockHwContext1->submitCalled);
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
EXPECT_FALSE(mockHwContext0->writeMemory2Called);
EXPECT_FALSE(mockHwContext1->writeMemoryCalled);
EXPECT_FALSE(mockHwContext1->writeMemory2Called);
aub_stream::AllocationParams params(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
hwContextContainer.initialize();
hwContextContainer.pollForCompletion();
hwContextContainer.expectMemory(1, reinterpret_cast<const void *>(0x123), 2, 0);
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1, false);
hwContextContainer.writeMemory(1, reinterpret_cast<const void *>(0x123), 2, 3u, 4, 5);
hwContextContainer.writeMemory(params);
EXPECT_TRUE(mockHwContext0->initializeCalled);
EXPECT_TRUE(mockHwContext1->initializeCalled);
@@ -1369,8 +1374,10 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
EXPECT_TRUE(mockHwContext1->expectMemoryCalled);
EXPECT_TRUE(mockHwContext0->submitCalled);
EXPECT_TRUE(mockHwContext1->submitCalled);
EXPECT_TRUE(mockHwContext0->writeMemoryCalled);
EXPECT_TRUE(mockHwContext1->writeMemoryCalled);
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
EXPECT_TRUE(mockHwContext0->writeMemory2Called);
EXPECT_FALSE(mockHwContext1->writeMemoryCalled);
EXPECT_TRUE(mockHwContext1->writeMemory2Called);
EXPECT_EQ(1u, mockHwContext0->memoryBanksPassed);
EXPECT_EQ(2u, mockHwContext1->memoryBanksPassed);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#pragma once
#include "third_party/aub_stream/headers/allocation_params.h"
#include "third_party/aub_stream/headers/aub_manager.h"
#include "third_party/aub_stream/headers/aubstream.h"
#include "third_party/aub_stream/headers/hardware_context.h"
@@ -26,6 +27,11 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
writeMemoryPageSizePassed = pageSize;
memoryBanksPassed = memoryBanks;
}
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
writeMemory2Called = true;
writeMemoryPageSizePassed = allocationParams.pageSize;
memoryBanksPassed = allocationParams.memoryBanks;
}
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
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 {
bool writeAndSubmitCalled = false;
bool submitCalled = false;
bool writeMemoryCalled = false;
bool writeMemory2Called = false;
bool freeMemoryCalled = false;
bool expectMemoryCalled = false;
bool readMemoryCalled = false;
@@ -103,6 +110,12 @@ class MockAubManager : public aub_stream::AubManager {
writeMemoryPageSizePassed = pageSize;
}
void writeMemory2(aub_stream::AllocationParams allocationParams) override {
writeMemory2Called = true;
hintToWriteMemory = allocationParams.hint;
writeMemoryPageSizePassed = allocationParams.pageSize;
}
void writePageTableEntries(uint64_t gfxAddress, size_t size, uint32_t memoryBanks, int hint,
std::vector<PageInfo> &lastLevelPages, size_t pageSize) override {
writePageTableEntriesCalled = true;
@@ -125,6 +138,7 @@ class MockAubManager : public aub_stream::AubManager {
bool addCommentCalled = false;
std::string receivedComment = "";
bool writeMemoryCalled = false;
bool writeMemory2Called = false;
bool writePageTableEntriesCalled = false;
bool writePhysicalMemoryPagesCalled = false;
bool freeMemoryCalled = false;