Skip to content

Commit 1cf110b

Browse files
committed
Copy and use compute-runtime experimental headers
1 parent 3dd399b commit 1cf110b

22 files changed

+1593
-3
lines changed

unified-runtime/source/adapters/level_zero/platform.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#pragma once
1111

1212
#include "common.hpp"
13-
#include "level_zero/driver_experimental/zex_api.h"
13+
#include "runtime/driver_experimental/zex_graph.h"
1414
#include "ur_api.h"
1515
#include "ze_api.h"
1616
#include "ze_ddi.h"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This subdirectory contains a copy of Level Zero experimental headers.
2+
Repo: https://github.com/intel/compute-runtime
3+
Tag: 25.44.36015.5
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <level_zero/ze_api.h>
11+
12+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListGetNextCommandIdExpCb_t)(
13+
ze_command_list_handle_t hCommandList,
14+
const ze_mutable_command_id_exp_desc_t *desc,
15+
uint64_t *pCommandId);
16+
17+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListUpdateMutableCommandsExpCb_t)(
18+
ze_command_list_handle_t hCommandList,
19+
const ze_mutable_commands_exp_desc_t *desc);
20+
21+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t)(
22+
ze_command_list_handle_t hCommandList,
23+
uint64_t commandId,
24+
ze_event_handle_t hSignalEvent);
25+
26+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t)(
27+
ze_command_list_handle_t hCommandList,
28+
uint64_t commandId,
29+
uint32_t numWaitEvents,
30+
ze_event_handle_t *phWaitEvents);
31+
32+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t)(
33+
ze_command_list_handle_t hCommandList,
34+
const ze_mutable_command_id_exp_desc_t *desc,
35+
uint32_t numKernels,
36+
ze_kernel_handle_t *phKernels,
37+
uint64_t *pCommandId);
38+
39+
typedef ze_result_t(ZE_APICALL *ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t)(
40+
ze_command_list_handle_t hCommandList,
41+
uint32_t numKernels,
42+
uint64_t *pCommandId,
43+
ze_kernel_handle_t *phKernels);
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "level_zero/ze_stypes.h"
11+
#include <level_zero/ze_api.h>
12+
13+
///////////////////////////////////////////////////////////////////////////////
14+
/// @brief Label handle.
15+
typedef struct _zex_label_handle_t *zex_label_handle_t;
16+
17+
///////////////////////////////////////////////////////////////////////////////
18+
/// @brief Label descriptor.
19+
typedef struct _zex_label_desc_t {
20+
ze_structure_type_ext_t stype = ZEX_STRUCTURE_TYPE_LABEL_DESCRIPTOR; ///< [in] type of this structure
21+
const void *pNext = nullptr; ///< [in][optional] pointer to extension-specific structure
22+
23+
const char *name; ///< [in][optional] null-terminated name of the label
24+
uint32_t alignment; ///< [in][optional] minimum alignment of the label
25+
} zex_label_desc_t;
26+
27+
///////////////////////////////////////////////////////////////////////////////
28+
/// @brief Operand flags
29+
typedef uint32_t zex_operand_flags_t;
30+
typedef enum _zex_operand_flag_t {
31+
ZEX_OPERAND_FLAG_USES_VARIABLE = ZE_BIT(0), // variable is being used - passed via memory
32+
ZEX_OPERAND_FLAG_JUMP_ON_CLEAR = ZE_BIT(1) // jump on '0', instead of default '1'
33+
} zex_operand_flag_t;
34+
35+
///////////////////////////////////////////////////////////////////////////////
36+
/// @brief Operand descriptor.
37+
typedef struct _zex_operand_desc_t {
38+
ze_structure_type_ext_t stype = ZEX_STRUCTURE_TYPE_OPERAND_DESCRIPTOR; ///< [in] type of this structure
39+
const void *pNext = nullptr; ///< [in][optional] pointer to extension-specific structure
40+
41+
void *memory; // if memory is NULL then offset is interpreted as MMIO
42+
// if flag ZEX_OPERAND_FLAG_USES_VARIABLE is set memory is interpreted as variable
43+
size_t offset; // offset within memory or register MMIO
44+
uint32_t size; // operand size - dword
45+
zex_operand_flags_t flags; // flags
46+
} zex_operand_desc_t;
47+
48+
#if defined(__cplusplus)
49+
extern "C" {
50+
#endif
51+
///////////////////////////////////////////////////////////////////////////////
52+
/// @brief Creates/returns label based on name provided in
53+
/// label descriptor.
54+
///
55+
/// @details
56+
/// - When label with the name provided in label descriptor does not
57+
/// exist new label is created.
58+
/// - If label with provided name exists it's returned.
59+
/// - Label at creation is undefined (points to nothing).
60+
///
61+
/// @returns
62+
/// - ZE_RESULT_SUCCESS
63+
/// - ZE_RESULT_ERROR_INVALID_ARGUMENT
64+
/// + nullptr == hCommandList
65+
/// + nullptr == pLabelDesc
66+
/// + nullptr == phLabel
67+
/// + pLabelDesc->alignment & (pLabelDesc->alignment - 1) != 0
68+
/// - ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY
69+
/// + bad_alloc
70+
ze_result_t ZE_APICALL
71+
zexCommandListGetLabel(
72+
ze_command_list_handle_t hCommandList, ///< [in] handle of command list
73+
const zex_label_desc_t *pLabelDesc, ///< [in] pointer to label descriptor
74+
zex_label_handle_t *phLabel ///< [out] pointer to handle of label
75+
);
76+
77+
///////////////////////////////////////////////////////////////////////////////
78+
/// @brief Sets label to point to current location in command list.
79+
///
80+
/// @details
81+
/// - Sets label address to current location.
82+
/// - All previous jumps to this label are patched with label's address.
83+
/// - Future jumps to this label will be patched with label's address.
84+
/// - Label can be set only once.
85+
/// - Label must be located in the same command list, as it was created
86+
///
87+
/// @returns
88+
/// - ZE_RESULT_SUCCESS
89+
/// - ZE_RESULT_ERROR_INVALID_ARGUMENT
90+
/// + nullptr == hCommandList
91+
/// + nullptr == hLabel
92+
/// - ZE_RESULT_ERROR_UNSUPPORTED_FEATURE
93+
/// + variable already set
94+
/// - ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT
95+
/// + label's address is not aligned to it's alignment
96+
ze_result_t ZE_APICALL
97+
zexCommandListSetLabel(
98+
ze_command_list_handle_t hCommandList, ///< [in] handle of command list
99+
zex_label_handle_t hLabel ///< [in] handle of label
100+
);
101+
102+
///////////////////////////////////////////////////////////////////////////////
103+
/// @brief Appends jump to label predicated by condition.
104+
///
105+
/// @details
106+
/// If condition is present:
107+
/// If condition->memory is present:
108+
/// If ZEX_OPERAND_FLAG_USES_VARIABLE flag is set:
109+
/// - Append MI_LOAD_REGISTER_MEM
110+
/// reg = PREDICATE_RESULT_2
111+
/// memAddr = gpu address of buffer variable
112+
/// Else:
113+
/// - Append MI_LOAD_REGISTER_MEM
114+
/// reg = PREDICATE_RESULT_2
115+
/// memAddr = pCondition->memory + pCondition->offset
116+
/// Else:
117+
/// - Append MI_LOAD_REGISTER_REG
118+
/// regDst = PREDICATE_RESULT_2
119+
/// regSrc = pCondition->offset (need to pass MMIO)
120+
///
121+
/// If ZEX_OPERAND_FLAG_JUMP_ON_CLEAR flag is set: // jumps when '0'
122+
/// - Append MI_SET_PREDICATE(ENABLE_ON_SET)
123+
/// Else: // jumps when '1'
124+
/// - Append MI_SET_PREDICATE(ENABLE_ON_CLEAR)
125+
///
126+
/// - Append MI_BATCH_BUFFER_START
127+
/// predicationEnabled = condition is present
128+
/// jumpAddress = label's address
129+
/// - Append MI_SET_PREDICATE(DISABLE) - after BB_START
130+
/// - Append MI_SET_PREDICATE(DISABLE) - at label's address
131+
///
132+
/// @returns
133+
/// - ZE_RESULT_SUCCESS
134+
/// - ZE_RESULT_ERROR_INVALID_ARGUMENT
135+
/// + nullptr == hCommandList
136+
/// + nullptr == hLabel
137+
ze_result_t ZE_APICALL
138+
zexCommandListAppendJump(
139+
ze_command_list_handle_t hCommandList, ///< [in] handle of command list
140+
zex_label_handle_t hLabel, ///< [in] handle of label
141+
zex_operand_desc_t *pCondition ///< [in][opt] pointer to operand
142+
);
143+
144+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListGetLabelCb_t)(
145+
ze_command_list_handle_t hCommandList,
146+
const zex_label_desc_t *pLabelDesc,
147+
zex_label_handle_t *phLabel);
148+
149+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListSetLabelCb_t)(
150+
ze_command_list_handle_t hCommandList,
151+
zex_label_handle_t hLabel);
152+
153+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListAppendJumpCb_t)(
154+
ze_command_list_handle_t hCommandList,
155+
zex_label_handle_t hLabel,
156+
zex_operand_desc_t *pCondition);
157+
158+
#if defined(__cplusplus)
159+
} // extern "C"
160+
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_variable_ext.h"
11+
#include <level_zero/ze_api.h>
12+
13+
#if defined(__cplusplus)
14+
extern "C" {
15+
#endif
16+
///////////////////////////////////////////////////////////////////////////////
17+
/// @brief Sets kernel group size to provided variable.
18+
ze_result_t ZE_APICALL
19+
zexKernelSetVariableGroupSize(
20+
ze_kernel_handle_t hKernel, ///< [in] handle of kernel
21+
zex_variable_handle_t hGroupSizeVariable ///< [in] handle of variable
22+
);
23+
24+
///////////////////////////////////////////////////////////////////////////////
25+
/// @brief Appends kernel launch to command list with variable group size.
26+
ze_result_t ZE_APICALL
27+
zexCommandListAppendVariableLaunchKernel(
28+
ze_command_list_handle_t hCommandList, ///< [in] hnadle of mutable command list
29+
ze_kernel_handle_t hKernel, ///< [in] handle of kernel
30+
zex_variable_handle_t hGroupCountVariable, ///< [in] handle of variable
31+
ze_event_handle_t hSignalEvent, ///< [in] handle to signal event
32+
uint32_t numWaitEvents, ///< [in] num events to wait for
33+
ze_event_handle_t *phWaitEvents); ///< [in] array of events to wait for
34+
35+
typedef ze_result_t(ZE_APICALL *zex_pfnKernelSetVariableGroupSizeCb_t)(
36+
ze_kernel_handle_t hKernel,
37+
zex_variable_handle_t hGroupSizeVariable);
38+
39+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListAppendVariableLaunchKernelCb_t)(
40+
ze_command_list_handle_t hCommandList,
41+
ze_kernel_handle_t hKernel,
42+
zex_variable_handle_t hGroupCountVariable,
43+
ze_event_handle_t hSignalEvent,
44+
uint32_t numWaitEvents,
45+
ze_event_handle_t *phWaitEvents);
46+
47+
#if defined(__cplusplus)
48+
} // extern "C"
49+
#endif
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "level_zero/driver_experimental/mcl_ext/ze_mutable_command_list_exp.h"
11+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_control_flow_ext.h"
12+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_dispatch_ext.h"
13+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_serialization_ext.h"
14+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_temp_mem_ext.h"
15+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_variable_ext.h"
16+
#include "level_zero/driver_experimental/mcl_ext/zex_mutable_cmdlist_variable_info_ext.h"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <level_zero/ze_api.h>
11+
12+
#if defined(__cplusplus)
13+
extern "C" {
14+
#endif
15+
///////////////////////////////////////////////////////////////////////////////
16+
/// @brief Retrieve native MCL binary from cmdlist.
17+
ze_result_t ZE_APICALL
18+
zexCommandListGetNativeBinary(
19+
ze_command_list_handle_t hCommandList, ///< [in] handle of mutable command list
20+
void *pBinary, ///< [in,out][optional] byte pointer to native MCL binary
21+
size_t *pBinarySize, ///< [in,out] size of native MCL binary in bytes
22+
const void *pModule, ///< [in] byte pointer to module containing kernels' used in cmdlist
23+
size_t moduleSize ///< [in] size in bytes of module containing kernels's used in cmdlist
24+
);
25+
26+
///////////////////////////////////////////////////////////////////////////////
27+
/// @brief Load command list from native MCL binary.
28+
ze_result_t ZE_APICALL
29+
zexCommandListLoadNativeBinary(
30+
ze_command_list_handle_t hCommandList, ///< [in] handle of mutable command list
31+
const void *pBinary, ///< [in] byte pointer to native MCL binary
32+
size_t binarySize ///< [in] size of native MCL binary in bytes
33+
);
34+
35+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListGetNativeBinaryCb_t)(
36+
ze_command_list_handle_t hCommandList,
37+
void *pBinary,
38+
size_t *pBinarySize,
39+
const void *pModule,
40+
size_t moduleSize);
41+
42+
typedef ze_result_t(ZE_APICALL *zex_pfnCommandListLoadNativeBinaryCb_t)(
43+
ze_command_list_handle_t hCommandList,
44+
const void *pBinary,
45+
size_t binarySize);
46+
47+
#if defined(__cplusplus)
48+
} // extern "C"
49+
#endif

0 commit comments

Comments
 (0)