Skip to content

Commit f918b0b

Browse files
royalstreampradeep
authored andcommitted
3D and 4D host array support
1 parent 05be04a commit f918b0b

File tree

3 files changed

+329
-5
lines changed

3 files changed

+329
-5
lines changed

AutoGenTool/Interop.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module Interop =
6565
// array inputs:
6666
"const\s+af_array\s*\*\s*(?:const\s+)?(\w+)", "[In] IntPtr[] array_$1";
6767
"const\s+dim_t\s*\*\s*(?:const\s+)?(\w+)", "[In] long[] dim_$1";
68-
"const\s+void\s*\*\s*(?:const\s+)?(\w+)", "[In] T[] $1"
68+
"const\s+void\s*\*\s*(?:const\s+)?(\w+)", "[In] T[_] $1"
6969
"const\s+char\s*\*\s*(?:const\s+)?(\w+)", "string $1";
7070
// trivial-case inputs:
7171
"(?:const\s+)?(\w+)\s+(\w+)", "$1 $2";
@@ -76,7 +76,7 @@ module Interop =
7676
"af_array\s*\*\s*(\w+)", "out IntPtr array_$1";
7777
"size_t\s*\*\s*(\w+)", "out UIntPtr size_$1";
7878
// array outputs:
79-
"void\s*\*\s*(\w+)", "[Out] T[] $1";
79+
"void\s*\*\s*(\w+)", "[Out] T[_] $1";
8080
"char\s*\*\s*(\w+)", "[Out] StringBuilder $1";
8181
// trivial-case outputs:
8282
"(\w+)\s*\*\s*(\w+)", "out $1 $2";
@@ -145,11 +145,11 @@ module Interop =
145145
for api, pars in matches do
146146
let unsupp = pars.Contains("???")
147147
let versions =
148-
if not unsupp && pars.Contains("T[]") then
148+
if not unsupp && pars.Contains("T[_]") then
149149
let add x y = y + x
150150
[ "bool"; "Complex"; "float"; "double"; "int"; "long"; "uint"; "ulong"; "byte" ]
151-
|> listCartesian [ "[]"; "[,]" ]
152-
|> List.map (fun (x,y) -> pars.Replace("T[]", y + x))
151+
|> listCartesian [ "[]"; "[,]"; "[,,]"; "[,,,]" ]
152+
|> List.map (fun (x,y) -> pars.Replace("T[_]", y + x))
153153
else [ pars ]
154154
for vpars in versions do
155155
if is1st then is1st <- false else cw <=- ""

