DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
_generate_explicit_inst.py
Go to the documentation of this file.
1import sys, os
2
3col_sizes = [1, 2, 3, 4, 5, 6, 7, 8, "D", "I"]
4
5templates = {
6 (
7 "ArrayDOF_op_",
8 ".cpp",
9 ): """
10#include "../ArrayDOF.hpp"
11#include "../ArrayDOF_op.hxx"
12#include "DNDS/DeviceStorage.hxx"
13namespace DNDS
14{{
15 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::Host, {offset}, template)
16 // DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::Host, {offset}, )
17}}
18 """,
19 (
20 "ArrayDOF_op_",
21 ".cu",
22 ): """
23#include "../ArrayDOF.hpp"
24#include "../ArrayDOF_op_CUDA.cuh"
25#include "DNDS/DeviceStorage.hxx"
26#include "DNDS/DeviceStorage_CUDA.cuh"
27namespace DNDS
28{{
29 DNDS_ARRAY_DOF_OP_FUNC_SEQ_INST(DeviceBackend::CUDA, {offset}, template)
30 // DNDS_ARRAYDOF_INST_STORAGE(DeviceBackend::CUDA, {offset}, )
31}}
32 """,
33}
34
35base_pos = os.path.abspath(os.path.dirname(__file__))
36
37file_done = set()
38
39
41 if isinstance(v, str):
42 if v == "D":
43 return "DynamicSize - 1"
44 if v == "I":
45 return "NonUniformSize - 1"
46 else:
47 return v - 1
48
49
50for (inst_prefix, inst_suffix), template in templates.items():
51 for col_size in col_sizes:
52 fname = inst_prefix + f"{col_size}" + inst_suffix
53 assert fname not in file_done, f"file name clash: {fname}"
54 file_done.add(fname)
55 template = template.strip()
56 print(f"generated: {fname}")
57 with open(os.path.join(base_pos, fname), "w") as f:
58 f.write(template.format(offset=col_size_to_offset(col_size)))
set(LIBNAME cfv) set(LINKS) set(LINKS_SHARED geom_shared dnds_shared $
Definition CMakeLists.txt:5