| 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_NRM1_TPL_SPEC_DECL_HPP_ |
| 18 |
#define KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_HPP_ |
| 19 |
|
| 20 |
namespace KokkosBlas { |
| 21 |
namespace Impl { |
| 22 |
|
| 23 |
namespace { |
| 24 |
template <class RV, class XV> |
| 25 |
inline void nrm1_print_specialization() { |
| 26 |
#ifdef KOKKOSKERNELS_ENABLE_CHECK_SPECIALIZATION |
| 27 |
printf("KokkosBlas1::nrm1<> TPL Blas specialization for < %s , %s >\n", typeid(RV).name(), typeid(XV).name()); |
| 28 |
#endif |
| 29 |
} |
| 30 |
} // namespace |
| 31 |
} // namespace Impl |
| 32 |
} // namespace KokkosBlas |
| 33 |
|
| 34 |
// Generic Host side BLAS (could be MKL or whatever) |
| 35 |
#ifdef KOKKOSKERNELS_ENABLE_TPL_BLAS |
| 36 |
#include "KokkosBlas_Host_tpl.hpp" |
| 37 |
|
| 38 |
namespace KokkosBlas { |
| 39 |
namespace Impl { |
| 40 |
|
| 41 |
#define KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(SCALAR, LAYOUT, EXECSPACE, MEMSPACE) \ |
| 42 |
template <> \ |
| 43 |
struct Nrm1<EXECSPACE, \ |
| 44 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 45 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 46 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<EXECSPACE, MEMSPACE>, \ |
| 47 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 48 |
1, true, \ |
| 49 |
nrm1_eti_spec_avail<EXECSPACE, \ |
| 50 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, \ |
| 51 |
Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 52 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<EXECSPACE, MEMSPACE>, \ |
| 53 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>>::value> { \ |
| 54 |
using mag_type = typename Kokkos::ArithTraits<SCALAR>::mag_type; \ |
| 55 |
using RV = Kokkos::View<mag_type, LAYOUT, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 56 |
using XV = Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<EXECSPACE, MEMSPACE>, \ |
| 57 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 58 |
using size_type = typename XV::size_type; \ |
| 59 |
\ |
| 60 |
static void nrm1(const EXECSPACE& space, RV& R, const XV& X) { \ |
| 61 |
Kokkos::Profiling::pushRegion("KokkosBlas::nrm1[TPL_BLAS," #SCALAR "]"); \ |
| 62 |
const size_type numElems = X.extent(0); \ |
| 63 |
if (numElems < static_cast<size_type>(INT_MAX)) { \ |
| 64 |
nrm1_print_specialization<RV, XV>(); \ |
| 65 |
int N = numElems; \ |
| 66 |
int one = 1; \ |
| 67 |
if constexpr (Kokkos::ArithTraits<SCALAR>::is_complex) { \ |
| 68 |
R() = HostBlas<std::complex<mag_type>>::asum(N, reinterpret_cast<const std::complex<mag_type>*>(X.data()), \ |
| 69 |
one); \ |
| 70 |
} else { \ |
| 71 |
R() = HostBlas<SCALAR>::asum(N, X.data(), one); \ |
| 72 |
} \ |
| 73 |
} else { \ |
| 74 |
Nrm1<EXECSPACE, RV, XV, 1, false, nrm1_eti_spec_avail<EXECSPACE, RV, XV>::value>::nrm1(space, R, X); \ |
| 75 |
} \ |
| 76 |
Kokkos::Profiling::popRegion(); \ |
| 77 |
} \ |
| 78 |
}; |
| 79 |
|
| 80 |
#if defined(KOKKOS_ENABLE_SERIAL) |
| 81 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(float, Kokkos::LayoutLeft, Kokkos::Serial, Kokkos::HostSpace) |
| 82 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(double, Kokkos::LayoutLeft, Kokkos::Serial, Kokkos::HostSpace) |
| 83 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::Serial, Kokkos::HostSpace) |
| 84 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::Serial, Kokkos::HostSpace) |
| 85 |
#endif |
| 86 |
|
| 87 |
#if defined(KOKKOS_ENABLE_OPENMP) |
| 88 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(float, Kokkos::LayoutLeft, Kokkos::OpenMP, Kokkos::HostSpace) |
| 89 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(double, Kokkos::LayoutLeft, Kokkos::OpenMP, Kokkos::HostSpace) |
| 90 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::OpenMP, Kokkos::HostSpace) |
| 91 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::OpenMP, Kokkos::HostSpace) |
| 92 |
#endif |
| 93 |
|
| 94 |
#if defined(KOKKOS_ENABLE_THREADS) |
| 95 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(float, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::HostSpace) |
| 96 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(double, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::HostSpace) |
| 97 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::HostSpace) |
| 98 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_BLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::HostSpace) |
| 99 |
#endif |
| 100 |
|
| 101 |
} // namespace Impl |
| 102 |
} // namespace KokkosBlas |
| 103 |
|
| 104 |
#endif |
| 105 |
|
| 106 |
// cuBLAS |
| 107 |
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUBLAS |
| 108 |
#include <KokkosBlas_tpl_spec.hpp> |
| 109 |
|
| 110 |
namespace KokkosBlas { |
| 111 |
namespace Impl { |
| 112 |
|
| 113 |
template <class ExecutionSpace, class XViewType, class RViewType> |
| 114 |
void cublasAsumWrapper(const ExecutionSpace& space, RViewType& R, const XViewType& X) { |
| 115 |
using XScalar = typename XViewType::non_const_value_type; |
| 116 |
|
| 117 |
nrm1_print_specialization<RViewType, XViewType>(); |
| 118 |
const int N = static_cast<int>(X.extent(0)); |
| 119 |
constexpr int one = 1; |
| 120 |
KokkosBlas::Impl::CudaBlasSingleton& s = KokkosBlas::Impl::CudaBlasSingleton::singleton(); |
| 121 |
|
| 122 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL(cublasSetStream(s.handle, space.cuda_stream())); |
| 123 |
if constexpr (std::is_same_v<XScalar, float>) { |
| 124 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL(cublasSasum(s.handle, N, X.data(), one, R.data())); |
| 125 |
} |
| 126 |
if constexpr (std::is_same_v<XScalar, double>) { |
| 127 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL(cublasDasum(s.handle, N, X.data(), one, R.data())); |
| 128 |
} |
| 129 |
if constexpr (std::is_same_v<XScalar, Kokkos::complex<float>>) { |
| 130 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL( |
| 131 |
cublasScasum(s.handle, N, reinterpret_cast<const cuComplex*>(X.data()), one, R.data())); |
| 132 |
} |
| 133 |
if constexpr (std::is_same_v<XScalar, Kokkos::complex<double>>) { |
| 134 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL( |
| 135 |
cublasDzasum(s.handle, N, reinterpret_cast<const cuDoubleComplex*>(X.data()), one, R.data())); |
| 136 |
} |
| 137 |
KOKKOSBLAS_IMPL_CUBLAS_SAFE_CALL(cublasSetStream(s.handle, NULL)); |
| 138 |
} |
| 139 |
|
| 140 |
#define KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(SCALAR, LAYOUT, MEMSPACE) \ |
| 141 |
template <> \ |
| 142 |
struct Nrm1<Kokkos::Cuda, \ |
| 143 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 144 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 145 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Cuda, MEMSPACE>, \ |
| 146 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 147 |
1, true, \ |
| 148 |
nrm1_eti_spec_avail<Kokkos::Cuda, \ |
| 149 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, \ |
| 150 |
Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 151 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Cuda, MEMSPACE>, \ |
| 152 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>>::value> { \ |
| 153 |
using execution_space = Kokkos::Cuda; \ |
| 154 |
using RV = Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 155 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 156 |
using XV = Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Cuda, MEMSPACE>, \ |
| 157 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 158 |
using size_type = typename XV::size_type; \ |
| 159 |
\ |
| 160 |
static void nrm1(const execution_space& space, RV& R, const XV& X) { \ |
| 161 |
Kokkos::Profiling::pushRegion("KokkosBlas::nrm1[TPL_CUBLAS," #SCALAR "]"); \ |
| 162 |
const size_type numElems = X.extent(0); \ |
| 163 |
if (numElems < static_cast<size_type>(INT_MAX)) { \ |
| 164 |
cublasAsumWrapper(space, R, X); \ |
| 165 |
} else { \ |
| 166 |
Nrm1<execution_space, RV, XV, 1, false, nrm1_eti_spec_avail<Kokkos::Cuda, RV, XV>::value>::nrm1(space, R, X); \ |
| 167 |
} \ |
| 168 |
Kokkos::Profiling::popRegion(); \ |
| 169 |
} \ |
| 170 |
}; |
| 171 |
|
| 172 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(float, Kokkos::LayoutLeft, Kokkos::CudaSpace) |
| 173 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(double, Kokkos::LayoutLeft, Kokkos::CudaSpace) |
| 174 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::CudaSpace) |
| 175 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::CudaSpace) |
| 176 |
|
| 177 |
#if defined(KOKKOSKERNELS_INST_MEMSPACE_CUDAUVMSPACE) |
| 178 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(float, Kokkos::LayoutLeft, Kokkos::CudaUVMSpace) |
| 179 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(double, Kokkos::LayoutLeft, Kokkos::CudaUVMSpace) |
| 180 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::CudaUVMSpace) |
| 181 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_CUBLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::CudaUVMSpace) |
| 182 |
#endif |
| 183 |
|
| 184 |
} // namespace Impl |
| 185 |
} // namespace KokkosBlas |
| 186 |
#endif // KOKKOSKERNELS_ENABLE_TPL_CUBLAS |
| 187 |
|
| 188 |
// rocBLAS |
| 189 |
#ifdef KOKKOSKERNELS_ENABLE_TPL_ROCBLAS |
| 190 |
#include <KokkosBlas_tpl_spec.hpp> |
| 191 |
|
| 192 |
namespace KokkosBlas { |
| 193 |
namespace Impl { |
| 194 |
|
| 195 |
template <class ExecutionSpace, class XViewType, class RViewType> |
| 196 |
void rocblasAsumWrapper(const ExecutionSpace& space, RViewType& R, const XViewType& X) { |
| 197 |
using XScalar = typename XViewType::non_const_value_type; |
| 198 |
|
| 199 |
nrm1_print_specialization<RViewType, XViewType>(); |
| 200 |
const int N = static_cast<int>(X.extent(0)); |
| 201 |
constexpr int one = 1; |
| 202 |
KokkosBlas::Impl::RocBlasSingleton& s = KokkosBlas::Impl::RocBlasSingleton::singleton(); |
| 203 |
|
| 204 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL(rocblas_set_stream(s.handle, space.hip_stream())); |
| 205 |
if constexpr (std::is_same_v<XScalar, float>) { |
| 206 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL(rocblas_sasum(s.handle, N, X.data(), one, R.data())); |
| 207 |
} |
| 208 |
if constexpr (std::is_same_v<XScalar, double>) { |
| 209 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL(rocblas_dasum(s.handle, N, X.data(), one, R.data())); |
| 210 |
} |
| 211 |
if constexpr (std::is_same_v<XScalar, Kokkos::complex<float>>) { |
| 212 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL( |
| 213 |
rocblas_scasum(s.handle, N, reinterpret_cast<const rocblas_float_complex*>(X.data()), one, R.data())); |
| 214 |
} |
| 215 |
if constexpr (std::is_same_v<XScalar, Kokkos::complex<double>>) { |
| 216 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL( |
| 217 |
rocblas_dzasum(s.handle, N, reinterpret_cast<const rocblas_double_complex*>(X.data()), one, R.data())); |
| 218 |
} |
| 219 |
KOKKOSBLAS_IMPL_ROCBLAS_SAFE_CALL(rocblas_set_stream(s.handle, NULL)); |
| 220 |
} |
| 221 |
|
| 222 |
#define KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(SCALAR, LAYOUT, MEMSPACE) \ |
| 223 |
template <> \ |
| 224 |
struct Nrm1<Kokkos::HIP, \ |
| 225 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 226 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 227 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::HIP, MEMSPACE>, \ |
| 228 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 229 |
1, true, \ |
| 230 |
nrm1_eti_spec_avail<Kokkos::HIP, \ |
| 231 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, \ |
| 232 |
Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 233 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::HIP, MEMSPACE>, \ |
| 234 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>>::value> { \ |
| 235 |
using RV = Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 236 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 237 |
using XV = Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::HIP, MEMSPACE>, \ |
| 238 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 239 |
using size_type = typename XV::size_type; \ |
| 240 |
\ |
| 241 |
static void nrm1(const Kokkos::HIP& space, RV& R, const XV& X) { \ |
| 242 |
Kokkos::Profiling::pushRegion("KokkosBlas::nrm1[TPL_ROCBLAS," #SCALAR "]"); \ |
| 243 |
const size_type numElems = X.extent(0); \ |
| 244 |
if (numElems < static_cast<size_type>(INT_MAX)) { \ |
| 245 |
rocblasAsumWrapper(space, R, X); \ |
| 246 |
} else { \ |
| 247 |
Nrm1<Kokkos::HIP, RV, XV, 1, false, nrm1_eti_spec_avail<Kokkos::HIP, RV, XV>::value>::nrm1(space, R, X); \ |
| 248 |
} \ |
| 249 |
Kokkos::Profiling::popRegion(); \ |
| 250 |
} \ |
| 251 |
}; |
| 252 |
|
| 253 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(float, Kokkos::LayoutLeft, Kokkos::HIPSpace) |
| 254 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(double, Kokkos::LayoutLeft, Kokkos::HIPSpace) |
| 255 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::HIPSpace) |
| 256 |
KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::HIPSpace) |
| 257 |
|
| 258 |
} // namespace Impl |
| 259 |
} // namespace KokkosBlas |
| 260 |
|
| 261 |
#endif // KOKKOSKERNELS_ENABLE_TPL_ROCBLAS |
| 262 |
|
| 263 |
// oneMKL |
| 264 |
#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL |
| 265 |
|
| 266 |
#if defined(KOKKOS_ENABLE_SYCL) |
| 267 |
|
| 268 |
#include <KokkosBlas_tpl_spec.hpp> |
| 269 |
#include <oneapi/mkl/blas.hpp> |
| 270 |
|
| 271 |
namespace KokkosBlas { |
| 272 |
namespace Impl { |
| 273 |
|
| 274 |
template <class ExecutionSpace, class XViewType, class RViewType> |
| 275 |
void onemklAsumWrapper(const ExecutionSpace& space, RViewType& R, const XViewType& X) { |
| 276 |
using XScalar = typename XViewType::non_const_value_type; |
| 277 |
using KAT_X = Kokkos::ArithTraits<XScalar>; |
| 278 |
using layout_t = typename XViewType::array_layout; |
| 279 |
|
| 280 |
const std::int64_t N = static_cast<std::int64_t>(X.extent(0)); |
| 281 |
|
| 282 |
// Create temp view on device to store the result |
| 283 |
Kokkos::View<typename Kokkos::ArithTraits<XScalar>::mag_type, typename XViewType::memory_space> res( |
| 284 |
"sycl asum result"); |
| 285 |
|
| 286 |
// Decide to call row_major or column_major function |
| 287 |
if constexpr (std::is_same_v<Kokkos::LayoutRight, layout_t>) { |
| 288 |
if constexpr (KAT_X::is_complex) { |
| 289 |
oneapi::mkl::blas::row_major::asum(space.sycl_queue(), N, |
| 290 |
reinterpret_cast<const std::complex<typename KAT_X::mag_type>*>(X.data()), 1, |
| 291 |
res.data()); |
| 292 |
} else { |
| 293 |
oneapi::mkl::blas::row_major::asum(space.sycl_queue(), N, X.data(), 1, res.data()); |
| 294 |
} |
| 295 |
} else { |
| 296 |
if constexpr (KAT_X::is_complex) { |
| 297 |
oneapi::mkl::blas::column_major::asum(space.sycl_queue(), N, |
| 298 |
reinterpret_cast<const std::complex<typename KAT_X::mag_type>*>(X.data()), |
| 299 |
1, res.data()); |
| 300 |
} else { |
| 301 |
oneapi::mkl::blas::column_major::asum(space.sycl_queue(), X.extent_int(0), X.data(), 1, res.data()); |
| 302 |
} |
| 303 |
} |
| 304 |
// Bring result back to host |
| 305 |
Kokkos::deep_copy(space, R, res); |
| 306 |
} |
| 307 |
|
| 308 |
#define KOKKOSBLAS1_NRM1_ONEMKL(SCALAR, LAYOUT, MEMSPACE) \ |
| 309 |
template <> \ |
| 310 |
struct Nrm1< \ |
| 311 |
Kokkos::Experimental::SYCL, \ |
| 312 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 313 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 314 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Experimental::SYCL, MEMSPACE>, \ |
| 315 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 316 |
1, true, \ |
| 317 |
nrm1_eti_spec_avail<Kokkos::Experimental::SYCL, \ |
| 318 |
Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 319 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \ |
| 320 |
Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Experimental::SYCL, MEMSPACE>, \ |
| 321 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>>::value> { \ |
| 322 |
using execution_space = Kokkos::Experimental::SYCL; \ |
| 323 |
using RV = Kokkos::View<typename Kokkos::ArithTraits<SCALAR>::mag_type, LAYOUT, Kokkos::HostSpace, \ |
| 324 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 325 |
using XV = Kokkos::View<const SCALAR*, LAYOUT, Kokkos::Device<Kokkos::Experimental::SYCL, MEMSPACE>, \ |
| 326 |
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \ |
| 327 |
using size_type = typename XV::size_type; \ |
| 328 |
\ |
| 329 |
static void nrm1(const execution_space& space, RV& R, const XV& X) { \ |
| 330 |
Kokkos::Profiling::pushRegion("KokkosBlas::nrm1[TPL_ONEMKL," #SCALAR "]"); \ |
| 331 |
const size_type numElems = X.extent(0); \ |
| 332 |
if (numElems < static_cast<size_type>(INT_MAX)) { \ |
| 333 |
onemklAsumWrapper(space, R, X); \ |
| 334 |
} else { \ |
| 335 |
Nrm1<execution_space, RV, XV, 1, false, nrm1_eti_spec_avail<Kokkos::Experimental::SYCL, RV, XV>::value>::nrm1( \ |
| 336 |
space, R, X); \ |
| 337 |
} \ |
| 338 |
Kokkos::Profiling::popRegion(); \ |
| 339 |
} \ |
| 340 |
}; |
| 341 |
|
| 342 |
KOKKOSBLAS1_NRM1_ONEMKL(float, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLDeviceUSMSpace) |
| 343 |
KOKKOSBLAS1_NRM1_ONEMKL(double, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLDeviceUSMSpace) |
| 344 |
KOKKOSBLAS1_NRM1_ONEMKL(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLDeviceUSMSpace) |
| 345 |
KOKKOSBLAS1_NRM1_ONEMKL(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLDeviceUSMSpace) |
| 346 |
|
| 347 |
#if defined(KOKKOSKERNELS_INST_MEMSPACE_SYCLSHAREDSPACE) |
| 348 |
KOKKOSBLAS1_NRM1_ONEMKL(float, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLSharedUSMSpace) |
| 349 |
KOKKOSBLAS1_NRM1_ONEMKL(double, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLSharedUSMSpace) |
| 350 |
KOKKOSBLAS1_NRM1_ONEMKL(Kokkos::complex<float>, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLSharedUSMSpace) |
| 351 |
KOKKOSBLAS1_NRM1_ONEMKL(Kokkos::complex<double>, Kokkos::LayoutLeft, Kokkos::Experimental::SYCLSharedUSMSpace) |
| 352 |
#endif |
| 353 |
|
| 354 |
} // namespace Impl |
| 355 |
} // namespace KokkosBlas |
| 356 |
|
| 357 |
#endif // KOKKOS_ENABLE_SYCL |
| 358 |
#endif // KOKKOSKERNELS_ENABLE_TPL_MKL |
| 359 |
|
| 360 |
#endif |