File: ze_context_api_entrypoints.h

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 (215 lines) | stat: -rw-r--r-- 6,325 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
 * Copyright (C) 2020-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include "level_zero/core/source/context/context.h"
#include "level_zero/core/source/driver/driver_handle.h"
#include "level_zero/ze_intel_gpu.h"
#include <level_zero/ze_api.h>

namespace L0 {
ze_result_t ZE_APICALL zeContextCreate(
    ze_driver_handle_t hDriver,
    const ze_context_desc_t *desc,
    ze_context_handle_t *phContext) {
    return L0::DriverHandle::fromHandle(hDriver)->createContext(desc, 0u, nullptr, phContext);
}

ze_result_t ZE_APICALL zeContextCreateEx(
    ze_driver_handle_t hDriver,
    const ze_context_desc_t *desc,
    uint32_t numDevices,
    ze_device_handle_t *phDevices,
    ze_context_handle_t *phContext) {
    return L0::DriverHandle::fromHandle(hDriver)->createContext(desc, numDevices, phDevices, phContext);
}

ze_result_t ZE_APICALL zeContextDestroy(ze_context_handle_t hContext) {
    return L0::Context::fromHandle(hContext)->destroy();
}

ze_result_t ZE_APICALL zeContextGetStatus(ze_context_handle_t hContext) {
    return L0::Context::fromHandle(hContext)->getStatus();
}

ze_result_t ZE_APICALL zeVirtualMemReserve(
    ze_context_handle_t hContext,
    const void *pStart,
    size_t size,
    void **pptr) {
    return L0::Context::fromHandle(hContext)->reserveVirtualMem(pStart, size, pptr);
}

ze_result_t ZE_APICALL zeVirtualMemFree(
    ze_context_handle_t hContext,
    const void *ptr,
    size_t size) {
    return L0::Context::fromHandle(hContext)->freeVirtualMem(ptr, size);
}

ze_result_t ZE_APICALL zeVirtualMemQueryPageSize(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    size_t size,
    size_t *pagesize) {
    return L0::Context::fromHandle(hContext)->queryVirtualMemPageSize(hDevice, size, pagesize);
}

ze_result_t ZE_APICALL zePhysicalMemCreate(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    ze_physical_mem_desc_t *desc,
    ze_physical_mem_handle_t *phPhysicalMemory) {
    return L0::Context::fromHandle(hContext)->createPhysicalMem(hDevice, desc, phPhysicalMemory);
}

ze_result_t ZE_APICALL zePhysicalMemDestroy(
    ze_context_handle_t hContext,
    ze_physical_mem_handle_t hPhysicalMemory) {
    return L0::Context::fromHandle(hContext)->destroyPhysicalMem(hPhysicalMemory);
}

ze_result_t ZE_APICALL zeVirtualMemMap(
    ze_context_handle_t hContext,
    const void *ptr,
    size_t size,
    ze_physical_mem_handle_t hPhysicalMemory,
    size_t offset,
    ze_memory_access_attribute_t access) {
    return L0::Context::fromHandle(hContext)->mapVirtualMem(ptr, size, hPhysicalMemory, offset, access);
}

ze_result_t ZE_APICALL zeVirtualMemUnmap(
    ze_context_handle_t hContext,
    const void *ptr,
    size_t size) {
    return L0::Context::fromHandle(hContext)->unMapVirtualMem(ptr, size);
}

ze_result_t ZE_APICALL zeVirtualMemSetAccessAttribute(
    ze_context_handle_t hContext,
    const void *ptr,
    size_t size,
    ze_memory_access_attribute_t access) {
    return L0::Context::fromHandle(hContext)->setVirtualMemAccessAttribute(ptr, size, access);
}

ze_result_t ZE_APICALL zeVirtualMemGetAccessAttribute(
    ze_context_handle_t hContext,
    const void *ptr,
    size_t size,
    ze_memory_access_attribute_t *access,
    size_t *outSize) {
    return L0::Context::fromHandle(hContext)->getVirtualMemAccessAttribute(ptr, size, access, outSize);
}

ze_result_t ZE_APICALL zeContextSystemBarrier(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice) {
    return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ze_result_t ZE_APICALL zeContextMakeMemoryResident(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    void *ptr,
    size_t size) {
    return L0::Context::fromHandle(hContext)->makeMemoryResident(hDevice, ptr, size);
}

ze_result_t ZE_APICALL zeContextEvictMemory(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    void *ptr,
    size_t size) {
    return L0::Context::fromHandle(hContext)->evictMemory(hDevice, ptr, size);
}

ze_result_t ZE_APICALL zeContextMakeImageResident(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    ze_image_handle_t hImage) {
    return L0::Context::fromHandle(hContext)->makeImageResident(hDevice, hImage);
}

ze_result_t ZE_APICALL zeContextEvictImage(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    ze_image_handle_t hImage) {
    return L0::Context::fromHandle(hContext)->evictImage(hDevice, hImage);
}

} // namespace L0

extern "C" {
ZE_APIEXPORT ze_result_t ZE_APICALL zeContextCreate(
    ze_driver_handle_t hDriver,
    const ze_context_desc_t *desc,
    ze_context_handle_t *phContext) {
    return L0::zeContextCreate(
        hDriver,
        desc,
        phContext);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextCreateEx(
    ze_driver_handle_t hDriver,
    const ze_context_desc_t *desc,
    uint32_t numDevices,
    ze_device_handle_t *phDevices,
    ze_context_handle_t *phContext) {
    return L0::zeContextCreateEx(
        hDriver,
        desc,
        numDevices,
        phDevices,
        phContext);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextDestroy(
    ze_context_handle_t hContext) {
    return L0::zeContextDestroy(
        hContext);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextGetStatus(
    ze_context_handle_t hContext) {
    return L0::zeContextGetStatus(
        hContext);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextMakeMemoryResident(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    void *ptr,
    size_t size) {
    return L0::zeContextMakeMemoryResident(hContext, hDevice, ptr, size);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextEvictMemory(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    void *ptr,
    size_t size) {
    return L0::zeContextEvictMemory(hContext, hDevice, ptr, size);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextMakeImageResident(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    ze_image_handle_t hImage) {
    return L0::zeContextMakeImageResident(hContext, hDevice, hImage);
}

ZE_APIEXPORT ze_result_t ZE_APICALL zeContextEvictImage(
    ze_context_handle_t hContext,
    ze_device_handle_t hDevice,
    ze_image_handle_t hImage) {
    return L0::zeContextEvictImage(hContext, hDevice, hImage);
}
}