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 4ab5373 commit 01683be
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 114 deletions.
24 changes: 6 additions & 18 deletions blas/impl/KokkosBlas1_axpby_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ namespace Impl {

template <class T>
constexpr typename std::enable_if<Kokkos::is_view_v<T>, int>::type
myExtent(T & v)
axpbyVarExtent(T & v)
{
return v.extent(0);
}

template <class T>
constexpr typename std::enable_if<!Kokkos::is_view_v<T>, int>::type
myExtent(T &)
axpbyVarExtent(T &)
{
return -1;
return 0;
}

//
Expand Down 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) // Aqui__ Not needed ???
const SizeType startingColumn)
: m_x(x), m_y(y), m_a(av), m_b(bv) {
static_assert(Kokkos::is_view<XV>::value,
"KokkosBlas::Impl::"
Expand All @@ -95,18 +95,16 @@ 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) {
if (myExtent(m_a) > 1) {
if (axpbyVarExtent(m_a) > 1) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
}
if (myExtent(m_b) > 1) {
if (axpbyVarExtent(m_b) > 1) {
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
}
}
#endif
}

KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -374,14 +372,6 @@ template <class execution_space, class AV, class XV, class BV, class YV,
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)
<< ", startingColumn = " << startingColumn
<< std::endl;
static_assert(Kokkos::is_view<XV>::value,
"KokkosBlas::Impl::"
"Axpby_Generic: X is not a Kokkos::View.");
Expand Down Expand Up @@ -504,11 +494,9 @@ void Axpby_Generic(const execution_space& space, const AV& av, const XV& x,
}
#endif // KOKKOSBLAS_OPTIMIZATION_LEVEL_AXPBY > 2
else { // (scalar_y == 2)
std::cout << "In impl.Axpby_generic(2,2): calling parallel_for(), KOKKOSBLAS_OPTIMIZATION_LEVEL_AXPBY = " << KOKKOSBLAS_OPTIMIZATION_LEVEL_AXPBY << std::endl;
Axpby_Functor<AV, XV, BV, YV, 2, 2, SizeType> op(x, y, av, bv,
startingColumn);
Kokkos::parallel_for("KokkosBlas::Axpby::S15", policy, op);
std::cout << "In impl.Axpby_generic(2,2): returned from parallel_for()" << std::endl;
}
}
}
Expand Down
34 changes: 7 additions & 27 deletions blas/impl/KokkosBlas1_axpby_mv_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,6 @@ struct Axpby_MV_Functor<typename XMV::non_const_value_type, XMV,
}
};

#if 1 // Needed when Invoke_Left() is corredcted and put back to work // Aqui_ (later)
// Column-unrolled variant of Axpby_MV_Functor. The number of columns
// in X and Y, UNROLL, is a compile-time constant.
template <class AV, class XMV, class BV, class YMV, int scalar_x, int scalar_y,
Expand Down Expand Up @@ -699,12 +698,12 @@ struct Axpby_MV_Unroll_Functor {
"KokkosBlas::Impl::Axpby_MV_Unroll_Functor: "
"BV must have rank 1.");

if (startingColumn != 0) { // Aqui__
if (myExtent(m_a) > 1) {
if (startingColumn != 0) {
if (axpbyVarExtent(m_a) > 1) {
m_a = Kokkos::subview(
av, std::make_pair(startingColumn, SizeType(av.extent(0))));
}
if (myExtent(m_b) > 1) {
if (axpbyVarExtent(m_b) > 1) {
m_b = Kokkos::subview(
bv, std::make_pair(startingColumn, SizeType(bv.extent(0))));
}
Expand Down Expand Up @@ -1444,7 +1443,6 @@ void Axpby_MV_Unrolled(const execution_space& space, const AV& av, const XMV& x,
}
}
}
#endif // Aqui_ (later)

// Invoke the "generic" (not unrolled) multivector functor that
// computes any of the following:
Expand Down Expand Up @@ -1582,7 +1580,6 @@ void Axpby_MV_Generic(const execution_space& space, const AV& av, const XMV& x,
}
}

#if 1 // Needed when Axpby_MV_Invoke_Left() is corredcted and put back to work // Aqui_ (later)
// Compute any of the following, in a way optimized for X and Y
// being LayoutLeft:
//
Expand All @@ -1607,7 +1604,6 @@ template <class execution_space, class AV, class XMV, class BV, class YMV,
struct Axpby_MV_Invoke_Left {
static void run(const execution_space& space, const AV& av, const XMV& x,
const BV& bv, const YMV& y, int scalar_x = 2, int scalar_y = 2) {
std::cout << "Entering mv_impl.Axpby_MV_Invoke_Left.run(): scalar_x/y = " << scalar_x << "/" << scalar_y << std::endl;
static_assert(Kokkos::is_view<XMV>::value,
"KokkosBlas::Impl::"
"Axpby_MV_Invoke_Left: X is not a Kokkos::View.");
Expand All @@ -1627,36 +1623,32 @@ struct Axpby_MV_Invoke_Left {
"X and Y must have rank 2.");

const SizeType numCols = x.extent(1);
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): numCols = " << numCols << std::endl;

// Strip-mine by 8, then 4. After that, do one column at a time.
// We limit the number of strip-mine values in order to keep down
// the amount of code to compile.
SizeType j = 0;
for (; j + 8 <= numCols; j += 8) {
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): 8, j = " << j << std::endl;
XMV X_cur = Kokkos::subview(x, Kokkos::ALL(), std::make_pair(j, j + 8));
YMV Y_cur = Kokkos::subview(y, Kokkos::ALL(), std::make_pair(j, j + 8));

// Passing in the starting column index lets the functor take
// 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, j, scalar_x, scalar_y); // Aqui__
space, av, X_cur, bv, Y_cur, j, scalar_x, scalar_y);
}
for (; j + 4 <= numCols; j += 4) {
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): 4, j = " << j << std::endl;
XMV X_cur = Kokkos::subview(x, Kokkos::ALL(), std::make_pair(j, j + 4));
YMV Y_cur = Kokkos::subview(y, Kokkos::ALL(), std::make_pair(j, j + 4));

