1#pragma once
2
3#include <cstddef>
4
5constexpr int taichi_max_num_indices = 12;
6// legacy: only used in cc and opengl backends
7constexpr 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
10constexpr int taichi_max_num_args_total = 64;
11constexpr int taichi_max_num_args_extra = 32;
12constexpr int taichi_max_num_snodes = 1024;
13constexpr int kMaxNumSnodeTreesLlvm = 512;
14constexpr int taichi_max_gpu_block_dim = 1024;
15constexpr std::size_t taichi_global_tmp_buffer_size = 1024 * 1024;
16constexpr int taichi_max_num_mem_requests = 1024 * 64;
17constexpr std::size_t taichi_page_size = 4096;
18constexpr std::size_t taichi_error_message_max_length = 2048;
19constexpr std::size_t taichi_error_message_max_num_arguments = 32;
20constexpr std::size_t taichi_result_buffer_entries = 32;
21constexpr std::size_t taichi_max_num_ret_value = 30;
22// slot for kernel return value
23constexpr std::size_t taichi_result_buffer_ret_value_id = 0;
24// slot for error code and error message char *
25constexpr std::size_t taichi_result_buffer_error_id = 30;
26constexpr std::size_t taichi_result_buffer_runtime_query_id = 31;
27
28constexpr 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
32constexpr std::size_t default_shared_mem_size = 65536;
33
34template <typename T, typename G>
35T 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
44template <typename T, typename G>
45T taichi_union_cast(G g) {
46 static_assert(sizeof(T) == sizeof(G));
47 return taichi_union_cast_with_different_sizes<T>(g);
48}
49
50enum class ExternalArrayLayout { kAOS, kSOA, kNull };
51
52enum class AutodiffMode { kForward, kReverse, kNone, kCheckAutodiffValid };
53
54enum class SNodeGradType { kPrimal, kAdjoint, kDual, kAdjointCheckbit };
55