Skip to content

Commit

Permalink
move msvc compiler macros to new version (#2885)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schellenberger Costa <[email protected]>
Co-authored-by: Bernhard Manfred Gruber <[email protected]>
Co-authored-by: Eric Niebler <[email protected]>
  • Loading branch information
4 people authored Nov 22, 2024
1 parent 667886e commit bc45573
Show file tree
Hide file tree
Showing 138 changed files with 458 additions and 481 deletions.
2 changes: 1 addition & 1 deletion cub/cub/detail/nvtx.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CUB_NAMESPACE_END

# define CUB_DETAIL_NVTX_RANGE_SCOPE(name) CUB_DETAIL_NVTX_RANGE_SCOPE_IF(true, name)
# else // NVTX3_CPP_DEFINITIONS_V1_0
# if defined(_CCCL_COMPILER_MSVC)
# if _CCCL_COMPILER(MSVC)
# pragma message( \
"warning: nvtx3.hpp is available but does not define the V1 API. This is odd. Please open a GitHub issue at: https://github.com/NVIDIA/cccl/issues.")
# else
Expand Down
8 changes: 4 additions & 4 deletions cub/cub/util_compiler.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
#define CUB_DEVICE_COMPILER_CLANG 4

// figure out which host compiler we're using
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
//! deprecated [Since 2.7]
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_MSVC
//! deprecated [Since 2.7]
# define CUB_MSVC_VERSION _CCCL_MSVC_VERSION
# define CUB_MSVC_VERSION _MSC_VER
//! deprecated [Since 2.7]
# define CUB_MSVC_VERSION_FULL _CCCL_MSVC_VERSION_FULL
# define CUB_MSVC_VERSION_FULL _MSC_FULL_VER
#elif _CCCL_COMPILER(CLANG)
//! deprecated [Since 2.7]
# define CUB_HOST_COMPILER CUB_HOST_COMPILER_CLANG
Expand All @@ -89,7 +89,7 @@
#if defined(_CCCL_CUDA_COMPILER_NVCC) || defined(_CCCL_CUDA_COMPILER_NVHPC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_NVCC
#elif defined(_CCCL_COMPILER_MSVC)
#elif _CCCL_COMPILER(MSVC)
//! deprecated [Since 2.7]
# define CUB_DEVICE_COMPILER CUB_DEVICE_COMPILER_MSVC
#elif _CCCL_COMPILER(GCC)
Expand Down
6 changes: 3 additions & 3 deletions cub/cub/util_cpp_dialect.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
# define CUB_CPP_DIALECT _CCCL_STD_VER

// Define CUB_COMPILER_DEPRECATION macro:
# if defined(_CCCL_COMPILER_MSVC)
# if _CCCL_COMPILER(MSVC)
# define CUB_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg))
# else // clang / gcc:
# define CUB_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(GCC warning #msg)
Expand All @@ -101,10 +101,10 @@
CUB_COMPILER_DEPRECATION(GCC 5.0);
# elif _CCCL_COMPILER(CLANG, <, 7)
CUB_COMPILER_DEPRECATION(Clang 7.0);
# elif defined(_CCCL_COMPILER_MSVC) && _CCCL_MSVC_VERSION < 1910
# elif _CCCL_COMPILER(MSVC, <, 19, 10)
// <2017. Hard upgrade message:
CUB_COMPILER_DEPRECATION(MSVC 2019(19.20 / 16.0 / 14.20));
# elif defined(_CCCL_COMPILER_MSVC) && _CCCL_MSVC_VERSION < 1920
# elif _CCCL_COMPILER(MSVC2017)
// >=2017, <2019. Soft deprecation message:
CUB_COMPILER_DEPRECATION_SOFT(MSVC 2019(19.20 / 16.0 / 14.20), MSVC 2017);
# endif
Expand Down
2 changes: 1 addition & 1 deletion cub/cub/util_deprecated.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#elif _CCCL_STD_VER >= 2014
# define CUB_DEPRECATED [[deprecated]]
# define CUB_DEPRECATED_BECAUSE(MSG) [[deprecated(MSG)]]
#elif defined(_CCCL_COMPILER_MSVC)
#elif _CCCL_COMPILER(MSVC)
# define CUB_DEPRECATED __declspec(deprecated)
# define CUB_DEPRECATED_BECAUSE(MSG) __declspec(deprecated(MSG))
#elif _CCCL_COMPILER(CLANG)
Expand Down
6 changes: 3 additions & 3 deletions cub/test/catch2_test_device_for_each_in_extents.cu
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
******************************************************************************/
#include <cub/config.cuh>

