Skip to content

Commit

Permalink
Restrict the use of ] to CXX 20 only. (#764)
Browse files Browse the repository at this point in the history
Close #740 .

Found by @achirkin , the size of `mapping` is non-deterministic. This is caused by the macro definition around whether `no_unique_address` is supported with nvcc. This PR uses the standard cpp version to define the macro regardless of the compiler being used.

Authors:
  - Jiaming Yuan (https://github.com/trivialfis)

Approvers:
  - Mark Hoemmen (https://github.com/mhoemmen)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #764
  • Loading branch information
trivialfis authored Jul 28, 2022
1 parent ad55c7b commit 2325d2b
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or
# define _MDSPAN_PRESERVE_STANDARD_LAYOUT 1
#endif

// no unique address starts working in NVCC 11.6
#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) && \
(!defined(__NVCC__) || ((__CUDACC_VER_MAJOR__ > 11) && (__CUDACC_VER_MINOR__ > 5)))
# if (__has_cpp_attribute(no_unique_address) >= 201803L) && !defined(_MDSPAN_COMPILER_MSVC)
#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
# if MDSPAN_HAS_CXX_20 && (__has_cpp_attribute(no_unique_address) >= 201803L)
# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
# define _MDSPAN_NO_UNIQUE_ADDRESS [[no_unique_address]]
# else
Expand Down

0 comments on commit 2325d2b

Please sign in to comment.