From 730659b0e9952ad1cf7496af1485a698257b6273 Mon Sep 17 00:00:00 2001 From: Ingo Wald Date: Thu, 15 Jan 2026 09:51:39 -0700 Subject: [PATCH 1/3] - added missing operator-= and operator+= for vec types - fixed broken/missing include when used with hip compiler Signed-off-by: Ingo Wald --- cuBQL/math/box.h | 9 ++++++++- cuBQL/math/common.h | 1 + cuBQL/math/vec.h | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cuBQL/math/box.h b/cuBQL/math/box.h index f0355de..07736c4 100644 --- a/cuBQL/math/box.h +++ b/cuBQL/math/box.h @@ -134,9 +134,16 @@ namespace cuBQL { inline __cubql_both vec_t center() const { return (this->lower+this->upper)/scalar_t(2); } + /*! return a vector that give the size of the box in x,y,...etc */ inline __cubql_both vec_t size() const { return this->upper - this->lower; } - + + /*! return a vector that give the size of the box in x,y,...etc + (also known as the 'span' of a box, due to the it being the + vector that spans the box from lower to upper) */ + inline __cubql_both vec_t span() const + { return this->upper - this->lower; } + /*! returns TWICE the center (which happens to be the SUM of lower an dupper). Note this 'conceptually' the same as 'center()', but without the nasty division that may lead to rounding diff --git a/cuBQL/math/common.h b/cuBQL/math/common.h index 998fd2b..f83211e 100644 --- a/cuBQL/math/common.h +++ b/cuBQL/math/common.h @@ -25,6 +25,7 @@ # include #endif #if defined(__HIPCC__) +# include # include # include #elif defined(__CUDACC__) diff --git a/cuBQL/math/vec.h b/cuBQL/math/vec.h index 126b83a..43c94eb 100644 --- a/cuBQL/math/vec.h +++ b/cuBQL/math/vec.h @@ -310,6 +310,16 @@ namespace cuBQL { vec_t operator+(vec_t v) { return v; } + template + inline __cubql_both + vec_t &operator-=(vec_t &self, vec_t v) + { return self = self-v; return self; } + + template + inline __cubql_both + vec_t &operator+=(vec_t &self, vec_t v) + { return self = self+v; return self; } + #if CUBQL_SUPPORT_CUDA_VECTOR_TYPES # define CUBQL_OPERATOR_CUDA_T(long_op, op) \ From f56eb7fe32da0bf6d730d82858e35c748b844eb1 Mon Sep 17 00:00:00 2001 From: Ingo Wald Date: Thu, 15 Jan 2026 20:43:50 -0700 Subject: [PATCH 2/3] added vec4=vec3+w constructor Signed-off-by: Ingo Wald --- cuBQL/math/common.h | 5 +++++ cuBQL/math/vec.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/cuBQL/math/common.h b/cuBQL/math/common.h index f83211e..710786e 100644 --- a/cuBQL/math/common.h +++ b/cuBQL/math/common.h @@ -63,7 +63,12 @@ # define CUBQL_INTERFACE /* nothing - currently not building any special 'cubql.dll' */ #ifndef __PRETTY_FUNCTION__ +# if defined(__func__) +# define __PRETTY_FUNCTION__ __func__ +// # define __PRETTY_FUNCTION__ __FILE__##"::"##__LINE__##": "##__FUNCTION__ +# else # define __PRETTY_FUNCTION__ __FUNCTION__ +# endif #endif diff --git a/cuBQL/math/vec.h b/cuBQL/math/vec.h index 43c94eb..b489fcd 100644 --- a/cuBQL/math/vec.h +++ b/cuBQL/math/vec.h @@ -206,6 +206,9 @@ namespace cuBQL { inline __cubql_both vec_t(const vec_t_data &o) { this->x = (o.x); this->y = (o.y); this->z = (o.z); this->w = (o.w); } + inline __cubql_both vec_t(const vec_t_data &o, T w) + { this->x = (o.x); this->y = (o.y); this->z = (o.z); this->w = w; } + template explicit __cubql_both vec_t(const vec_t_data &o) { this->x = T(o.x); this->y = T(o.y); this->z = T(o.z); this->w = T(o.w); } From 2933f0d37092e80f1d6647be0dc8c9ee042b3b34 Mon Sep 17 00:00:00 2001 From: Ingo Wald Date: Fri, 16 Jan 2026 10:28:41 -0700 Subject: [PATCH 3/3] slightly nicer writing of operator-= and op+= Signed-off-by: Ingo Wald --- cuBQL/math/vec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cuBQL/math/vec.h b/cuBQL/math/vec.h index b489fcd..474a110 100644 --- a/cuBQL/math/vec.h +++ b/cuBQL/math/vec.h @@ -316,12 +316,12 @@ namespace cuBQL { template inline __cubql_both vec_t &operator-=(vec_t &self, vec_t v) - { return self = self-v; return self; } + { self = self-v; return self; } template inline __cubql_both vec_t &operator+=(vec_t &self, vec_t v) - { return self = self+v; return self; } + { self = self+v; return self; } #if CUBQL_SUPPORT_CUDA_VECTOR_TYPES