Skip to content

Commit

Permalink
Fixed issues with host compiler with C++17 and C++20 modes
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffburdick committed Aug 9, 2024
1 parent 39b4372 commit 958551d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 10 additions & 2 deletions include/matx/core/half.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,11 @@ __MATX_HOST__ __MATX_DEVICE__ __MATX_INLINE__ matxHalf<T> rsqrt(const matxHalf<T
#ifdef __CUDA_ARCH__
return hrsqrt(x.x);
#else
return static_cast<T>(::rsqrt(static_cast<float>(x.x)));
#ifdef __CUDACC__
return static_cast<__nv_bfloat16>(::rsqrt(static_cast<float>(x.x)));
#else
return static_cast<__nv_bfloat16>(1.f / cuda::std::sqrt(static_cast<float>(x.x)));
#endif
#endif
}

Expand All @@ -719,7 +723,11 @@ rsqrt(const matxHalf<__nv_bfloat16> &x)
#if __CUDA_ARCH__ >= 800
return hrsqrt(x.x);
#else
return static_cast<__nv_bfloat16>(::rsqrt(static_cast<float>(x.x)));
#ifdef __CUDACC__
return static_cast<__nv_bfloat16>(::rsqrt(static_cast<float>(x.x)));
#else
return static_cast<__nv_bfloat16>(1.f / cuda::std::sqrt(static_cast<float>(x.x)));
#endif
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions include/matx/core/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ namespace matx
* @brief Default construct a smart_pointer_buffer. This should only be used when temporarily
* creating an empty tensor for construction later.
*/
smart_pointer_buffer<T>() {};
smart_pointer_buffer() {};

/**
* @brief Construct a new smart pointer buffer from an existing object
*
* @param ptr Smart poiner object
* @param size Size of allocation
*/
smart_pointer_buffer<T>(T &&ptr, size_t size) : data_(std::forward<T>(ptr)), size_(size) {
smart_pointer_buffer(T &&ptr, size_t size) : data_(std::forward<T>(ptr)), size_(size) {
static_assert(is_smart_ptr_v<T>);
}

Expand Down Expand Up @@ -328,7 +328,7 @@ namespace matx
*
* @param rhs Object to move from
*/
smart_pointer_buffer<T>(smart_pointer_buffer<T> &&rhs) {
smart_pointer_buffer(smart_pointer_buffer<T> &&rhs) {
size_ = rhs.size_;
data_ = std::move(rhs.data_);
}
Expand All @@ -337,7 +337,7 @@ namespace matx
* @brief Default destructor
*
*/
~smart_pointer_buffer<T>() = default;
~smart_pointer_buffer() = default;

/**
* @brief Get underlying data pointer
Expand Down
4 changes: 4 additions & 0 deletions include/matx/operators/scalar_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ static __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ auto _internal_rsqrt(T v1)
return rsqrt(v1);
}
else {
#ifdef __CUDACC__
return ::rsqrt(v1);
#else
return static_cast<T>(1) / sqrt(v1);
#endif
}
}
template <typename T> struct RSqrtF {
Expand Down

0 comments on commit 958551d

Please sign in to comment.