// TODO: remove _CCCL_COMPILER_MSVC check after MSVC bug related to vector comparison is fixed:
// TODO: remove _CCCL_COMPILER(MSVC) check after MSVC bug related to vector comparison is fixed:
// "error C3546: '...': there are no parameter packs available to expand"
#if __cccl_lib_mdspan && !defined(_CCCL_COMPILER_MSVC)
#if __cccl_lib_mdspan && !_CCCL_COMPILER(MSVC)

# include <cub/device/device_for.cuh>

Expand Down Expand Up @@ -181,4 +181,4 @@ C2H_TEST("DeviceForEachInExtents 3D dynamic", "[ForEachInExtents][dynamic][devic
REQUIRE(h_output == h_output_gpu);
}

#endif // __cccl_lib_mdspan && !defined(_CCCL_COMPILER_MSVC)
#endif // __cccl_lib_mdspan && !_CCCL_COMPILER(MSVC)
4 changes: 2 additions & 2 deletions cub/test/catch2_test_device_transform.cu
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ struct alignas(Alignment) overaligned_addable_t

using overaligned_types =
c2h::type_list<overaligned_addable_t<32>
#ifndef _CCCL_COMPILER_MSVC // error C2719: [...] formal parameter with requested alignment of 256 won't be aligned
#if !_CCCL_COMPILER(MSVC) // error C2719: [...] formal parameter with requested alignment of 256 won't be aligned
,
overaligned_addable_t<256>
#endif // _CCCL_COMPILER_MSVC
#endif // !_CCCL_COMPILER(MSVC)
>;

// test with types exceeding the memcpy_async and bulk copy alignments (16 and 128 bytes respectively)
Expand Down
2 changes: 1 addition & 1 deletion cub/test/test_warning_suppression.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// C4127: conditional expression is constant
// This can be fixed with `if constexpr` when available, but there's no way to
// silence these pre-C++17.
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
# if _CCCL_STD_VER < 2017
# pragma warning(disable : 4127)
# endif
Expand Down
8 changes: 4 additions & 4 deletions cudax/examples/stf/fdtd_mgpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using namespace cuda::experimental::stf;

// FIXME : MSVC has trouble with box constructors
#if !defined(_CCCL_COMPILER_MSVC)
#if !_CCCL_COMPILER(MSVC)
void write_vtk_2D(const std::string& filename, slice<double, 3> Ez, double dx, double dy, double /*unused*/)
{
FILE* f = fopen(filename.c_str(), "w");
Expand Down Expand Up @@ -99,11 +99,11 @@ _CCCL_DEVICE double Source(double t, double x, double y, double z)
constexpr double k = 2 * pi / wavelength;
return sin(k * x - omega * t);
}
#endif // !defined(_CCCL_COMPILER_MSVC)
#endif // !_CCCL_COMPILER(MSVC)

int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
#if !defined(_CCCL_COMPILER_MSVC)
#if !_CCCL_COMPILER(MSVC)
context ctx;

// Initialize the time loop
Expand Down Expand Up @@ -292,5 +292,5 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
};

ctx.finalize();
#endif // !defined(_CCCL_COMPILER_MSVC)
#endif // !_CCCL_COMPILER(MSVC)
}
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__async/lazy.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct __lazy_tupl<_CUDA_VSTD::index_sequence<_Idx...>, _Ts...> : __detail::__la
bool __engaged_[sizeof...(_Ts)] = {};
};

#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
template <class... _Ts>
struct __mk_lazy_tuple_
{
Expand Down
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__async/meta.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ inline constexpr bool __type_is_error<_ERROR<_What...>&> = true;
// True if any of the types in _Ts... are errors; false otherwise.
template <class... _Ts>
inline constexpr bool __type_contains_error =
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
(__type_is_error<_Ts> || ...);
#else
__ustdex_unhandled_error(static_cast<_CUDA_VSTD::__type_list<_Ts...>*>(nullptr));
Expand Down
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__async/tuple.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template <class _Fn, class _Tupl, class... _Us>
using __apply_result_t =
decltype(__declval<_Tupl>().__apply(__declval<_Fn>(), __declval<_Tupl>(), __declval<_Us>()...));

#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
template <class... _Ts>
struct __mk_tuple_
{
Expand Down
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__async/variant.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public:
}
};

#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
template <class... _Ts>
struct __mk_variant_
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

