1 | #pragma once |
2 | |
3 | #include "taichi/rhi/arch.h" |
4 | #include "taichi/util/lang_util.h" |
5 | |
6 | namespace taichi::lang { |
7 | |
8 | struct CompileConfig { |
9 | Arch arch; |
10 | bool debug; |
11 | bool cfg_optimization; |
12 | bool check_out_of_bound; |
13 | bool validate_autodiff; |
14 | int simd_width; |
15 | int opt_level; |
16 | int external_optimization_level; |
17 | int max_vector_width; |
18 | bool print_preprocessed_ir; |
19 | bool print_ir; |
20 | bool print_accessor_ir; |
21 | bool print_evaluator_ir; |
22 | bool serial_schedule; |
23 | bool simplify_before_lower_access; |
24 | bool lower_access; |
25 | bool simplify_after_lower_access; |
26 | bool move_loop_invariant_outside_if; |
27 | bool cache_loop_invariant_global_vars{true}; |
28 | bool demote_dense_struct_fors; |
29 | bool advanced_optimization; |
30 | bool constant_folding; |
31 | bool use_llvm; |
32 | bool verbose_kernel_launches; |
33 | bool kernel_profiler; |
34 | bool timeline{false}; |
35 | bool verbose; |
36 | bool fast_math; |
37 | bool flatten_if; |
38 | bool make_thread_local; |
39 | bool make_block_local; |
40 | bool detect_read_only; |
41 | bool ndarray_use_cached_allocator; |
42 | bool real_matrix_scalarize; |
43 | DataType default_fp; |
44 | DataType default_ip; |
45 | DataType default_up; |
46 | std::string ; |
47 | int default_cpu_block_dim; |
48 | bool cpu_block_dim_adaptive; |
49 | int default_gpu_block_dim; |
50 | int gpu_max_reg; |
51 | int ad_stack_size{0}; // 0 = adaptive |
52 | // The default size when the Taichi compiler is unable to automatically |
53 | // determine the autodiff stack size. |
54 | int default_ad_stack_size{32}; |
55 | |
56 | int saturating_grid_dim; |
57 | int max_block_dim; |
58 | int cpu_max_num_threads; |
59 | int random_seed; |
60 | |
61 | // LLVM backend options: |
62 | bool print_struct_llvm_ir; |
63 | bool print_kernel_llvm_ir; |
64 | bool print_kernel_llvm_ir_optimized; |
65 | bool print_kernel_nvptx; |
66 | |
67 | // CUDA/AMDGPU backend options: |
68 | float64 device_memory_GB; |
69 | float64 device_memory_fraction; |
70 | |
71 | // C backend options: |
72 | std::string cc_compile_cmd; |
73 | std::string cc_link_cmd; |
74 | |
75 | // Opengl backend options: |
76 | bool allow_nv_shader_extension{true}; |
77 | |
78 | bool quant_opt_store_fusion{true}; |
79 | bool quant_opt_atomic_demotion{true}; |
80 | |
81 | // Mesh related. |
82 | // MeshTaichi options |
83 | bool make_mesh_block_local{true}; |
84 | bool optimize_mesh_reordered_mapping{true}; |
85 | bool mesh_localize_to_end_mapping{true}; |
86 | bool mesh_localize_from_end_mapping{false}; |
87 | bool mesh_localize_all_attr_mappings{false}; |
88 | bool demote_no_access_mesh_fors{true}; |
89 | bool experimental_auto_mesh_local{false}; |
90 | int auto_mesh_local_default_occupacy{4}; |
91 | |
92 | // Offline cache options |
93 | bool offline_cache{false}; |
94 | std::string offline_cache_file_path{get_repo_dir() + "ticache" }; |
95 | std::string offline_cache_cleaning_policy{ |
96 | "lru" }; // "never"|"version"|"lru"|"fifo" |
97 | int offline_cache_max_size_of_files{100 * 1024 * |
98 | 1024}; // bytes, default: 100MB |
99 | double offline_cache_cleaning_factor{0.25}; // [0.f, 1.f] |
100 | |
101 | int num_compile_threads{4}; |
102 | std::string vk_api_version; |
103 | |
104 | size_t cuda_stack_limit{8192}; |
105 | |
106 | CompileConfig(); |
107 | |
108 | void fit(); |
109 | }; |
110 | |
111 | extern TI_DLL_EXPORT CompileConfig default_compile_config; |
112 | |
113 | } // namespace taichi::lang |
114 | |