- Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathkernel2.cxx
32 lines (26 loc) · 1.18 KB
/
kernel2.cxx
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
#include"../include/luacir.hxx"
#include"../include/format.hxx"
#include"params.hxx"
// Load and execute a Lua script.
@meta lua_engine_t kernel_lua;
@meta kernel_lua.file("kernel.lua");
template<int sm, typenametype_t>
voidfake_kernel(consttype_t* input, type_t* output, size_t count) {
// Look for a JSON item with the sm and typename keys.
@meta kernel_key_t key { sm, @type_string(type_t) };
@meta cirprint("Compiling kernel %:\n", key);
// At compile-time, call the lua function kernel_params and pass our key.
// If anything unexpected happens, we'll see a message.
@meta params_t params = kernel_lua.call<params_t>("kernel_params", key);
// Print the kernel parameters if they were found.
@meta cirprint(" Params for kernel: %\n\n", params);
// Off to the races--generate your kernel with these parameters.
}
intmain(int argc, char** argv) {
fake_kernel<52>((constfloat*)nullptr, (float*)nullptr, 0);
fake_kernel<52>((constdouble*)nullptr, (double*)nullptr, 0);
fake_kernel<70>((constfloat*)nullptr, (float*)nullptr, 0);
fake_kernel<70>((constshort*)nullptr, (short*)nullptr, 0);
fake_kernel<35>((constint*)nullptr, (int*)nullptr, 0);
return0;
}