#include <cuda/experimental/__memory_resource/any_resource.cuh>

#if _CCCL_STD_VER >= 2014 && !defined(_CCCL_COMPILER_MSVC_2017) \
&& defined(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017) && defined(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)

//! @file
//! The \c uninitialized_async_buffer class provides a typed buffer allocated in stream-order from a given memory
Expand Down Expand Up @@ -299,6 +298,6 @@ using uninitialized_async_device_buffer = uninitialized_async_buffer<_Tp, _CUDA_

} // namespace cuda::experimental

#endif // _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER_MSVC_2017 && LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE
#endif // _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017) && LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#endif //__CUDAX__CONTAINERS_UNINITIALIZED_ASYNC_BUFFER_H
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

#include <cuda/experimental/__memory_resource/any_resource.cuh>

#if _CCCL_STD_VER >= 2014 && !defined(_CCCL_COMPILER_MSVC_2017) \
&& defined(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017) && defined(LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)

//! @file
//! The \c uninitialized_buffer class provides a typed buffer allocated from a given memory resource.
Expand Down Expand Up @@ -264,6 +263,6 @@ using uninitialized_device_buffer = uninitialized_buffer<_Tp, _CUDA_VMR::device_

} // namespace cuda::experimental

#endif // _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER_MSVC_2017 && LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE
#endif // _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017) && LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#endif //__CUDAX__CONTAINERS_UNINITIALIZED_BUFFER_H
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__device/device.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public:
using attr_result_t = typename detail::__dev_attr<_Attr>::type;

#ifndef _CCCL_DOXYGEN_INVOKED // Do not document
# if defined(_CCCL_COMPILER_MSVC)
# if _CCCL_COMPILER(MSVC)
// When __EDG__ is defined, std::construct_at will not permit constructing
// a device object from an __emplace_device object. This is a workaround.
device(detail::__emplace_device __ed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#endif

// cuda::mr is unavable on MSVC 2017
#if defined(_CCCL_COMPILER_MSVC_2017)
#if _CCCL_COMPILER(MSVC2017)
# error "The any_resource header is not supported on MSVC 2017"
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif // no system header

// cudaMallocAsync was introduced in CTK 11.2
#if !defined(_CCCL_COMPILER_MSVC_2017) && _CCCL_CUDACC_AT_LEAST(11, 2)
#if !_CCCL_COMPILER(MSVC2017) && _CCCL_CUDACC_AT_LEAST(11, 2)

# if defined(_CCCL_CUDA_COMPILER_CLANG)
# include <cuda_runtime.h>
Expand Down Expand Up @@ -428,6 +428,6 @@ public:

# endif // _CCCL_STD_VER >= 2014

#endif // !_CCCL_COMPILER_MSVC_2017 && _CCCL_CUDACC_AT_LEAST(11, 2)
#endif // !_CCCL_COMPILER(MSVC2017) && _CCCL_CUDACC_AT_LEAST(11, 2)

#endif // _CUDAX__MEMORY_RESOURCE_DEVICE_MEMORY_POOL
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif // no system header

// cudaMallocAsync was introduced in CTK 11.2
#if !defined(_CCCL_COMPILER_MSVC_2017) && _CCCL_CUDACC_AT_LEAST(11, 2)
#if !_CCCL_COMPILER(MSVC2017) && _CCCL_CUDACC_AT_LEAST(11, 2)

# if defined(_CCCL_CUDA_COMPILER_CLANG)
# include <cuda_runtime.h>
Expand Down Expand Up @@ -417,6 +417,6 @@ static_assert(_CUDA_VMR::resource_with<device_memory_resource, _CUDA_VMR::device

# endif // _CCCL_STD_VER >= 2014

#endif // !_CCCL_COMPILER_MSVC_2017 && _CCCL_CUDACC_AT_LEAST(11, 2)
#endif // !_CCCL_COMPILER(MSVC2017) && _CCCL_CUDACC_AT_LEAST(11, 2)

#endif //_CUDAX__MEMORY_RESOURCE_CUDA_DEVICE_MEMORY_RESOURCE
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#endif

// cuda::mr is unavable on MSVC 2017
#if defined(_CCCL_COMPILER_MSVC_2017)
#if _CCCL_COMPILER(MSVC2017)
# error "The shared_resource header is not supported on MSVC 2017"
#endif

Expand Down
8 changes: 4 additions & 4 deletions cudax/include/cuda/experimental/__stf/graph/graph_task.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ public:
return mv(*this);
}

#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
// TODO (miscco): figure out why MSVC is complaining about unreachable code here
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4702) // unreachable code
#endif // _CCCL_COMPILER_MSVC
#endif // _CCCL_COMPILER(MSVC)