// Passing in the starting column index lets the functor take
// 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, j, scalar_x, scalar_y); // Aqui__
space, av, X_cur, bv, Y_cur, j, scalar_x, scalar_y);
}
for (; j < numCols; ++j) {
std::cout << "In mv_impl.Axpby_MV_Invoke_Left.run(): 1, j = " << j << std::endl;
auto x_cur = Kokkos::subview(x, Kokkos::ALL(), j);
auto y_cur = Kokkos::subview(y, Kokkos::ALL(), j);

Expand All @@ -1665,22 +1657,11 @@ 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;
//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
Axpby_Generic<execution_space, AV, XV, BV, YV, SizeType>(
space, av, x_cur, bv, y_cur, j, scalar_x, scalar_y);
}
std::cout << "Leaving mv_impl.Axpby_MV_Invoke_Left.run()" << std::endl;
}
};
#endif // Aqui_ (later)

// Compute any of the following, in a way optimized for X and Y
// being LayoutRight:
Expand All @@ -1706,7 +1687,6 @@ template <class execution_space, class AV, class XMV, class BV, class YMV,
struct Axpby_MV_Invoke_Right {
static void run(const execution_space& space, const AV& av, const XMV& x,
const BV& bv, const YMV& y, int scalar_x = 2, int scalar_y = 2) {
std::cout << "Entering mv_impl.Axpby_MV_Invoke_Right.run()" << std::endl;
static_assert(Kokkos::is_view<XMV>::value,
"KokkosBlas::Impl::"
"Axpby_MV_Invoke_Right: X is not a Kokkos::View.");
Expand Down
32 changes: 10 additions & 22 deletions blas/impl/KokkosBlas1_axpby_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ struct axpby_eti_spec_avail {
template <> \
struct axpby_eti_spec_avail< \
EXEC_SPACE, \
Kokkos::View<const SCALAR*, LAYOUT, /*AquiCorrection*/ \
Kokkos::View<const SCALAR*, LAYOUT, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<const SCALAR**, LAYOUT, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<const SCALAR*, LAYOUT, /*AquiCorrection*/ \
Kokkos::View<const SCALAR*, LAYOUT, \
Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Kokkos::View<SCALAR**, LAYOUT, Kokkos::Device<EXEC_SPACE, MEM_SPACE>, \
Expand Down Expand Up @@ -181,7 +181,6 @@ struct Axpby<execution_space, AV, XMV, BV, YMV, 2, false,

static void axpby(const execution_space& space, const AV& av, const XMV& X,
const BV& bv, const YMV& Y) {
std::cout << "Entering spec.Axpby::axpby(case 001)" << std::endl;
static_assert(Kokkos::is_view<XMV>::value,
"KokkosBlas::Impl::"
"Axpby<rank-2>::axpby: X is not a Kokkos::View.");
Expand Down Expand Up @@ -232,20 +231,18 @@ struct Axpby<execution_space, AV, XMV, BV, YMV, 2, false,

if (numRows < static_cast<size_type>(INT_MAX) &&
numRows * numCols < static_cast<size_type>(INT_MAX)) {
std::cout << "In spec.Axpby::axpby(case 001.1)" << std::endl;
using index_type = int;
using Axpby_MV_Invoke_Layout = typename
std::conditional< std::is_same< typename XMV::array_layout, Kokkos::LayoutLeft >::value // AquiCorrection
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type> // Aqui ???
std::conditional< std::is_same< typename XMV::array_layout, Kokkos::LayoutLeft >::value
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type>
, Axpby_MV_Invoke_Right<execution_space, AV, XMV, BV, YMV, index_type>
>::type;
Axpby_MV_Invoke_Layout::run(space, av, X, bv, Y, a, b);
} else {
std::cout << "In spec.Axpby::axpby(case 001.2)" << std::endl;
using index_type = typename XMV::size_type;
using Axpby_MV_Invoke_Layout = typename
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value // AquiCorrection
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type> // Aqui ???
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type>
, Axpby_MV_Invoke_Right<execution_space, AV, XMV, BV, YMV, index_type>
>::type;
Axpby_MV_Invoke_Layout::run(space, av, X, bv, Y, a, b);
Expand Down Expand Up @@ -273,7 +270,6 @@ struct Axpby<execution_space, typename XMV::non_const_value_type, XMV,

static void axpby(const execution_space& space, const AV& alpha, const XMV& X,
const BV& beta, const YMV& Y) {
std::cout << "Entering spec.Axpby::axpby(case 002)" << std::endl;
static_assert(Kokkos::is_view<XMV>::value,
"KokkosBlas::Impl::Axpby::axpby (MV): "
"X is not a Kokkos::View.");
Expand Down Expand Up @@ -339,20 +335,18 @@ struct Axpby<execution_space, typename XMV::non_const_value_type, XMV,

if (numRows < static_cast<size_type>(INT_MAX) &&
numRows * numCols < static_cast<size_type>(INT_MAX)) {
std::cout << "In spec.Axpby::axpby(case 002.1)" << std::endl;
using index_type = int;
using Axpby_MV_Invoke_Layout = typename
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value // AquiCorrection
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type> // Aqui ???
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type>
, Axpby_MV_Invoke_Right<execution_space, AV, XMV, BV, YMV, index_type>
>::type;
Axpby_MV_Invoke_Layout::run(space, alpha, X, beta, Y, a, b);
} else {
std::cout << "In spec.Axpby::axpby(case 002.2)" << std::endl;
using index_type = typename XMV::size_type;
using Axpby_MV_Invoke_Layout = typename
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value // AquiCorrection
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type> // Aqui ???
std::conditional< std::is_same<typename XMV::array_layout, Kokkos::LayoutLeft>::value
, Axpby_MV_Invoke_Left<execution_space, AV, XMV, BV, YMV, index_type>
, Axpby_MV_Invoke_Right<execution_space, AV, XMV, BV, YMV, index_type>
>::type;
Axpby_MV_Invoke_Layout::run(space, alpha, X, beta, Y, a, b);
Expand All @@ -375,7 +369,6 @@ struct Axpby<execution_space, AV, XV, BV, YV, 1, false,

static void axpby(const execution_space& space, const AV& av, const XV& X,
const BV& bv, const YV& Y) {
std::cout << "Entering spec.Axpby::axpby(case 003)" << std::endl;
Kokkos::Profiling::pushRegion(KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
? "KokkosBlas::axpby[ETI]"
: "KokkosBlas::axpby[noETI]");
Expand All @@ -393,12 +386,10 @@ struct Axpby<execution_space, AV, XV, BV, YV, 1, false,
}

if (numRows < static_cast<size_type>(INT_MAX)) {
std::cout << "In spec.Axpby::axpby(case 003.1)" << std::endl;
using index_type = int;
Axpby_Generic<execution_space, AV, XV, BV, YV, index_type>(
space, av, X, bv, Y, 0, a, b);
} else {
std::cout << "In spec.Axpby::axpby(case 003.2)" << std::endl;
using index_type = typename XV::size_type;
Axpby_Generic<execution_space, AV, XV, BV, YV, index_type>(
space, av, X, bv, Y, 0, a, b);
Expand Down Expand Up @@ -427,7 +418,6 @@ struct Axpby<execution_space, typename XV::non_const_value_type, XV,

static void axpby(const execution_space& space, const AV& alpha, const XV& X,
const BV& beta, const YV& Y) {
std::cout << "Entering spec.Axpby::axpby(case 004)" << std::endl;
static_assert(Kokkos::is_view<XV>::value,
"KokkosBlas::Impl::"
"Axpby<rank-1>::axpby: X is not a Kokkos::View.");
Expand Down Expand Up @@ -491,13 +481,11 @@ struct Axpby<execution_space, typename XV::non_const_value_type, XV,
#endif // KOKKOSBLAS_OPTIMIZATION_LEVEL_AXPBY > 2

if (numRows < static_cast<size_type>(INT_MAX)) {
std::cout << "In spec.Axpby::axpby(case 004.1)" << std::endl;
using index_type = int;
Axpby_Generic<execution_space, typename XV::non_const_value_type, XV,
typename YV::non_const_value_type, YV, index_type>(
space, alpha, X, beta, Y, 0, a, b);
} else {
std::cout << "In spec.Axpby::axpby(case 004.2)" << std::endl;
using index_type = typename XV::size_type;
Axpby_Generic<execution_space, typename XV::non_const_value_type, XV,
typename YV::non_const_value_type, YV, index_type>(
Expand Down
2 changes: 1 addition & 1 deletion blas/impl/KokkosBlas1_axpby_unification_attempt_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Impl {
// --------------------------------

template <class tExecSpace>
constexpr int atHostOrDev() {
constexpr int atHostOrDev() { // Aqui__

#ifdef KOKKOS_ENABLE_SERIAL
constexpr bool exec_is_serial = std::is_same_v<tExecSpace, Kokkos::Serial>;
Expand Down
Loading

0 comments on commit 01683be

Please sign in to comment.