Open SimeonEhrig opened 1 month ago
So, we need to implement a mechanism, which checks if the standard library is available and working with the active backend.
We could use
#if __cpp_lib_mdspan >= 202207L
// use the c++23 mdspan
# include <mdspan>
using mdspan = std::mdspan;
#else
// use the standalone version
# include <experimental/mdspan>
using mdspan = std::experimental::mdspan;
#endif
For the accessors, we could use
#if __cplusplus >= 202302L
// use the [x,y] accessor
#else
// use the (x,y) accessor
#endif
to decide what to use.
For the accessors, we could use
#if __cplusplus >= 202302L // use the [x,y] accessor #else // use the (x,y) accessor #endif
to decide what to use.
This is, how it would look in practice: https://github.com/SimeonEhrig/MyCpp/blob/28d20632657697533184f95c883739718f8397ad/features/23/mdspan/hello_mspan/main.cpp#L44
Actual I would prefer the wrapper. But in this case, we need to inherit from std::mdspan
to implement the operator()
. Therefore we can also not use the stl implementation directly.
During PR https://github.com/alpaka-group/alpaka/pull/2317#discussion_r1683056959 there was the question if we already support the native implementation of C++23
std::mdspan
. At the moment we do not support it. Instead we use the reference implementation from the kokkos team. This implementation has the two major advantages that it supports C++17 and is working with all our back-ends.@fwyzard Suggest that we should use the native implementation of the standard library if the available. Therefore we have to solve two different problems.
operator[]
with one argument. Instead theoperator()
is used in the kokkos implementation. If C++23 is used, also theoperator[]
is available. The standard library implementation only supports theoperator[]
. Ether we write our codes with an preprocessor if-else or we use a wrapper function to provide theoperator()
function for the standard library implementation.libc++
) and the Microsoft compiler supportsstd::mdspan
. Therefore the following back-ends works or not.Working
Not working
Unknown/no tested
https://en.cppreference.com/w/cpp/compiler_support#cpp23
So, we need to implement a mechanism, which checks if the standard library is available and working with the active backend. Otherwise we need to use the kokkos implementation.