Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
eeprude committed Jul 10, 2023
1 parent 8ef12f7 commit 4ab5373
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 27 deletions.
32 changes: 19 additions & 13 deletions blas/impl/KokkosBlas1_axpby_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct Axpby_Functor {
BV m_b;

Axpby_Functor(const XV& x, const YV& y, const AV& av, const BV& bv,
const SizeType startingColumn)
const SizeType startingColumn) // Aqui__ Not needed ???
: m_x(x), m_y(y), m_a(av), m_b(bv) {
static_assert(Kokkos::is_view<XV>::value,
"KokkosBlas::Impl::"
Expand All @@ -95,13 +95,18 @@ struct Axpby_Functor {
static_assert(YV::rank == 1,
"KokkosBlas::Impl::Axpby_Functor: "
"XV and YV must have rank 1.");

#if 1 // Aqui__ Not needed ???
if (startingColumn != 0) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
if (myExtent(m_a) > 1) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
}
if (myExtent(m_b) > 1) {
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
}
}
#endif
}

KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -358,8 +363,9 @@ struct Axpby_Functor<typename XV::non_const_value_type, XV,
};

// Variant of Axpby_MV_Generic for single vectors (1-D Views) x and y.
// As above, either av and bv are both 1-D Views (and only the first
// entry of each will be read), or both av and bv are scalars.
// As above, av and bv are either:
// - both 1-D views (and only the first entry of each are read), or
// - both scalars.
//
// This takes the starting column, so that if av and bv are both 1-D
// Views, then the functor can take a subview if appropriate.
Expand All @@ -369,11 +375,11 @@ void Axpby_Generic(const execution_space& space, const AV& av, const XV& x,
const BV& bv, const YV& y, const SizeType startingColumn,
int scalar_x = 2, int scalar_y = 2) {
std::cout << "Entering impl.Axpby_Generic()"
<< ": scalar_x/y = " << scalar_x << "/" << scalar_y
<< ", is_view av/bv = " << Kokkos::is_view<AV>::value << "/" << Kokkos::is_view<BV>::value
<< ", rank XV/YV = " << XV::rank << "/" << YV::rank
<< ", extent x/y = " << x.extent(0) << "/" << y.extent(0)
<< ", extent av/bv = " << myExtent(av) << "/" << myExtent(bv)
<< ": scalar_x/y = " << scalar_x << "/" << scalar_y
<< ", is_view av/bv = " << Kokkos::is_view<AV>::value << "/" << Kokkos::is_view<BV>::value
<< ", rank XV/YV = " << XV::rank << "/" << YV::rank
<< ", extent x/y = " << x.extent(0) << "/" << y.extent(0)
<< ", extent av/bv = " << myExtent(av) << "/" << myExtent(bv)
<< ", startingColumn = " << startingColumn
<< std::endl;
static_assert(Kokkos::is_view<XV>::value,
Expand Down
39 changes: 26 additions & 13 deletions blas/impl/KokkosBlas1_axpby_mv_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,15 @@ struct Axpby_MV_Unroll_Functor {
"KokkosBlas::Impl::Axpby_MV_Unroll_Functor: "
"BV must have rank 1.");

if (startingColumn != 0) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
if (startingColumn != 0) { // Aqui__
if (myExtent(m_a) > 1) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
}
if (myExtent(m_b) > 1) {
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
}
}
}

Expand Down Expand Up @@ -1299,7 +1303,7 @@ struct Axpby_MV_Unroll_Functor<typename XMV::non_const_value_type, XMV,
// scalar_x and scalar_y come in as integers. The values -1, 0, and 1 correspond to
// the literal values of the coefficients. The value 2 tells the
// functor to use the corresponding vector of coefficients: scalar_x == 2
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. vb are
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. bv are
// ignored.
//
// Any literal coefficient of zero has BLAS semantics of ignoring the
Expand Down Expand Up @@ -1453,7 +1457,7 @@ void Axpby_MV_Unrolled(const execution_space& space, const AV& av, const XMV& x,
// scalar_x and scalar_y come in as integers. The values -1, 0, and 1 correspond to
// the literal values of the coefficients. The value 2 tells the
// functor to use the corresponding vector of coefficients: scalar_x == 2
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. vb are
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. bv are
// ignored.
//
// Any literal coefficient of zero has BLAS semantics of ignoring the
Expand Down Expand Up @@ -1590,7 +1594,7 @@ void Axpby_MV_Generic(const execution_space& space, const AV& av, const XMV& x,
// scalar_x and scalar_y come in as integers. The values -1, 0, and 1 correspond to
// the literal values of the coefficients. The value 2 tells the
// functor to use the corresponding vector of coefficients: scalar_x == 2
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. vb are
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. bv are
// ignored.
//
// Any literal coefficient of zero has BLAS semantics of ignoring the
Expand Down Expand Up @@ -1638,7 +1642,7 @@ struct Axpby_MV_Invoke_Left {
// subviews of av and bv, if they are Views. If they are scalars,
// the functor doesn't have to do anything to them.
Axpby_MV_Unrolled<execution_space, AV, XMV, BV, YMV, 8, SizeType>(
space, av, X_cur, bv, Y_cur, 0/*j*/, scalar_x, scalar_y); // Aqui__
space, av, X_cur, bv, Y_cur, j, scalar_x, scalar_y); // Aqui__
}
for (; j + 4 <= numCols; j += 4) {
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): 4, j = " << j << std::endl;
Expand All @@ -1649,7 +1653,7 @@ struct Axpby_MV_Invoke_Left {
// subviews of av and bv, if they are Views. If they are scalars,
// the functor doesn't have to do anything to them.
Axpby_MV_Unrolled<execution_space, AV, XMV, BV, YMV, 4, SizeType>(
space, av, X_cur, bv, Y_cur, 0/*j*/, scalar_x, scalar_y); // Aqui__
space, av, X_cur, bv, Y_cur, j, scalar_x, scalar_y); // Aqui__
}
for (; j < numCols; ++j) {
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): 1, j = " << j << std::endl;
Expand All @@ -1661,8 +1665,17 @@ struct Axpby_MV_Invoke_Left {
// the functor doesn't have to do anything to them.
typedef decltype(x_cur) XV;
typedef decltype(y_cur) YV;
Axpby_Generic<execution_space, AV, XV, BV, YV, SizeType>(
space, av, x_cur, bv, y_cur, 0/*j*/, scalar_x, scalar_y); // Aqui__
//if ((myExtent(av) > 1) ||
// (myExtent(bv) > 1)) {
Axpby_Generic<execution_space, AV, XV, BV, YV, SizeType>(
space, av, x_cur, bv, y_cur, j, scalar_x, scalar_y); // Aqui__
#if 0
}
else {
Axpby_Generic<execution_space, AV, XV, BV, YV, SizeType>(
space, av, x_cur, bv, y_cur, 0, scalar_x, scalar_y); // Aqui__
}
#endif
}
std::cout << "Leaving mv_impl.Axpby_MV_Invoke_Left.run()" << std::endl;
}
Expand All @@ -1680,7 +1693,7 @@ struct Axpby_MV_Invoke_Left {
// scalar_x and scalar_y come in as integers. The values -1, 0, and 1 correspond to
// the literal values of the coefficients. The value 2 tells the
// functor to use the corresponding vector of coefficients: scalar_x == 2
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. vb are
// means use av, and scalar_y == 2 means use bv. Otherwise, av resp. bv are
// ignored.
//
// Any literal coefficient of zero has BLAS semantics of ignoring the
Expand Down
Loading

0 comments on commit 4ab5373

Please sign in to comment.