- Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathkernel1.cxx
33 lines (27 loc) · 1.17 KB
/
kernel1.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
33
#include<fstream>
#include"../include/jsoncir.hxx"
#include"params.hxx"
// Load a JSON file.
@meta json kernel_json;
@meta std::ifstream json_file("kernel.json");
@meta json_file>> kernel_json;
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, find the JSON item for key and read all the members
// of params_t. If anything unexpected happens, we'll see a message.
@meta params_t params = find_json_value<params_t>(kernel_json, 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() {
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;
}