Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Nov 23, 2021
1 parent a5aa729 commit 4d1e461
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions include/flamegpu/runtime/utility/DeviceMacroProperty.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ class DeviceMacroProperty : public ReadOnlyDeviceMacroProperty<T, I, J, K, W> {
* 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;
/**
Expand Down Expand Up @@ -293,35 +291,29 @@ __device__ __forceinline__ DeviceMacroProperty<T, I, J, K, W>& DeviceMacroProper
}
template<typename T, unsigned int I, unsigned int J, unsigned int K, unsigned int W>
__device__ __forceinline__ T DeviceMacroProperty<T, I, J, K, W>::operator+(const T& val) const {
static_assert(std::is_same<T, int32_t>::value ||
std::is_same<T, uint32_t>::value ||
std::is_same<T, uint64_t>::value ||
std::is_same<T, float>::value ||
std::is_same<T, double>::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");
return { };
} else if (this->ptr == nullptr) {
return { };
}
this->setCheckWriteFlag();
this->setCheckReadFlag();
#endif
return atomicAdd(this->ptr, val) + val;
return *this->ptr + val;
}
template<typename T, unsigned int I, unsigned int J, unsigned int K, unsigned int W>
__device__ __forceinline__ T DeviceMacroProperty<T, I, J, K, W>::operator-(const T& val) const {
static_assert(std::is_same<T, uint32_t>::value || std::is_same<T, int32_t>::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");
return { };
} else if (this->ptr == nullptr) {
return { };
}
this->setCheckWriteFlag();
this->setCheckReadFlag();
#endif
return atomicSub(this->ptr, val) - val;
return *this->ptr - val;
}
template<typename T, unsigned int I, unsigned int J, unsigned int K, unsigned int W>
__device__ __forceinline__ T DeviceMacroProperty<T, I, J, K, W>::operator++() {
Expand Down

0 comments on commit 4d1e461

Please sign in to comment.