template <typename Fun>
void operator->*(Fun&& f)
Expand Down Expand Up @@ -518,9 +518,9 @@ public:
::std::apply(f, tuple_prepend(mv(childGraph), typed_deps()));
}
}
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
_CCCL_DIAG_POP
#endif // _CCCL_COMPILER_MSVC
#endif // _CCCL_COMPILER(MSVC)

private:
auto typed_deps()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,19 +492,19 @@ protected:
return nullptr;
}

#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_MSVC(4702) // unreachable code
#endif // _CCCL_COMPILER_MSVC
#endif // _CCCL_COMPILER(MSVC)
virtual event_list stream_to_event_list(cudaStream_t, ::std::string) const
{
fprintf(stderr, "Internal error.\n");
abort();
return event_list();
}
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
_CCCL_DIAG_POP
#endif // _CCCL_COMPILER_MSVC
#endif // _CCCL_COMPILER(MSVC)

virtual size_t epoch() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#ifndef _CCCL_DOXYGEN_INVOKED // do not document

# if !defined(_CCCL_COMPILER_MSVC)
# if !_CCCL_COMPILER(MSVC)
# define STATEFUL_CALLBACKS

namespace cuda::experimental::stf
Expand Down Expand Up @@ -602,5 +602,5 @@ inline bool cudaCallbackQueueProgress(callback_queue* q, bool flag)

} // end namespace cuda::experimental::stf

# endif // !_CCCL_COMPILER_MSVC
# endif // !_CCCL_COMPILER(MSVC)
#endif // _CCCL_DOXYGEN_INVOKED do not document
4 changes: 2 additions & 2 deletions cudax/include/cuda/experimental/__stf/stream/stream_ctx.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ UNITTEST("movable stream_task")

// FIXME : This test is causing some compiler errors with MSVC, so we disable
// it on MSVC for now
# if !defined(_CCCL_COMPILER_MSVC)
# if !_CCCL_COMPILER(MSVC)
UNITTEST("logical_data_untyped moveable")
{
using namespace cuda::experimental::stf;
Expand Down Expand Up @@ -852,7 +852,7 @@ UNITTEST("logical_data_untyped moveable")

ctx.finalize();
};
# endif // !_CCCL_COMPILER_MSVC
# endif // !_CCCL_COMPILER(MSVC)

# ifdef __CUDACC__
namespace reserved
Expand Down
2 changes: 1 addition & 1 deletion cudax/include/cuda/experimental/__stf/utility/core.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace cuda::experimental::stf
{

// Hack setenv on Windows
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
/**
* @brief Sets an environment variable, mimicking the behavior of `std::setenv` on Windows.
*
Expand Down
12 changes: 6 additions & 6 deletions cudax/include/cuda/experimental/__stf/utility/traits.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ namespace reserved
template <typename T>
constexpr ::std::string_view type_name_IMPL()
{
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
return __FUNCSIG__;
#else // ^^^ _CCCL_COMPILER_MSVC ^^^ / vvv !_CCCL_COMPILER_MSVC vvv
#else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv
return __PRETTY_FUNCTION__;
#endif // !_CCCL_COMPILER_MSVC
#endif // !_CCCL_COMPILER(MSVC)
}

// Length of prefix and suffix in __PRETTY_FUNCTION__ when used with `type_name`.
Expand All @@ -73,14 +73,14 @@ inline constexpr ::std::pair<size_t, size_t> type_name_affixes = [] {
template <class T>
constexpr ::std::string_view type_name_impl()
{
#if defined(_CCCL_COMPILER_MSVC)
#if _CCCL_COMPILER(MSVC)
constexpr ::std::string_view p = __FUNCSIG__;
// MSVC does not provide constexpr methods so we make this utility much simpler and return __FUNCSIG__ directly
return p;
#else // ^^^ _CCCL_COMPILER_MSVC ^^^ / vvv !_CCCL_COMPILER_MSVC vvv
#else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv
::std::string_view p = __PRETTY_FUNCTION__;
return p.substr(type_name_affixes.first, p.size() - type_name_affixes.first - type_name_affixes.second);
#endif // !_CCCL_COMPILER_MSVC
#endif // !_CCCL_COMPILER(MSVC)
}

} // namespace reserved
Expand Down
Loading

0 comments on commit bc45573

Please sign in to comment.