Skip to content

Commit 7e7ef8b

Browse files
author
Diptorup Deb
committed
Add bindings for more needed libsyclinterface functions.
1 parent ac05c1a commit 7e7ef8b

File tree

1 file changed

+226
-10
lines changed

1 file changed

+226
-10
lines changed

numba_dpex/dpctl_iface/libsyclinterface_bindings.py

Lines changed: 226 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def _build_dpctl_function(llvm_module, return_ty, arg_list, func_name):
3030
return fn
3131

3232

33+
# --------------------- DpctlSyclQueue functions ------------------------------#
34+
35+
3336
def dpctl_queue_copy(builder: llvmir.IRBuilder, *args):
3437
"""Inserts LLVM IR to call DPCTLQueue_Copy to create a copy of a
3538
DpctlSyclQueueRef pointer passed in to the function.
@@ -66,42 +69,255 @@ def dpctl_queue_memcpy(builder: llvmir.IRBuilder, *args):
6669
return ret
6770

6871

69-
def dpctl_event_wait(builder: llvmir.IRBuilder, *args):
70-
"""Inserts LLVM IR to call DPCTLEvent_Wait."""
72+
def dpctl_queue_delete(builder: llvmir.IRBuilder, *args):
73+
"""Inserts LLVM IR to call DPCTLQueue_Delete."""
7174
mod = builder.module
7275
fn = _build_dpctl_function(
7376
llvm_module=mod,
74-
return_ty=llvmir.VoidType(),
77+
return_ty=llvmir.types.VoidType(),
7578
arg_list=[cgutils.voidptr_t],
76-
func_name="DPCTLEvent_Wait",
79+
func_name="DPCTLQueue_Delete",
7780
)
7881
ret = builder.call(fn, args)
7982

8083
return ret
8184

8285

83-
def dpctl_event_delete(builder: llvmir.IRBuilder, *args):
84-
"""Inserts LLVM IR to call DPCTLEvent_Delete."""
86+
def dpctl_queue_get_context(builder: llvmir.IRBuilder, *args):
87+
"""Inserts LLVM IR to call DPCTLQueue_GetContext."""
88+
mod = builder.module
89+
fn = _build_dpctl_function(
90+
llvm_module=mod,
91+
return_ty=cgutils.voidptr_t,
92+
arg_list=[cgutils.voidptr_t],
93+
func_name="DPCTLQueue_GetContext",
94+
)
95+
ret = builder.call(fn, args)
96+
97+
return ret
98+
99+
100+
def dpctl_queue_get_device(builder: llvmir.IRBuilder, *args):
101+
"""Inserts LLVM IR to call DPCTLQueue_GetDevice."""
102+
mod = builder.module
103+
fn = _build_dpctl_function(
104+
llvm_module=mod,
105+
return_ty=cgutils.voidptr_t,
106+
arg_list=[cgutils.voidptr_t],
107+
func_name="DPCTLQueue_GetDevice",
108+
)
109+
ret = builder.call(fn, args)
110+
111+
return ret
112+
113+
114+
def dpctl_queue_submit_range(builder: llvmir.IRBuilder, *args):
115+
"""Inserts LLVM IR to call DPCTLQueue_SubmitRange.
116+
117+
DPCTLSyclEventRef
118+
DPCTLQueue_SubmitRange(
119+
const DPCTLSyclKernelRef KRef,
120+
const DPCTLSyclQueueRef QRef,
121+
void** Args,
122+
const DPCTLKernelArgType* ArgTypes,
123+
size_t NArgs,
124+
const size_t Range[3],
125+
size_t NRange,
126+
const DPCTLSyclEventRef* DepEvents,
127+
size_t NDepEvents
128+
);
129+
130+
"""
131+
mod = builder.module
132+
fn = _build_dpctl_function(
133+
llvm_module=mod,
134+
return_ty=cgutils.voidptr_t,
135+
arg_list=[
136+
cgutils.voidptr_t,
137+
cgutils.voidptr_t,
138+
cgutils.voidptr_t.as_pointer(),
139+
cgutils.int32_t.as_pointer(),
140+
llvmir.IntType(64),
141+
llvmir.IntType(64).as_pointer(),
142+
llvmir.IntType(64),
143+
cgutils.voidptr_t,
144+
llvmir.IntType(64),
145+
],
146+
func_name="DPCTLQueue_SubmitRange",
147+
)
148+
ret = builder.call(fn, args)
149+
150+
return ret
151+
152+
153+
def dpctl_queue_submit_ndrange(builder: llvmir.IRBuilder, *args):
154+
"""Inserts LLVM IR to call DPCTLQueue_SubmitNDRange.
155+
156+
DPCTLSyclEventRef
157+
DPCTLQueue_SubmitNDRange(
158+
const DPCTLSyclKernelRef KRef,
159+
const DPCTLSyclQueueRef QRef,
160+
void** Args,
161+
const DPCTLKernelArgType* ArgTypes,
162+
size_t NArgs,
163+
const size_t gRange[3],
164+
const size_t lRange[3],
165+
size_t NDims,
166+
const DPCTLSyclEventRef* DepEvents,
167+
size_t NDepEvents
168+
);
169+
170+
"""
171+
mod = builder.module
172+
fn = _build_dpctl_function(
173+
llvm_module=mod,
174+
return_ty=cgutils.voidptr_t,
175+
arg_list=[
176+
cgutils.voidptr_t,
177+
cgutils.voidptr_t,
178+
cgutils.voidptr_t.as_pointer(),
179+
cgutils.int32_t.as_pointer(),
180+
llvmir.IntType(64),
181+
llvmir.IntType(64).as_pointer(),
182+
llvmir.IntType(64).as_pointer(),
183+
llvmir.IntType(64),
184+
cgutils.voidptr_t,
185+
llvmir.IntType(64),
186+
],
187+
func_name="DPCTLQueue_SubmitNDRange",
188+
)
189+
ret = builder.call(fn, args)
190+
191+
return ret
192+
193+
194+
# --------------------- DpctlSyclDevice functions -----------------------------#
195+
196+
197+
def dpctl_device_delete(builder: llvmir.IRBuilder, *args):
198+
"""Inserts LLVM IR to call DPCTLDevice_Delete."""
199+
mod = builder.module
200+
fn = _build_dpctl_function(
201+
llvm_module=mod,
202+
return_ty=llvmir.types.VoidType(),
203+
arg_list=[cgutils.voidptr_t],
204+
func_name="DPCTLDevice_Delete",
205+
)
206+
ret = builder.call(fn, args)
207+
208+
return ret
209+
210+
211+
# --------------------- DpctlSyclKernelBundle functions -----------------------#
212+
213+
214+
def dpctl_kernel_bundle_create_from_spirv(builder: llvmir.IRBuilder, *args):
215+
"""Inserts LLVM IR to call DPCTLKernelBundle_CreateFromSpirv."""
216+
mod = builder.module
217+
fn = _build_dpctl_function(
218+
llvm_module=mod,
219+
return_ty=cgutils.voidptr_t,
220+
arg_list=[
221+
cgutils.voidptr_t,
222+
cgutils.voidptr_t,
223+
cgutils.voidptr_t,
224+
llvmir.IntType(64),
225+
cgutils.voidptr_t,
226+
],
227+
func_name="DPCTLKernelBundle_CreateFromSpirv",
228+
)
229+
ret = builder.call(fn, args)
230+
231+
return ret
232+
233+
234+
def dpctl_kernel_bundle_delete(builder: llvmir.IRBuilder, *args):
235+
"""Inserts LLVM IR to call DPCTLKernelBundle_Delete."""
236+
mod = builder.module
237+
fn = _build_dpctl_function(
238+
llvm_module=mod,
239+
return_ty=llvmir.types.VoidType(),
240+
arg_list=[cgutils.voidptr_t],
241+
func_name="DPCTLKernelBundle_Delete",
242+
)
243+
ret = builder.call(fn, args)
244+
245+
return ret
246+
247+
248+
def dpctl_kernel_bundle_get_kernel(builder: llvmir.IRBuilder, *args):
249+
"""Inserts LLVM IR to call DPCTLKernelBundle_GetKernel."""
250+
mod = builder.module
251+
fn = _build_dpctl_function(
252+
llvm_module=mod,
253+
return_ty=cgutils.voidptr_t,
254+
arg_list=[cgutils.voidptr_t, cgutils.voidptr_t],
255+
func_name="DPCTLKernelBundle_GetKernel",
256+
)
257+
ret = builder.call(fn, args)
258+
259+
return ret
260+
261+
262+
# --------------------- DpctlSyclKernel functions -----------------------------#
263+
264+
265+
def dpctl_kernel_delete(builder: llvmir.IRBuilder, *args):
266+
"""Inserts LLVM IR to call DPCTLKernel_Delete."""
267+
mod = builder.module
268+
fn = _build_dpctl_function(
269+
llvm_module=mod,
270+
return_ty=llvmir.types.VoidType(),
271+
arg_list=[cgutils.voidptr_t],
272+
func_name="DPCTLKernel_Delete",
273+
)
274+
ret = builder.call(fn, args)
275+
276+
return ret
277+
278+
279+
# --------------------- DpctlSyclContext functions ----------------------------#
280+
281+
282+
def dpctl_context_delete(builder: llvmir.IRBuilder, *args):
283+
"""Inserts LLVM IR to call DPCTLContext_Delete."""
284+
mod = builder.module
285+
fn = _build_dpctl_function(
286+
llvm_module=mod,
287+
return_ty=llvmir.types.VoidType(),
288+
arg_list=[cgutils.voidptr_t],
289+
func_name="DPCTLContext_Delete",
290+
)
291+
ret = builder.call(fn, args)
292+
293+
return ret
294+
295+
296+
# --------------------- DpctlSyclEvent functions ------------------------------#
297+
298+
299+
def dpctl_event_wait(builder: llvmir.IRBuilder, *args):
300+
"""Inserts LLVM IR to call DPCTLEvent_Wait."""
85301
mod = builder.module
86302
fn = _build_dpctl_function(
87303
llvm_module=mod,
88304
return_ty=llvmir.VoidType(),
89305
arg_list=[cgutils.voidptr_t],
90-
func_name="DPCTLEvent_Delete",
306+
func_name="DPCTLEvent_Wait",
91307
)
92308
ret = builder.call(fn, args)
93309

94310
return ret
95311

96312

97-
def dpctl_queue_delete(builder: llvmir.IRBuilder, *args):
98-
"""Inserts LLVM IR to call DPCTLQueue_Delete."""
313+
def dpctl_event_delete(builder: llvmir.IRBuilder, *args):
314+
"""Inserts LLVM IR to call DPCTLEvent_Delete."""
99315
mod = builder.module
100316
fn = _build_dpctl_function(
101317
llvm_module=mod,
102318
return_ty=llvmir.VoidType(),
103319
arg_list=[cgutils.voidptr_t],
104-
func_name="DPCTLQueue_Delete",
320+
func_name="DPCTLEvent_Delete",
105321
)
106322
ret = builder.call(fn, args)
107323

0 commit comments

Comments
 (0)