Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove relaxed constexpr #775

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ target_include_directories(matx INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOU
target_include_directories(matx INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/matx/kernels>"
"$<INSTALL_INTERFACE:include/matx/kernels>")
target_compile_features(matx INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_options(matx INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>)

# 11.2 and above required for async allocation
if (CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.5)
Expand Down
3 changes: 1 addition & 2 deletions cmake/versions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"packages": {
"CCCL": {
"version": "2.4.0",
"version": "2.7.0-rc2",
tbensonatl marked this conversation as resolved.
Show resolved Hide resolved
"git_shallow": true,
"git_url": "https://github.com/NVIDIA/cccl.git",
"git_tag": "1c009d2"
}
}
}
2 changes: 1 addition & 1 deletion docs_input/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Required Third-party Dependencies
---------------------------------

- `CPM <https://github.com/cpm-cmake/CPM.cmake>`_ (* Included in the project source and does not require a separate download)
- `CCCL <https://github.com/NVIDIA/cccl>`_ 2.4.0+
- `CCCL <https://github.com/NVIDIA/cccl>`_ 2.7.0+


Optional Third-party Dependencies
Expand Down
3 changes: 1 addition & 2 deletions include/matx/core/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

#include "matx/core/error.h"
#include "matx/core/nvtx.h"
#include <cuda/std/__algorithm>
#include <cuda/std/__algorithm>
#include <cuda/std/functional>

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/clone.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ IGNORE_WARNING_POP_GCC
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
4 changes: 2 additions & 2 deletions include/matx/operators/collapse.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down Expand Up @@ -235,7 +235,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/fftshift.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/interleaved.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/kronecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

template <typename ShapeType, typename Executor>
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/permute.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ IGNORE_WARNING_POP_GCC
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int32_t dim) const
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/planar.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/r2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/remap.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/repmat.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

template <typename ShapeType, typename Executor>
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/reshape.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int32_t dim) const
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/reverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
29 changes: 28 additions & 1 deletion include/matx/operators/scalar_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,20 @@ template <typename T> static __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ auto
return matx::sin(v1);
}
else {
// This should go away once CCCL adds <cmath> support
#ifdef __CUDACC__
if constexpr (std::is_same_v<T, float>) {
return ::sinf(v1);
}
else if constexpr (std::is_same_v<T, double>) {
return ::sin(v1);
}
else {
matx::sin(v1);
}
#else
return cuda::std::sin(v1);
#endif
}
}
template <typename T> struct SinF {
Expand All @@ -250,7 +263,20 @@ template <typename T> static __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ auto
return matx::cos(v1);
}
else {
// This should go away once CCCL adds <cmath> support
#ifdef __CUDACC__
if constexpr (std::is_same_v<T, float>) {
return ::cosf(v1);
}
else if constexpr (std::is_same_v<T, double>) {
return ::cos(v1);
}
else {
matx::cos(v1);
}
#else
return cuda::std::cos(v1);
#endif
}
}
template <typename T> struct CosF {
Expand Down Expand Up @@ -691,7 +717,8 @@ static __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ auto _internal_isinf(T v1)
return cuda::std::isinf(static_cast<typename castType::value_type>(v1.real())) || cuda::std::isinf(static_cast<typename castType::value_type>(v1.imag()));
} else {
return cuda::std::isinf(static_cast<castType>(v1));
}
}

}
template <typename T>
struct IsInf {
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(index_t i)
{
return std::as_const(*this).template operator()(i);
return cuda::std::as_const(*this).template operator()(i);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/self.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/shift.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

template <typename ShapeType, typename Executor>
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
Expand Down
2 changes: 1 addition & 1 deletion include/matx/operators/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace matx
template <typename... Is>
__MATX_INLINE__ __MATX_DEVICE__ __MATX_HOST__ decltype(auto) operator()(Is... indices)
{
return std::as_const(*this).template operator()(indices...);
return cuda::std::as_const(*this).template operator()(indices...);
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank() noexcept
Expand Down
1 change: 1 addition & 0 deletions include/matx/operators/toeplitz.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "matx/core/type_utils.h"
#include "matx/operators/base_operator.h"
#include <cuda/std/__algorithm/transform.h>

namespace matx
{
Expand Down
6 changes: 3 additions & 3 deletions include/matx/transforms/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ void __MATX_INLINE__ argmax_impl(OutType dest, TensorIndexType &idest, const InT
#ifdef __CUDACC__
MATX_NVTX_START("argmax_impl(" + get_type_str(in) + ")", matx::MATX_NVTX_LOG_API)

const auto initial_value = cuda::std::make_tuple(static_cast<matx::index_t>(-1), std::numeric_limits<typename InType::value_type>::lowest());
const auto initial_value = thrust::make_tuple(static_cast<matx::index_t>(-1), std::numeric_limits<typename InType::value_type>::lowest());
using reduce_param_type = typename detail::ReduceParams_t<typename detail::CustomArgMaxCmp, decltype(initial_value)>;
auto reduce_params = reduce_param_type{detail::CustomArgMaxCmp{}, initial_value};

Expand Down Expand Up @@ -2219,7 +2219,7 @@ void __MATX_INLINE__ argmin_impl(OutType dest, TensorIndexType &idest, const InT
#ifdef __CUDACC__
MATX_NVTX_START("argmin_impl(" + get_type_str(in) + ")", matx::MATX_NVTX_LOG_API)

const auto initial_value = cuda::std::make_tuple(static_cast<matx::index_t>(-1), std::numeric_limits<typename InType::value_type>::max());
const auto initial_value = thrust::make_tuple(static_cast<matx::index_t>(-1), std::numeric_limits<typename InType::value_type>::max());
using reduce_param_type = typename detail::ReduceParams_t<typename detail::CustomArgMinCmp, decltype(initial_value)>;
auto reduce_params = reduce_param_type{detail::CustomArgMinCmp{}, initial_value};

Expand Down Expand Up @@ -2307,7 +2307,7 @@ void __MATX_INLINE__ argminmax_impl(OutType destmin, TensorIndexType &idestmin,
#ifdef __CUDACC__
MATX_NVTX_START("argminmax_impl(" + get_type_str(in) + ")", matx::MATX_NVTX_LOG_API)

const auto initial_value = cuda::std::make_tuple(
const auto initial_value = thrust::make_tuple(
static_cast<matx::index_t>(-1),
std::numeric_limits<typename InType::value_type>::max(),
static_cast<matx::index_t>(-1),
Expand Down
Loading