diff options
author | Brett Weiland <brettsweiland@gmail.com> | 2024-05-27 20:56:59 -0500 |
---|---|---|
committer | Brett Weiland <brettsweiland@gmail.com> | 2024-05-27 20:56:59 -0500 |
commit | 093200a449ea38952de52012e324036c106e294b (patch) | |
tree | 6030076eb894ca100d6aa0d6550ab56955e7fb2f /common.cuh | |
parent | 7e9e2150619c05f9e8a74432e596b11f373518b9 (diff) |
boutta switch away from templates
Diffstat (limited to 'common.cuh')
-rw-r--r-- | common.cuh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/common.cuh b/common.cuh new file mode 100644 index 0000000..d5a9cdf --- /dev/null +++ b/common.cuh @@ -0,0 +1,43 @@ +#ifndef COMMON_H +#define COMMON_H + +#include "include/helper_math.h" + +/** + +template <class T> class vect_t2; +template <class T> class vect_t3; +template <class T> class vect_t4; + +//this feels so hacky... idk why people are so scared of metaprogramming +template <> class vect_t2<double> { public: using vect_t = double2; }; +template <> class vect_t3<double> { public: using vect_t = double3; }; +template <> class vect_t4<double> { public: using vect_t = double4; }; + +template <> class vect_t2<float> { public: using vect_t = float2; }; +template <> class vect_t3<float> { public: using vect_t = float3; }; +template <> class vect_t4<float> { public: using vect_t = float4; }; + + +template <class T, class X> __device__ T vect_create(X x); +template <class T, class X, class Y, class Z> __device__ T vect_create(X x, Y y, Z z); + +//I have no fucking clue if this is right, check me later ig +template <class float3, class X> __device__ inline float3 vect_create<float3>(X x) { return make_float3(x); } + +template <class float3, class X, class Y, class Z> __device__ inline float3 vect_create<float3>(X x, Y y, Z z) { return make_float3(x, y, z); } +**/ + +/** I'm not sure weather float or double percision is nessesary. I was using +templates, but this changes the structure of my entire project in unwanted +ways, so I'm switching over to typedefs. **/ + +typedef float2 vect_t2; +typedef float3 vect_t3; +typedef float4 vect_t4; +typedef float T; + +#define vect1to3(x) (make_float3(x)) +#define make_vect(x, y, z) (make_float3(x, y, z)) + +#endif |