File: host_function.inl

package info (click to toggle)
intel-compute-runtime 25.44.36015.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,632 kB
  • sloc: cpp: 931,547; lisp: 2,074; sh: 719; makefile: 162; python: 21
file content (84 lines) | stat: -rw-r--r-- 5,039 bytes parent folder | download
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
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (C) 2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/host_function.h"
#include "shared/source/memory_manager/multi_graphics_allocation.h"

namespace NEO {

template <typename GfxFamily>
void HostFunctionHelper::programHostFunction(LinearStream &commandStream, const HostFunctionData &hostFunctionData, uint64_t userHostFunctionAddress, uint64_t userDataAddress) {

    HostFunctionHelper::programHostFunctionAddress<GfxFamily>(&commandStream, nullptr, hostFunctionData, userHostFunctionAddress);
    HostFunctionHelper::programHostFunctionUserData<GfxFamily>(&commandStream, nullptr, hostFunctionData, userDataAddress);
    HostFunctionHelper::programSignalHostFunctionStart<GfxFamily>(&commandStream, nullptr, hostFunctionData);
    HostFunctionHelper::programWaitForHostFunctionCompletion<GfxFamily>(&commandStream, nullptr, hostFunctionData);
}

template <typename GfxFamily>
void HostFunctionHelper::programHostFunctionAddress(LinearStream *commandStream, void *cmdBuffer, const HostFunctionData &hostFunctionData, uint64_t userHostFunctionAddress) {
    using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM;

    auto hostFunctionAddressDst = reinterpret_cast<uint64_t>(hostFunctionData.entry);

    EncodeStoreMemory<GfxFamily>::programStoreDataImmCommand(commandStream,
                                                             static_cast<MI_STORE_DATA_IMM *>(cmdBuffer),
                                                             hostFunctionAddressDst,
                                                             getLowPart(userHostFunctionAddress),
                                                             getHighPart(userHostFunctionAddress),
                                                             true,
                                                             false);
}

template <typename GfxFamily>
void HostFunctionHelper::programHostFunctionUserData(LinearStream *commandStream, void *cmdBuffer, const HostFunctionData &hostFunctionData, uint64_t userDataAddress) {
    using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM;

    auto userDataAddressDst = reinterpret_cast<uint64_t>(hostFunctionData.userData);

    EncodeStoreMemory<GfxFamily>::programStoreDataImmCommand(commandStream,
                                                             static_cast<MI_STORE_DATA_IMM *>(cmdBuffer),
                                                             userDataAddressDst,
                                                             getLowPart(userDataAddress),
                                                             getHighPart(userDataAddress),
                                                             true,
                                                             false);
}

template <typename GfxFamily>
void HostFunctionHelper::programSignalHostFunctionStart(LinearStream *commandStream, void *cmdBuffer, const HostFunctionData &hostFunctionData) {
    using MI_STORE_DATA_IMM = typename GfxFamily::MI_STORE_DATA_IMM;

    auto internalTagAddress = reinterpret_cast<uint64_t>(hostFunctionData.internalTag);
    EncodeStoreMemory<GfxFamily>::programStoreDataImmCommand(commandStream,
                                                             static_cast<MI_STORE_DATA_IMM *>(cmdBuffer),
                                                             internalTagAddress,
                                                             static_cast<uint32_t>(HostFunctionTagStatus::pending),
                                                             0u,
                                                             false,
                                                             false);
}

template <typename GfxFamily>
void HostFunctionHelper::programWaitForHostFunctionCompletion(LinearStream *commandStream, void *cmdBuffer, const HostFunctionData &hostFunctionData) {
    using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;

    auto internalTagAddress = reinterpret_cast<uint64_t>(hostFunctionData.internalTag);
    EncodeSemaphore<GfxFamily>::programMiSemaphoreWaitCommand(commandStream,
                                                              static_cast<MI_SEMAPHORE_WAIT *>(cmdBuffer),
                                                              internalTagAddress,
                                                              static_cast<uint32_t>(HostFunctionTagStatus::completed),
                                                              GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_EQUAL_SDD,
                                                              false,
                                                              true,
                                                              false,
                                                              false,
                                                              false);
}

} // namespace NEO