File: flat_batch_buffer_helper.cpp

package info (click to toggle)
intel-compute-runtime 22.43.24595.41-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,740 kB
  • sloc: cpp: 631,142; lisp: 3,515; sh: 470; makefile: 76; python: 21
file content (70 lines) | stat: -rw-r--r-- 2,632 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (C) 2018-2020 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/helpers/flat_batch_buffer_helper.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.insert(std::pair<uint64_t, uint64_t>(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