Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/basis_universal/encoder/cppspmd_math_declares.h
9903 views
1
// Do not include this header directly.
2
// This header defines shared struct spmd_kernel helpers.
3
//
4
// Copyright 2020-2024 Binomial LLC
5
//
6
// Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
// You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17
18
// See cppspmd_math.h for detailed error statistics.
19
20
CPPSPMD_FORCE_INLINE void reduce_expb(vfloat& arg, vfloat& two_int_a, vint& adjustment);
21
CPPSPMD_FORCE_INLINE vfloat tan56(vfloat x);
22
CPPSPMD_FORCE_INLINE vfloat tan82(vfloat x);
23
24
inline vfloat log2_est(vfloat v);
25
26
inline vfloat log_est(vfloat v);
27
28
inline vfloat exp2_est(vfloat arg);
29
30
inline vfloat exp_est(vfloat arg);
31
32
inline vfloat pow_est(vfloat arg1, vfloat arg2);
33
34
CPPSPMD_FORCE_INLINE vfloat recip_est1(const vfloat& q);
35
CPPSPMD_FORCE_INLINE vfloat recip_est1_pn(const vfloat& q);
36
37
inline vfloat mod_angles(vfloat a);
38
39
inline vfloat sincos_est_a(vfloat a, bool sin_flag);
40
CPPSPMD_FORCE_INLINE vfloat sin_est_a(vfloat a) { return sincos_est_a(a, true); }
41
CPPSPMD_FORCE_INLINE vfloat cos_est_a(vfloat a) { return sincos_est_a(a, false); }
42
43
inline vfloat sin_est(vfloat a);
44
45
inline vfloat cos_est(vfloat a);
46
47
// Don't call with values <= 0.
48
CPPSPMD_FORCE_INLINE vfloat rsqrt_est1(vfloat x0);
49
50
// Don't call with values <= 0.
51
CPPSPMD_FORCE_INLINE vfloat rsqrt_est2(vfloat x0);
52
53
CPPSPMD_FORCE_INLINE vfloat atan2_est(vfloat y, vfloat x);
54
55
CPPSPMD_FORCE_INLINE vfloat atan_est(vfloat x) { return atan2_est(x, vfloat(1.0f)); }
56
57
// Don't call this for angles close to 90/270!
58
inline vfloat tan_est(vfloat x);
59
60
// https://burtleburtle.net/bob/rand/smallprng.html
61
struct rand_context { vint a, b, c, d; };
62
63
inline void seed_rand(rand_context& x, vint seed);
64
65
// Returns 32-bit unsigned random numbers.
66
inline vint get_randu(rand_context& x);
67
68
// Returns random numbers between [low, high), or low if low >= high
69
inline vint get_randi(rand_context& x, vint low, vint high);
70
71
// Returns random numbers between [low, high), or low if low >= high
72
inline vfloat get_randf(rand_context& x, vfloat low, vfloat high);
73
74
CPPSPMD_FORCE_INLINE void init_reverse_bits(vint& tab1, vint& tab2);
75
CPPSPMD_FORCE_INLINE vint reverse_bits(vint k, vint tab1, vint tab2);
76
77
CPPSPMD_FORCE_INLINE vint count_leading_zeros(vint x);
78
CPPSPMD_FORCE_INLINE vint count_leading_zeros_alt(vint x);
79
80
CPPSPMD_FORCE_INLINE vint count_trailing_zeros(vint x);
81
82
CPPSPMD_FORCE_INLINE vint count_set_bits(vint x);
83
84
void print_vint(vint v);
85
void print_vbool(vbool v);
86
void print_vint_hex(vint v);
87
void print_active_lanes(const char *pPrefix);
88
void print_vfloat(vfloat v);
89
90
91