-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathflat_batch_buffer_helper.cpp
72 lines (61 loc) · 2.66 KB
/
flat_batch_buffer_helper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/flat_batch_buffer_helper.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/command_stream/submissions_aggregator.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/memory_manager/graphics_allocation.h"
namespace NEO {
bool FlatBatchBufferHelper::setPatchInfoData(const PatchInfoData &data) {
patchInfoCollection.push_back(data);
return true;
}
bool FlatBatchBufferHelper::removePatchInfoData(uint64_t targetLocation) {
for (auto it = patchInfoCollection.begin(); it != patchInfoCollection.end(); ++it) {
if (it->targetAllocation + it->targetAllocationOffset == targetLocation) {
patchInfoCollection.erase(it);
break;
}
}
return true;
}
bool FlatBatchBufferHelper::registerCommandChunk(uint64_t baseCpu, uint64_t baseGpu, uint64_t startOffset, uint64_t endOffset) {
CommandChunk commandChunk;
commandChunk.baseAddressGpu = baseGpu;
commandChunk.baseAddressCpu = baseCpu;
commandChunk.startOffset = startOffset;
commandChunk.endOffset = endOffset;
return registerCommandChunk(commandChunk);
}
bool FlatBatchBufferHelper::registerCommandChunk(BatchBuffer &batchBuffer, size_t batchBufferStartCommandSize) {
CommandChunk commandChunk;
commandChunk.baseAddressGpu = batchBuffer.stream->getGraphicsAllocation()->getGpuAddress();
commandChunk.baseAddressCpu = reinterpret_cast<uint64_t>(batchBuffer.stream->getCpuBase());
commandChunk.startOffset = batchBuffer.startOffset;
commandChunk.endOffset = batchBuffer.chainedBatchBufferStartOffset + batchBufferStartCommandSize;
return registerCommandChunk(commandChunk);
}
bool FlatBatchBufferHelper::registerCommandChunk(CommandChunk &commandChunk) {
commandChunkList.push_back(commandChunk);
return true;
}
bool FlatBatchBufferHelper::registerBatchBufferStartAddress(uint64_t commandAddress, uint64_t startAddress) {
batchBufferStartAddressSequence.emplace(commandAddress, startAddress);
return true;
}
void FlatBatchBufferHelper::fixCrossThreadDataInfo(std::vector<PatchInfoData> &data, size_t offsetCrossThreadData, uint64_t gpuAddress) {
for (auto &patchInfoData : data) {
if (patchInfoData.sourceType == PatchInfoAllocationType::kernelArg) {
patchInfoData.targetAllocation = gpuAddress;
patchInfoData.targetAllocationOffset += offsetCrossThreadData;
}
}
}
MemoryManager *FlatBatchBufferHelper::getMemoryManager() const {
return executionEnvironment.memoryManager.get();
}
}; // namespace NEO