Wrapper/Interop/af_array.cs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,60 @@ public static class af_array
6666
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
6767
public static extern af_err af_create_array(out IntPtr array_arr, [In] byte[,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
6868

69+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70+
public static extern af_err af_create_array(out IntPtr array_arr, [In] bool[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
71+
72+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73+
public static extern af_err af_create_array(out IntPtr array_arr, [In] Complex[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
74+
75+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76+
public static extern af_err af_create_array(out IntPtr array_arr, [In] float[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
77+
78+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79+
public static extern af_err af_create_array(out IntPtr array_arr, [In] double[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
80+
81+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82+
public static extern af_err af_create_array(out IntPtr array_arr, [In] int[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
83+
84+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85+
public static extern af_err af_create_array(out IntPtr array_arr, [In] long[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
86+
87+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
88+
public static extern af_err af_create_array(out IntPtr array_arr, [In] uint[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
89+
90+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
91+
public static extern af_err af_create_array(out IntPtr array_arr, [In] ulong[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
92+
93+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
94+
public static extern af_err af_create_array(out IntPtr array_arr, [In] byte[,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
95+
96+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
97+
public static extern af_err af_create_array(out IntPtr array_arr, [In] bool[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
98+
99+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
100+
public static extern af_err af_create_array(out IntPtr array_arr, [In] Complex[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
101+
102+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
103+
public static extern af_err af_create_array(out IntPtr array_arr, [In] float[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
104+
105+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
106+
public static extern af_err af_create_array(out IntPtr array_arr, [In] double[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
107+
108+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
109+
public static extern af_err af_create_array(out IntPtr array_arr, [In] int[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
110+
111+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
112+
public static extern af_err af_create_array(out IntPtr array_arr, [In] long[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
113+
114+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
115+
public static extern af_err af_create_array(out IntPtr array_arr, [In] uint[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
116+
117+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
118+
public static extern af_err af_create_array(out IntPtr array_arr, [In] ulong[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
119+
120+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
121+
public static extern af_err af_create_array(out IntPtr array_arr, [In] byte[,,,] data, uint ndims, [In] long[] dim_dims, af_dtype type);
122+
69123
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70124
public static extern af_err af_create_handle(out IntPtr array_arr, uint ndims, [In] long[] dim_dims, af_dtype type);
71125

@@ -126,6 +180,60 @@ public static class af_array
126180
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
127181
public static extern af_err af_write_array(IntPtr array_arr, [In] byte[,] data, UIntPtr size_bytes, af_source src);
128182

183+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
184+
public static extern af_err af_write_array(IntPtr array_arr, [In] bool[,,] data, UIntPtr size_bytes, af_source src);
185+
186+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
187+
public static extern af_err af_write_array(IntPtr array_arr, [In] Complex[,,] data, UIntPtr size_bytes, af_source src);
188+
189+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
190+
public static extern af_err af_write_array(IntPtr array_arr, [In] float[,,] data, UIntPtr size_bytes, af_source src);
191+
192+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
193+
public static extern af_err af_write_array(IntPtr array_arr, [In] double[,,] data, UIntPtr size_bytes, af_source src);
194+
195+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
196+
public static extern af_err af_write_array(IntPtr array_arr, [In] int[,,] data, UIntPtr size_bytes, af_source src);
197+
198+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
199+
public static extern af_err af_write_array(IntPtr array_arr, [In] long[,,] data, UIntPtr size_bytes, af_source src);
200+
201+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
202+
public static extern af_err af_write_array(IntPtr array_arr, [In] uint[,,] data, UIntPtr size_bytes, af_source src);
203+
204+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
205+
public static extern af_err af_write_array(IntPtr array_arr, [In] ulong[,,] data, UIntPtr size_bytes, af_source src);
206+
207+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
208+
public static extern af_err af_write_array(IntPtr array_arr, [In] byte[,,] data, UIntPtr size_bytes, af_source src);
209+
210+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
211+
public static extern af_err af_write_array(IntPtr array_arr, [In] bool[,,,] data, UIntPtr size_bytes, af_source src);
212+
213+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
214+
public static extern af_err af_write_array(IntPtr array_arr, [In] Complex[,,,] data, UIntPtr size_bytes, af_source src);
215+
216+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
217+
public static extern af_err af_write_array(IntPtr array_arr, [In] float[,,,] data, UIntPtr size_bytes, af_source src);
218+
219+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
220+
public static extern af_err af_write_array(IntPtr array_arr, [In] double[,,,] data, UIntPtr size_bytes, af_source src);
221+
222+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
223+
public static extern af_err af_write_array(IntPtr array_arr, [In] int[,,,] data, UIntPtr size_bytes, af_source src);
224+
225+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
226+
public static extern af_err af_write_array(IntPtr array_arr, [In] long[,,,] data, UIntPtr size_bytes, af_source src);
227+
228+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
229+
public static extern af_err af_write_array(IntPtr array_arr, [In] uint[,,,] data, UIntPtr size_bytes, af_source src);
230+
231+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
232+
public static extern af_err af_write_array(IntPtr array_arr, [In] ulong[,,,] data, UIntPtr size_bytes, af_source src);
233+
234+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
235+
public static extern af_err af_write_array(IntPtr array_arr, [In] byte[,,,] data, UIntPtr size_bytes, af_source src);
236+
129237
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
130238
public static extern af_err af_get_data_ptr([Out] bool[] data, IntPtr array_arr);
131239

@@ -180,6 +288,60 @@ public static class af_array
180288
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
181289
public static extern af_err af_get_data_ptr([Out] byte[,] data, IntPtr array_arr);
182290

291+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
292+
public static extern af_err af_get_data_ptr([Out] bool[,,] data, IntPtr array_arr);
293+
294+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
295+
public static extern af_err af_get_data_ptr([Out] Complex[,,] data, IntPtr array_arr);
296+
297+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
298+
public static extern af_err af_get_data_ptr([Out] float[,,] data, IntPtr array_arr);
299+
300+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
301+
public static extern af_err af_get_data_ptr([Out] double[,,] data, IntPtr array_arr);
302+
303+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
304+
public static extern af_err af_get_data_ptr([Out] int[,,] data, IntPtr array_arr);
305+
306+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
307+
public static extern af_err af_get_data_ptr([Out] long[,,] data, IntPtr array_arr);
308+
309+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
310+
public static extern af_err af_get_data_ptr([Out] uint[,,] data, IntPtr array_arr);
311+
312+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
313+
public static extern af_err af_get_data_ptr([Out] ulong[,,] data, IntPtr array_arr);
314+
315+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
316+
public static extern af_err af_get_data_ptr([Out] byte[,,] data, IntPtr array_arr);
317+
318+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
319+
public static extern af_err af_get_data_ptr([Out] bool[,,,] data, IntPtr array_arr);
320+
321+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
322+
public static extern af_err af_get_data_ptr([Out] Complex[,,,] data, IntPtr array_arr);
323+
324+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
325+
public static extern af_err af_get_data_ptr([Out] float[,,,] data, IntPtr array_arr);
326+
327+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
328+
public static extern af_err af_get_data_ptr([Out] double[,,,] data, IntPtr array_arr);
329+
330+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
331+
public static extern af_err af_get_data_ptr([Out] int[,,,] data, IntPtr array_arr);
332+
333+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
334+
public static extern af_err af_get_data_ptr([Out] long[,,,] data, IntPtr array_arr);
335+
336+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
337+
public static extern af_err af_get_data_ptr([Out] uint[,,,] data, IntPtr array_arr);
338+
339+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
340+
public static extern af_err af_get_data_ptr([Out] ulong[,,,] data, IntPtr array_arr);
341+
342+
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
343+
public static extern af_err af_get_data_ptr([Out] byte[,,,] data, IntPtr array_arr);
344+
183345
[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
184346
public static extern af_err af_release_array(IntPtr array_arr);
185347

0 commit comments

Comments
 (0)