Skip to content

Commit

Permalink
BLAS - ROT: fixing types for Host TPL calls to ROT function
Browse files Browse the repository at this point in the history
The types for the arguments c and s are actually different and need
to be appropriately propagated through the TPL layers of the library.

Signed-off-by: Luc Berger-Vergiat <[email protected]>
  • Loading branch information
lucbv committed Jan 6, 2025
1 parent 6667b94 commit d764583
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
34 changes: 24 additions & 10 deletions blas/tpls/KokkosBlas1_rot_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ namespace Impl {
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
true, ETI_SPEC_AVAIL> { \
using VectorView = Kokkos::View<double*, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using MagnitudeView = Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using ScalarView = Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, ScalarView const& c, \
ScalarView const& s) { \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, \
MagnitudeView const& c, ScalarView const& s) { \
Kokkos::Profiling::pushRegion("KokkosBlas::rot[TPL_BLAS,double]"); \
HostBlas<double>::rot(X.extent_int(0), X.data(), 1, Y.data(), 1, c.data(), s.data()); \
Kokkos::Profiling::popRegion(); \
Expand All @@ -66,13 +70,17 @@ namespace Impl {
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
true, ETI_SPEC_AVAIL> { \
using VectorView = Kokkos::View<float*, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using MagnitudeView = Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using ScalarView = Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, ScalarView const& c, \
ScalarView const& s) { \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, \
MagnitudeView const& c, ScalarView const& s) { \
Kokkos::Profiling::pushRegion("KokkosBlas::rot[TPL_BLAS,float]"); \
HostBlas<float>::rot(X.extent_int(0), X.data(), 1, Y.data(), 1, c.data(), s.data()); \
Kokkos::Profiling::popRegion(); \
Expand All @@ -84,13 +92,16 @@ namespace Impl {
struct Rot<Kokkos::complex<double>, EXECSPACE, MEMSPACE, true, ETI_SPEC_AVAIL> { \
using VectorView = Kokkos::View<Kokkos::complex<double>*, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using ScalarView = Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
using MagnitudeView = Kokkos::View<double, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, ScalarView const& c, \
using ScalarView = Kokkos::View<Kokkos::complex<double>, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, MagnitudeView const& c, \
ScalarView const& s) { \
Kokkos::Profiling::pushRegion("KokkosBlas::rot[TPL_BLAS,complex<double>]"); \
HostBlas<std::complex<double>>::rot(X.extent_int(0), reinterpret_cast<std::complex<double>*>(X.data()), 1, \
reinterpret_cast<std::complex<double>*>(Y.data()), 1, c.data(), s.data()); \
reinterpret_cast<std::complex<double>*>(Y.data()), 1, c.data(), \
reinterpret_cast<std::complex<double>*>(s.data())); \
Kokkos::Profiling::popRegion(); \
} \
};
Expand All @@ -100,13 +111,16 @@ namespace Impl {
struct Rot<Kokkos::complex<float>, EXECSPACE, MEMSPACE, true, ETI_SPEC_AVAIL> { \
using VectorView = Kokkos::View<Kokkos::complex<float>*, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using ScalarView = Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
using MagnitudeView = Kokkos::View<float, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
using ScalarView = Kokkos::View<Kokkos::complex<float>, LAYOUT, Kokkos::Device<EXECSPACE, Kokkos::HostSpace>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>; \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, ScalarView const& c, \
static void rot(EXECSPACE const& /*space*/, VectorView const& X, VectorView const& Y, MagnitudeView const& c, \
ScalarView const& s) { \
Kokkos::Profiling::pushRegion("KokkosBlas::rot[TPL_BLAS,complex<float>]"); \
HostBlas<std::complex<float>>::rot(X.extent_int(0), reinterpret_cast<std::complex<float>*>(X.data()), 1, \
reinterpret_cast<std::complex<float>*>(Y.data()), 1, c.data(), s.data()); \
reinterpret_cast<std::complex<float>*>(Y.data()), 1, c.data(), \
reinterpret_cast<std::complex<float>*>(s.data())); \
Kokkos::Profiling::popRegion(); \
} \
};
Expand Down
8 changes: 4 additions & 4 deletions blas/tpls/KokkosBlas_Host_tpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ void F77_BLAS_MANGLE(srot, SROT)(KK_INT const* N, float* X, KK_INT const* incx,
void F77_BLAS_MANGLE(drot, DROT)(KK_INT const* N, double* X, KK_INT const* incx, double* Y, KK_INT const* incy,
double* c, double* s);
void F77_BLAS_MANGLE(crot, CROT)(KK_INT const* N, std::complex<float>* X, KK_INT const* incx, std::complex<float>* Y,
KK_INT const* incy, float* c, float* s);
KK_INT const* incy, float* c, std::complex<float>* s);
void F77_BLAS_MANGLE(zrot, ZROT)(KK_INT const* N, std::complex<double>* X, KK_INT const* incx, std::complex<double>* Y,
KK_INT const* incy, double* c, double* s);
KK_INT const* incy, double* c, std::complex<double>* s);

///
/// rotg
Expand Down Expand Up @@ -683,7 +683,7 @@ void HostBlas<std::complex<float> >::axpy(KK_INT n, const std::complex<float> al
}
template <>
void HostBlas<std::complex<float> >::rot(KK_INT const N, std::complex<float>* X, KK_INT const incx,
std::complex<float>* Y, KK_INT const incy, float* c, float* s) {
std::complex<float>* Y, KK_INT const incy, float* c, std::complex<float>* s) {
F77_FUNC_CROT(&N, X, &incx, Y, &incy, c, s);
}
template <>
Expand Down Expand Up @@ -824,7 +824,7 @@ void HostBlas<std::complex<double> >::axpy(KK_INT n, const std::complex<double>
}
template <>
void HostBlas<std::complex<double> >::rot(KK_INT const N, std::complex<double>* X, KK_INT const incx,
std::complex<double>* Y, KK_INT const incy, double* c, double* s) {
std::complex<double>* Y, KK_INT const incy, double* c, std::complex<double>* s) {
F77_FUNC_ZROT(&N, X, &incx, Y, &incy, c, s);
}
template <>
Expand Down
2 changes: 1 addition & 1 deletion blas/tpls/KokkosBlas_Host_tpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct HostBlas {
static void axpy(KK_INT n, const T alpha, const T *x, KK_INT x_inc,
/* */ T *y, KK_INT y_inc);

static void rot(KK_INT const N, T *X, KK_INT const incx, T *Y, KK_INT const incy, mag_type *c, mag_type *s);
static void rot(KK_INT const N, T *X, KK_INT const incx, T *Y, KK_INT const incy, mag_type *c, T *s);

static void rotg(T *a, T *b, mag_type *c, T *s);

Expand Down

0 comments on commit d764583

Please sign in to comment.