1 | #pragma once |
2 | |
3 | #include <cstddef> |
4 | |
5 | constexpr int taichi_max_num_indices = 12; |
6 | // legacy: only used in cc and opengl backends |
7 | constexpr int taichi_max_num_args = 8; |
8 | // used in llvm backend: only the first 32 arguments can be types.ndarray |
9 | // TODO: refine argument passing |
10 | constexpr int taichi_max_num_args_total = 64; |
11 | constexpr int = 32; |
12 | constexpr int taichi_max_num_snodes = 1024; |
13 | constexpr int kMaxNumSnodeTreesLlvm = 512; |
14 | constexpr int taichi_max_gpu_block_dim = 1024; |
15 | constexpr std::size_t taichi_global_tmp_buffer_size = 1024 * 1024; |
16 | constexpr int taichi_max_num_mem_requests = 1024 * 64; |
17 | constexpr std::size_t taichi_page_size = 4096; |
18 | constexpr std::size_t taichi_error_message_max_length = 2048; |
19 | constexpr std::size_t taichi_error_message_max_num_arguments = 32; |
20 | constexpr std::size_t taichi_result_buffer_entries = 32; |
21 | constexpr std::size_t taichi_max_num_ret_value = 30; |
22 | // slot for kernel return value |
23 | constexpr std::size_t taichi_result_buffer_ret_value_id = 0; |
24 | // slot for error code and error message char * |
25 | constexpr std::size_t taichi_result_buffer_error_id = 30; |
26 | constexpr std::size_t taichi_result_buffer_runtime_query_id = 31; |
27 | |
28 | constexpr int taichi_listgen_max_element_size = 1024; |
29 | |
30 | // use for auto mesh_local to determine shared-mem size per block (in bytes) |
31 | // TODO: get this at runtime |
32 | constexpr std::size_t default_shared_mem_size = 65536; |
33 | |
34 | template <typename T, typename G> |
35 | T taichi_union_cast_with_different_sizes(G g) { |
36 | union { |
37 | T t; |
38 | G g; |
39 | } u; |
40 | u.g = g; |
41 | return u.t; |
42 | } |
43 | |
44 | template <typename T, typename G> |
45 | T taichi_union_cast(G g) { |
46 | static_assert(sizeof(T) == sizeof(G)); |
47 | return taichi_union_cast_with_different_sizes<T>(g); |
48 | } |
49 | |
50 | enum class ExternalArrayLayout { kAOS, kSOA, kNull }; |
51 | |
52 | enum class AutodiffMode { kForward, kReverse, kNone, kCheckAutodiffValid }; |
53 | |
54 | enum class SNodeGradType { kPrimal, kAdjoint, kDual, kAdjointCheckbit }; |
55 | |