From 4d1e461ef1bfc67b1ae137aa278a5a11c4e1c032 Mon Sep 17 00:00:00 2001 From: Robert Chisholm Date: Tue, 23 Nov 2021 15:48:14 +0000 Subject: [PATCH] Fix bug --- .../runtime/utility/DeviceMacroProperty.cuh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/include/flamegpu/runtime/utility/DeviceMacroProperty.cuh b/include/flamegpu/runtime/utility/DeviceMacroProperty.cuh index 45eb91562..2517d7231 100644 --- a/include/flamegpu/runtime/utility/DeviceMacroProperty.cuh +++ b/include/flamegpu/runtime/utility/DeviceMacroProperty.cuh @@ -102,14 +102,12 @@ class DeviceMacroProperty : public ReadOnlyDeviceMacroProperty { * atomic add * @param val The 2nd operand * @return (this + val) - * @note Only suitable where T is type int32_t, uint32_t, uint64_t, float, double */ __device__ __forceinline__ T operator+(const T& val) const; /** * atomic subtraction * @param val The 2nd operand * @return (this - val) - * @note Only suitable where T is type int32_t or uint32_t */ __device__ __forceinline__ T operator-(const T& val) const; /** @@ -293,11 +291,6 @@ __device__ __forceinline__ DeviceMacroProperty& DeviceMacroProper } template __device__ __forceinline__ T DeviceMacroProperty::operator+(const T& val) const { - static_assert(std::is_same::value || - std::is_same::value || - std::is_same::value || - std::is_same::value || - std::is_same::value, "atomic add only supports the types int32_t/uint32_t/uint64_t/float/double."); #if !defined(SEATBELTS) || SEATBELTS if (I != 1 || J != 1 || K != 1 || W != 1) { DTHROW("Indexing error, property has more dimensions.\n"); @@ -305,13 +298,12 @@ __device__ __forceinline__ T DeviceMacroProperty::operator+(const } else if (this->ptr == nullptr) { return { }; } - this->setCheckWriteFlag(); + this->setCheckReadFlag(); #endif - return atomicAdd(this->ptr, val) + val; + return *this->ptr + val; } template __device__ __forceinline__ T DeviceMacroProperty::operator-(const T& val) const { - static_assert(std::is_same::value || std::is_same::value, "atomic subtract only supports the types int32_t/uint32_t."); #if !defined(SEATBELTS) || SEATBELTS if (I != 1 || J != 1 || K != 1 || W != 1) { DTHROW("Indexing error, property has more dimensions.\n"); @@ -319,9 +311,9 @@ __device__ __forceinline__ T DeviceMacroProperty::operator-(const } else if (this->ptr == nullptr) { return { }; } - this->setCheckWriteFlag(); + this->setCheckReadFlag(); #endif - return atomicSub(this->ptr, val) - val; + return *this->ptr - val; } template __device__ __forceinline__ T DeviceMacroProperty::operator++() {