Debian Codegraph @

packages/kokkos-kernels/blas/tpls/KokkosBlas1_nrm2_tpl_spec_avail.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16
17 #ifndef KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_HPP_
18 #define KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_HPP_
19
20 namespace KokkosBlas {
21 namespace Impl {
22 // Specialization struct which defines whether a specialization exists
23 template <class execution_space, class RV, class XMV, int Xrank = XMV::rank>
24 struct nrm2_tpl_spec_avail {
25 enum : bool { value = false };
26 };
27 } // namespace Impl
28 } // namespace KokkosBlas
29
30 namespace KokkosBlas {
31 namespace Impl {
32 // Generic Host side BLAS (could be MKL or whatever)
33 #ifdef KOKKOSKERNELS_ENABLE_TPL_BLAS
34 // double
35 #define KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_BLAS(SCALAR, LAYOUT, MEMSPACE) \
36 template <class ExecSpace> \
37 struct nrm2_tpl_spec_avail<ExecSpace, \
38 Kokkos::View<typename Kokkos::Details::InnerProductSpaceTraits<SCALAR>::mag_type, LAYOUT, \
39 Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
40 Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<ExecSpace, MEMSPACE>, \
41 Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
42 1> { \
43 enum : bool { value = true }; \
44 };
45
46 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_BLAS(double, Kokkos::LayoutLeft, Kokkos::HostSpace)
47 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_BLAS(float, Kokkos::LayoutLeft, Kokkos::HostSpace)
48 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_BLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::HostSpace)
49 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL_BLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::HostSpace)
50
51 #endif
52
53 #define KOKKOSBLAS1_NRM2_TPL_SPEC(SCALAR, LAYOUT, EXECSPACE, MEMSPACE) \
54 template <> \
55 struct nrm2_tpl_spec_avail<EXECSPACE, \
56 Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \
57 Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
58 Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<EXECSPACE, MEMSPACE>, \
59 Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
60 1> { \
61 enum : bool { value = true }; \
62 };
63
64 #define KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(LAYOUT, EXECSPACE, MEMSPACE) \
65 KOKKOSBLAS1_NRM2_TPL_SPEC(float, LAYOUT, EXECSPACE, MEMSPACE) \
66 KOKKOSBLAS1_NRM2_TPL_SPEC(double, LAYOUT, EXECSPACE, MEMSPACE) \
67 KOKKOSBLAS1_NRM2_TPL_SPEC(Kokkos::complex<float>, LAYOUT, EXECSPACE, MEMSPACE) \
68 KOKKOSBLAS1_NRM2_TPL_SPEC(Kokkos::complex<double>, LAYOUT, EXECSPACE, MEMSPACE)
69
70 #ifdef KOKKOSKERNELS_ENABLE_TPL_CUBLAS
71 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(Kokkos::LayoutLeft, Kokkos::Cuda, Kokkos::CudaSpace)
72 #endif
73
74 #ifdef KOKKOSKERNELS_ENABLE_TPL_ROCBLAS
75 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(Kokkos::LayoutLeft, Kokkos::HIP, Kokkos::HIPSpace)
76 #endif
77
78 #if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && defined(KOKKOS_ENABLE_SYCL)
79 KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(Kokkos::LayoutLeft, Kokkos::Experimental::SYCL,
80 Kokkos::Experimental::SYCLDeviceUSMSpace)
81 #endif
82
83 } // namespace Impl
84 } // namespace KokkosBlas
85 #endif