}
Callback<CLNativeKernel> call = Native.resolve(
- Call_pv_v.stub((MemoryAddress memargs) -> {
+ cl_h.clEnqueueNativeKernel$x0$make((MemoryAddress memargs) -> {
int xmem = 0;
for (int i=0;i<args.length;i++) {
clEnqueueMarker(addr(), info.event);
}
info.post(events);
- } catch (CLException | RuntimeException | Error t) {
+ } catch (RuntimeException | Error t) {
throw t;
} catch (Throwable t) {
throw new RuntimeException(t);
clEnqueueMarker(addr(), info.event);
}
info.post(events);
- } catch (CLException | RuntimeException | Error t) {
+ } catch (RuntimeException | Error t) {
throw t;
} catch (Throwable t) {
throw new RuntimeException(t);
static Callback<CLEventNotify> call(CLEventNotify notify) {
if (notify != null) {
return Native.resolve(
- Call_pLIpv_v.stub((cevent, status, dummy) -> notify.notify(Native.resolve(cevent, CLEvent::new), status)),
+ cl_h.clSetEventCallback$x0$make(((cevent, status, dummy) -> notify.notify(Native.resolve(cevent, CLEvent::new), status))),
(p) -> new Callback<>(p, notify));
} else {
return Callback.NULL;
@SuppressWarnings("unchecked")
static <T extends Native> Callback<CLNotify<T>> call(CLNotify<T> notify, Function<MemoryAddress,T> create) {
if (notify != null) {
+ // jextract note: this 2-parameter callback is used in a few places, but as it's untyped it
+ // doesn't matter which one is used.
return Native.resolve(
- Call_pLpv_v.stub((co, dummy) -> notify.notify(Native.resolve(co, create))),
+ cl_h.clBuildProgram$x0$make((co, dummy) -> notify.notify(Native.resolve(co, create))),
(p) -> new Callback<>(p, notify));
} else {
return Callback.NULL;
-export_defines=src/notzed.zcl/gen/export-defines
-generate_api=src/notzed.zcl/gen/generate-api
-opencl_pm=src/notzed.zcl/gen/opencl.pm
-
-# this is in src/notzed.zcl/classes already
-notzed.zcl_defines = \
- au/notzed/zcl/CL.java
-
notzed.zcl_generated = \
- au/notzed/zcl/CLLib.java \
- au/notzed/zcl/Call_pBpvJpv_v.java \
- au/notzed/zcl/Call_pLIppvpv_v.java \
- au/notzed/zcl/Call_pLIpv_v.java \
- au/notzed/zcl/Call_pLpv_v.java \
- au/notzed/zcl/Call_pv_v.java
+ au/notzed/zcl/cl_h.java \
+ au/notzed/zcl/RuntimeHelper.java
notzed.zcl_JAVA_GENERATED = \
$(notzed.zcl_generated)
-$(notzed.zcl_genjavadir)/au/notzed/zcl/CL.java: src/notzed.zcl/include/CL/cl.h $(export_defines)
- @install -d $(@D)
- perl $(export_defines) $< > $@ || rm -f $@
-
-$(addprefix $(notzed.zcl_genjavadir)/,$(notzed.zcl_generated)): $(generate_api) $(opencl_pm)
- perl $(generate_api) \
- -d $(notzed.zcl_genjavadir) \
- -t au.notzed.zcl \
- -r _cl_platform_id=CLPlatform \
- -r _cl_device_id=CLDevice \
- -r _cl_context=CLContext \
- -r _cl_command_queue=CLCommandQueue \
- -r _cl_program=CLProgram \
- -r _cl_kernel=CLKernel \
- -r _cl_event=CLEvent \
- -r _cl_mem=CLMemory \
- -r _cl_sampler=CLSampler \
- -r _cl_image_desc=CLImageDesc \
- -r _cl_image_format=CLImageFormat \
- --raw-calls \
- -c CLLib -lOpenCL --func-file src/notzed.zcl/gen/opencl.txt \
- ./$(opencl_pm)
+# This edits the jextract output a little bit
+# - make class non-final
+# - remove the constants
+# - enqueueSVMFree uses a void *[], which jextract turns into an unknown-length sequence, don't do that.
+$(addprefix $(notzed.zcl_genjavadir)/,$(notzed.zcl_generated)): src/notzed.zcl/include/CL/cl.h src/notzed.zcl/gen/gen.make
+ $(JEXTRACT) --output $(notzed.zcl_genjavadir) \
+ -t au.notzed.zcl \
+ -lOpenCL \
+ --filter cl.h \
+ -I /usr/lib64/clang/9.0.1/include \
+ -I src/notzed.zcl/include \
+ $< || ( rm $< ; exit 1)
+ ( echo '1,30 s/^public final class/public class/' ; \
+ echo 'g/public static final int CL_/d' ; \
+ echo '1,$$ s/MemoryLayout.ofSequence(MemoryLayouts.SysV.C_POINTER)/MemoryLayouts.SysV.C_POINTER/' ; \
+ echo 'w' ) | ed $(notzed.zcl_genjavadir)/au/notzed/zcl/cl_h.java