-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathCLFFM.java
More file actions
108 lines (83 loc) · 7.36 KB
/
Copy pathCLFFM.java
File metadata and controls
108 lines (83 loc) · 7.36 KB
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
package javaforce.ffm;
import java.lang.foreign.*;
import java.lang.invoke.*;
import static java.lang.foreign.ValueLayout.*;
import javaforce.*;
import javaforce.ffm.*;
import javaforce.api.*;
/** CLAPI FFM implementation.
*
* Generated by GenFFM - DO NOT EDIT
*/
public class CLFFM implements CLAPI {
private FFM ffm;
private static CLFFM instance;
public static synchronized CLFFM getInstance() {
if (instance == null) {
instance = new CLFFM();
if (!instance.ffm_init()) {
JFLog.log("CLFFM init failed!");
instance = null;
}
}
return instance;
}
private MethodHandle clClose;
public boolean clClose(long a1) { try { boolean _ret_value_ = (boolean)clClose.invokeExact(a1);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clExecute;
public boolean clExecute(long a1,long a2,int a3) { try { boolean _ret_value_ = (boolean)clExecute.invokeExact(a1,a2,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clExecute2;
public boolean clExecute2(long a1,long a2,int a3,int a4) { try { boolean _ret_value_ = (boolean)clExecute2.invokeExact(a1,a2,a3,a4);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clExecute3;
public boolean clExecute3(long a1,long a2,int a3,int a4,int a5) { try { boolean _ret_value_ = (boolean)clExecute3.invokeExact(a1,a2,a3,a4,a5);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clExecute4;
public boolean clExecute4(long a1,long a2,int a3,int a4,int a5,int a6) { try { boolean _ret_value_ = (boolean)clExecute4.invokeExact(a1,a2,a3,a4,a5,a6);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clFreeBuffer;
public boolean clFreeBuffer(long a1,long a2) { try { boolean _ret_value_ = (boolean)clFreeBuffer.invokeExact(a1,a2);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clFreeKernel;
public boolean clFreeKernel(long a1,long a2) { try { boolean _ret_value_ = (boolean)clFreeKernel.invokeExact(a1,a2);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clReadBufferf32;
public boolean clReadBufferf32(long a1,long a2,float[] a3,int a4) { try { Arena arena = Arena.ofAuto(); MemorySegment _array_a3 = FFM.toMemory(arena, a3);boolean _ret_value_ = (boolean)clReadBufferf32.invokeExact(a1,a2,_array_a3,a4);FFM.copyBack(_array_a3,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clReadBufferi8;
public boolean clReadBufferi8(long a1,long a2,byte[] a3,int a4) { try { Arena arena = Arena.ofAuto(); MemorySegment _array_a3 = FFM.toMemory(arena, a3);boolean _ret_value_ = (boolean)clReadBufferi8.invokeExact(a1,a2,_array_a3,a4);FFM.copyBack(_array_a3,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clSetArg;
public boolean clSetArg(long a1,long a2,int a3,byte[] a4,int a5) { try { Arena arena = Arena.ofAuto(); MemorySegment _array_a4 = FFM.toMemory(arena, a4);boolean _ret_value_ = (boolean)clSetArg.invokeExact(a1,a2,a3,_array_a4,a5);FFM.copyBack(_array_a4,a4);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clWriteBufferf32;
public boolean clWriteBufferf32(long a1,long a2,float[] a3,int a4) { try { Arena arena = Arena.ofAuto(); MemorySegment _array_a3 = FFM.toMemory(arena, a3);boolean _ret_value_ = (boolean)clWriteBufferf32.invokeExact(a1,a2,_array_a3,a4);FFM.copyBack(_array_a3,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clWriteBufferi8;
public boolean clWriteBufferi8(long a1,long a2,byte[] a3,int a4) { try { Arena arena = Arena.ofAuto(); MemorySegment _array_a3 = FFM.toMemory(arena, a3);boolean _ret_value_ = (boolean)clWriteBufferi8.invokeExact(a1,a2,_array_a3,a4);FFM.copyBack(_array_a3,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle clCreate;
public long clCreate(java.lang.String a1,int a2) { try { Arena arena = Arena.ofAuto(); long _ret_value_ = (long)clCreate.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),a2);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle clCreateBuffer;
public long clCreateBuffer(long a1,int a2,int a3) { try { long _ret_value_ = (long)clCreateBuffer.invokeExact(a1,a2,a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle clKernel;
public long clKernel(long a1,java.lang.String a2) { try { Arena arena = Arena.ofAuto(); long _ret_value_ = (long)clKernel.invokeExact(a1,(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private boolean ffm_init() {
if (FFM.debug) JFLog.log("CLFFM init started");
MethodHandle init;
ffm = FFM.getInstance();
Library[] libs = new Library[] {new Library("OpenCL")};
Library.findLibraries(null, libs);
Arena arena = Arena.ofAuto();
init = ffm.getFunction("CLAPIinit", ffm.getFunctionDesciptor(ValueLayout.JAVA_BOOLEAN,ADDRESS));
if (init == null) return false;
try {if (!(boolean)init.invokeExact(libs[0].getPath(arena))) return false;} catch (Throwable t) {JFLog.log(t); return false;}
clClose = ffm.getFunctionPtr("_clClose", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG));
clExecute = ffm.getFunctionPtr("_clExecute", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,JAVA_INT));
clExecute2 = ffm.getFunctionPtr("_clExecute2", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,JAVA_INT,JAVA_INT));
clExecute3 = ffm.getFunctionPtr("_clExecute3", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,JAVA_INT,JAVA_INT,JAVA_INT));
clExecute4 = ffm.getFunctionPtr("_clExecute4", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,JAVA_INT,JAVA_INT,JAVA_INT,JAVA_INT));
clFreeBuffer = ffm.getFunctionPtr("_clFreeBuffer", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG));
clFreeKernel = ffm.getFunctionPtr("_clFreeKernel", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG));
clReadBufferf32 = ffm.getFunctionPtr("_clReadBufferf32", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,ADDRESS,JAVA_INT));
clReadBufferi8 = ffm.getFunctionPtr("_clReadBufferi8", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,ADDRESS,JAVA_INT));
clSetArg = ffm.getFunctionPtr("_clSetArg", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,JAVA_INT,ADDRESS,JAVA_INT));
clWriteBufferf32 = ffm.getFunctionPtr("_clWriteBufferf32", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,ADDRESS,JAVA_INT));
clWriteBufferi8 = ffm.getFunctionPtr("_clWriteBufferi8", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_LONG,ADDRESS,JAVA_INT));
clCreate = ffm.getFunctionPtr("_clCreate", ffm.getFunctionDesciptor(JAVA_LONG,ADDRESS,JAVA_INT));
clCreateBuffer = ffm.getFunctionPtr("_clCreateBuffer", ffm.getFunctionDesciptor(JAVA_LONG,JAVA_LONG,JAVA_INT,JAVA_INT));
clKernel = ffm.getFunctionPtr("_clKernel", ffm.getFunctionDesciptor(JAVA_LONG,JAVA_LONG,ADDRESS));
if (FFM.debug) JFLog.log("CLFFM init complete");
return true;
}
}