diff options
author | Suren A. Chilingaryan <csa@ipecompute4.ands.kit.edu> | 2022-09-06 19:12:09 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@ipecompute4.ands.kit.edu> | 2022-09-06 19:12:09 +0200 |
commit | efa4313aa57e4c3511eb1d5d88edc37e99f899fa (patch) | |
tree | b4061f583770608a19a313a9ef40cef71cc053d2 /patches/astra-toolbox-approximate-projectors/rounding.h | |
parent | 4616a04086c1f9248008add524a9cf74ffecca33 (diff) | |
download | ccpi-efa4313aa57e4c3511eb1d5d88edc37e99f899fa.tar.gz ccpi-efa4313aa57e4c3511eb1d5d88edc37e99f899fa.tar.bz2 ccpi-efa4313aa57e4c3511eb1d5d88edc37e99f899fa.tar.xz ccpi-efa4313aa57e4c3511eb1d5d88edc37e99f899fa.zip |
Add all CCPi patches (patches are not applied automatically, but just collected)
Diffstat (limited to 'patches/astra-toolbox-approximate-projectors/rounding.h')
-rw-r--r-- | patches/astra-toolbox-approximate-projectors/rounding.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/astra-toolbox-approximate-projectors/rounding.h b/patches/astra-toolbox-approximate-projectors/rounding.h new file mode 100644 index 0000000..c1cbffb --- /dev/null +++ b/patches/astra-toolbox-approximate-projectors/rounding.h @@ -0,0 +1,50 @@ +#include <cuda_fp16.h> + +#define precision 8 +#define approximate_interpolation + +#ifdef approximate_interpolation +# ifdef precision +# if precision == 16 +# define texto(v) __float2half(v) +# define texfrom(v) __half2float(v) +# define textype half +# define interpolate(v0, v1, pos) (v0 + pos*(v1-v0)) +# define textocheck(var,msg,val) var=texto(val); +# else +# define precision_mult ((1<<precision)-1) +# define texto(v) ((unsigned char)(precision_mult*v)) +# define texfrom(v) (1.f * v / precision_mult) +# define textype unsigned +# define interpolate(v0, v1, pos) (v0 + ((unsigned)(256 * pos)) * (v1 - v0) / 256) +# define textocheck(var, msg, val) \ + if ((val<0)||(val>1)) { printf("Received out-of-range value (%f) in %s texture fetch\n", val, msg); } \ + var=texto(val); +# endif +# else +# define texto(v) (v) +# define texfrom(v) (v) +# define textype float +# define interpolate(v0, v1, pos) (v0 + pos*(v1-v0)) +# define textocheck(var,msg,val) var=texto(val); +# endif +#else +# ifdef precision +# if precision == 16 +# define texto(v) __half2float(__float2half(v)) +# define textocheck(var,msg,val) var=texto(val); +# else +# define precision_mult ((1<<precision)-1) +# define texto(v) (floor(precision_mult*v)/precision_mult) +# define textocheck(var, msg, val) \ + if ((val<0)||(val>1)) { printf("Received out-of-range value (%f) in %s texture fetch\n", val, msg); } \ + var=texto(val); +# endif +# else +# define texto(v) (v) +# define textocheck(var,msg,val) var=texto(val); +# endif +# define texfrom(v) (v) +# define textype float +# define interpolate(v0, v1, pos) (v0 + pos*(v1-v0)) +#endif |