1 | #include "compile_config.h" |
---|---|
2 | |
3 | #include <thread> |
4 | #include "taichi/rhi/arch.h" |
5 | #include "taichi/util/offline_cache.h" |
6 | |
7 | namespace taichi::lang { |
8 | |
9 | CompileConfig::CompileConfig() { |
10 | arch = host_arch(); |
11 | simd_width = default_simd_width(arch); |
12 | opt_level = 1; |
13 | external_optimization_level = 3; |
14 | print_ir = false; |
15 | print_preprocessed_ir = false; |
16 | print_accessor_ir = false; |
17 | print_evaluator_ir = false; |
18 | use_llvm = true; |
19 | demote_dense_struct_fors = true; |
20 | advanced_optimization = true; |
21 | constant_folding = true; |
22 | max_vector_width = 8; |
23 | debug = false; |
24 | cfg_optimization = true; |
25 | check_out_of_bound = false; |
26 | serial_schedule = false; |
27 | simplify_before_lower_access = true; |
28 | lower_access = true; |
29 | simplify_after_lower_access = true; |
30 | move_loop_invariant_outside_if = false; |
31 | default_fp = PrimitiveType::f32; |
32 | default_ip = PrimitiveType::i32; |
33 | default_up = PrimitiveType::u32; |
34 | verbose_kernel_launches = false; |
35 | kernel_profiler = false; |
36 | default_cpu_block_dim = 32; |
37 | cpu_block_dim_adaptive = true; |
38 | default_gpu_block_dim = 128; |
39 | gpu_max_reg = 0; // 0 means using the default value from the CUDA driver. |
40 | verbose = true; |
41 | fast_math = true; |
42 | flatten_if = false; |
43 | make_thread_local = true; |
44 | make_block_local = true; |
45 | detect_read_only = true; |
46 | ndarray_use_cached_allocator = true; |
47 | real_matrix_scalarize = true; |
48 | |
49 | saturating_grid_dim = 0; |
50 | max_block_dim = 0; |
51 | cpu_max_num_threads = std::thread::hardware_concurrency(); |
52 | random_seed = 0; |
53 | |
54 | // LLVM backend options: |
55 | print_struct_llvm_ir = false; |
56 | print_kernel_llvm_ir = false; |
57 | print_kernel_nvptx = false; |
58 | print_kernel_llvm_ir_optimized = false; |
59 | |
60 | // CUDA/AMDGPU backend options: |
61 | device_memory_GB = 1; // by default, preallocate 1 GB GPU memory |
62 | device_memory_fraction = 0.0; |
63 | |
64 | // C backend options: |
65 | cc_compile_cmd = "gcc -Wc99-c11-compat -c -o '{}' '{}' -O3"; |
66 | cc_link_cmd = "gcc -shared -fPIC -o '{}' '{}'"; |
67 | } |
68 | |
69 | void CompileConfig::fit() { |
70 | if (debug) { |
71 | // TODO: allow users to run in debug mode without out-of-bound checks |
72 | check_out_of_bound = true; |
73 | } |
74 | if (arch == Arch::cc || arch_uses_spirv(arch)) { |
75 | demote_dense_struct_fors = true; |
76 | } |
77 | offline_cache::disable_offline_cache_if_needed(this); |
78 | } |
79 | |
80 | } // namespace taichi::lang |
81 |