alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
mdspan.hpp
Go to the documentation of this file.
1/* Copyright 2026 Axel Hübl, Benjamin Worpitz, Matthias Werner, Andrea Bocci, Jan Stephan, Bernhard Manfred Gruber,
2 * Aurora Perego, Simone Balducci
3 * SPDX-License-Identifier: MPL-2.0
4 */
5
6// no pragma once, because the header defines alias namespaces
7
8#ifdef ALPAKA_USE_MDSPAN
9# ifdef ALPAKA_HAS_STD_MDSPAN
10// mdspan from the standard library
11# include <mdspan>
12# include <version>
13
14namespace alpaka::experimental
15{
16 // Import C++23 mdspan into alpaka::experimental namespace.
17 // See https://wg21.link/P0009R18 .
18 using ::std::default_accessor;
19 using ::std::dextents;
20 using ::std::extents;
21 using ::std::layout_left;
22 using ::std::layout_right;
23 using ::std::layout_stride;
24 using ::std::mdspan;
25# ifdef __cpp_lib_submdspan
26 // Import C++26 submdspan into alpaka::experimental namespace.
27 // See https://wg21.link/P2630R4 .
28 using ::std::full_extent;
29 using ::std::submdspan;
30# endif
31} // namespace alpaka::experimental
32
33# else
34
35# ifdef ALPAKA_ACC_SYCL_ENABLED
36// do not expose the macro definition of printf
37# pragma push_macro("printf")
38# ifdef printf
39# undef printf
40# endif
41# endif // ALPAKA_ACC_SYCL_ENABLED
42
43# if defined(ALPAKA_ACC_SYCL_ENABLED) && (defined(ALPAKA_SYCL_ONEAPI_FPGA) || defined(ALPAKA_SYCL_TARGET_FPGA))
44// the fpga compiler does not handle well the [[no_unique_address]] attribute, resulting in:
45// GEP has !intel-tbaa annotation but its "shape" is unexpected!
46// /opt/intel/oneapi/compiler/2025.0/bin/compiler/llvm-link: error: linked module is broken!
47// icpx: error: sycl-link command failed with exit code 1 (use -v to see invocation)
48# include <experimental/__p0009_bits/config.hpp>
49# undef MDSPAN_IMPL_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS
50# undef MDSPAN_IMPL_NO_UNIQUE_ADDRESS
51# define MDSPAN_IMPL_NO_UNIQUE_ADDRESS
52# endif
53
54// mdspan from the Kokkos reference implementation
55# define MDSPAN_IMPL_STANDARD_NAMESPACE alpaka::experimental
56# include <experimental/mdspan>
57
58# ifdef ALPAKA_ACC_SYCL_ENABLED
59// restore the macro definition of printf
60# pragma pop_macro("printf")
61# endif // ALPAKA_ACC_SYCL_ENABLED
62# endif
63#endif