Skip to content

Commit

Permalink
Update of the perf tests based on Luc's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kliegeois committed Nov 9, 2022
1 parent 5e013fe commit 372493d
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ struct Functor_TestBatchedTeamVectorCG_1 {
_handle.tmp_view = typename KrylovHandleType::TemporaryViewType(
"", _X.extent(0), 4 * _X.extent(1));

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ struct Functor_TestBatchedTeamVectorCG_2 {
_handle.tmp_view = typename KrylovHandleType::TemporaryViewType(
"", _X.extent(0), 4 * _X.extent(1));

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ struct Functor_TestBatchedTeamVectorCG_3 {

_handle.set_memory_strategy(0);

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
38 changes: 17 additions & 21 deletions perf_test/batched/sparse/CG/KokkosBatched_Test_CG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,11 @@

/// Kokkos headers
#include "Kokkos_Core.hpp"
#include "Kokkos_Timer.hpp"
#include "Kokkos_Random.hpp"
#include "Kokkos_UnorderedMap.hpp"
#include "Kokkos_Sort.hpp"

/// KokkosKernels headers
#include "Kokkos_ArithTraits.hpp"
#include "KokkosBatched_Util.hpp"
#include "KokkosBatched_Vector.hpp"

#include <Kokkos_ArithTraits.hpp>
#include <KokkosBatched_Util.hpp>
#include <KokkosBatched_Vector.hpp>
#include <KokkosBatched_Copy_Decl.hpp>
#include <KokkosBatched_AddRadial_Decl.hpp>
#include <KokkosBatched_Gemm_Decl.hpp>
#include <KokkosBatched_Gemv_Decl.hpp>
#include <KokkosBatched_Trsm_Decl.hpp>
#include <KokkosBatched_Trsv_Decl.hpp>
#include <KokkosBatched_LU_Decl.hpp>
#include <KokkosSparse_CrsMatrix.hpp>

#include "KokkosBatched_Test_Sparse_Helper.hpp"

#include "KokkosBatched_Spmv.hpp"
Expand Down Expand Up @@ -128,15 +112,29 @@ int main(int argc, char *argv[]) {
<< std::endl
<< "-timers : Filename of the output timers."
<< std::endl
<< "-n1 : Number of repetitions 1." << std::endl
<< "-n2 : Number of repetitions 2." << std::endl
<< "-n1 : Number of repetitions of the experience."
<< std::endl
<< "-n2 : Number of the kernel calls inside one "
"experience."
<< std::endl
<< "-team_size : Used team size." << std::endl
<< "-n_implementations: Number of implementations to use: test "
"all "
"implementations [0, specified number -1]."
<< std::endl
<< "-implementation : Specify only one implementation at a time."
<< std::endl
<< " Note: implementation 0 : use scratch pad "
"only for scalar temporary variable."
<< std::endl
<< " Note: implementation 1 : use scratch pad "
"for scalar temporary variables and for the graph of the "
"matrices."
<< std::endl
<< " Note: implementation 2 : use scratch pad "
"for scalar and vector temporary variables and for the graph of "
"the matrices."
<< std::endl
<< "-l : Specify left layout." << std::endl
<< "-r : Specify right layout." << std::endl
<< "-C : Specify if the convergence is monitored."
Expand Down Expand Up @@ -273,8 +271,6 @@ int main(int argc, char *argv[]) {
flush.run();
exec_space().fence();

exec_space().fence();

if (i_impl == 0 && layout_left) {
t_spmv +=
Functor_TestBatchedTeamVectorCG_1<exec_space,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ struct Functor_TestBatchedTeamVectorGMRES_1 {
_handle.tmp_view = typename KrylovHandleType::TemporaryViewType(
"", _X.extent(0), _X.extent(1) + maximum_iteration + 3);

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ struct Functor_TestBatchedTeamVectorGMRES_2 {
Kokkos::Timer timer;
Kokkos::Profiling::pushRegion(name.c_str());

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ struct Functor_TestBatchedTeamVectorGMRES_3 {
Kokkos::Timer timer;
Kokkos::Profiling::pushRegion(name.c_str());

Kokkos::TeamPolicy<DeviceType> auto_policy(
ceil(1. * _D.extent(0) / _N_team), Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(
ceil(1. * _D.extent(0) / _N_team), _team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> auto_policy(_handle.get_number_of_teams(),
Kokkos::AUTO(), Kokkos::AUTO());
Kokkos::TeamPolicy<DeviceType> tuned_policy(_handle.get_number_of_teams(),
_team_size, _vector_length);
Kokkos::TeamPolicy<DeviceType> policy;

if (_team_size < 1)
Expand Down
42 changes: 16 additions & 26 deletions perf_test/batched/sparse/GMRES/KokkosBatched_Test_GMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,18 @@

/// Kokkos headers
#include "Kokkos_Core.hpp"
#include "Kokkos_Timer.hpp"
#include "Kokkos_Random.hpp"
#include "Kokkos_UnorderedMap.hpp"
#include "Kokkos_Sort.hpp"

/// KokkosKernels headers
#include "Kokkos_ArithTraits.hpp"
#include "KokkosBatched_Util.hpp"
#include "KokkosBatched_Vector.hpp"

#include <Kokkos_ArithTraits.hpp>
#include <KokkosBatched_Util.hpp>
#include <KokkosBatched_Vector.hpp>
#include <KokkosBatched_Copy_Decl.hpp>
#include <KokkosBatched_AddRadial_Decl.hpp>
#include <KokkosBatched_Gemm_Decl.hpp>
#include <KokkosBatched_Gemv_Decl.hpp>
#include <KokkosBatched_Trsm_Decl.hpp>
#include <KokkosBatched_Trsv_Decl.hpp>
#include <KokkosBatched_LU_Decl.hpp>
#include <KokkosSparse_CrsMatrix.hpp>

#include "KokkosBatched_Test_Sparse_Helper.hpp"

#include "KokkosBatched_Spmv.hpp"
#include "KokkosBatched_CrsMatrix.hpp"
#include "KokkosBatched_Krylov_Handle.hpp"
#include "KokkosBatched_GMRES.hpp"
#include "KokkosBatched_JacobiPrec.hpp"
#include "KokkosBatched_Dot.hpp"
#include "KokkosBatched_Util.hpp"
#include "KokkosBatched_Dot_Internal.hpp"
#include "KokkosBatched_Spmv_Serial_Impl.hpp"
#include "KokkosBatched_Copy_Decl.hpp"

typedef Kokkos::DefaultExecutionSpace exec_space;
typedef typename exec_space::memory_space memory_space;
Expand Down Expand Up @@ -150,15 +129,28 @@ int main(int argc, char *argv[]) {
<< "-other_level : Select the scratch pad level (if used) "
"where everything except the Arnoldi vectors are stored."
<< std::endl
<< "-n1 : Number of repetitions 1." << std::endl
<< "-n2 : Number of repetitions 2." << std::endl
<< "-n1 : Number of repetitions of the experience."
<< std::endl
<< "-n2 : Number of the kernel calls inside one "
"experience."
<< std::endl
<< "-team_size : Used team size." << std::endl
<< "-n_implementations: Number of implementations to use: test "
"all "
"implementations [0, specified number -1]."
<< std::endl
<< "-implementation : Specify only one implementation at a time."
<< std::endl
<< " Note: implementation 0 : does not use "
"scratch pad."
<< std::endl
<< " Note: implementation 1 : use scratch pad "
"for the graph and for the diagonal entries of the matrices."
<< std::endl
<< " Note: implementation 2 : use scratch pad "
"for the graph and for the diagonal entries of the matrices and "
"for the temporary variable but not for the Arnoldi vectors."
<< std::endl
<< "-l : Specify left layout." << std::endl
<< "-r : Specify right layout." << std::endl
<< "-P : Specify if a Jacobi preconditioner is "
Expand Down Expand Up @@ -318,8 +310,6 @@ int main(int argc, char *argv[]) {
flush.run();
exec_space().fence();

exec_space().fence();

if (i_impl == 0 && layout_left) {
if (use_preconditioner)
t_spmv += Functor_TestBatchedTeamVectorGMRES_1<
Expand Down
43 changes: 0 additions & 43 deletions perf_test/batched/sparse/KokkosBatched_Test_Sparse_Helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,6 @@ void readArrayFromMM(std::string name, const XType &x) {
input.close();

Kokkos::deep_copy(x, x_h);

/*
std::ofstream myfile;
myfile.open("x-data.txt");
for (size_t i = 0; i < x_h.extent(0); ++i) {
for (size_t j = 0; j < x_h.extent(1); ++j) {
myfile << std::setprecision (15) << x_h(i, j) << " ";
}
myfile << std::endl;
}
myfile.close();
*/
}

template <class AType>
Expand Down Expand Up @@ -195,21 +180,6 @@ void readCRSFromMM(std::string name, const VType &V, const IntType &r,
Kokkos::deep_copy(V, V_h);
Kokkos::deep_copy(r, r_h);
Kokkos::deep_copy(c, c_h);

/*
std::ofstream myfile;
myfile.open("a-data.txt");
for (size_t i = 0; i < nrows; ++i) {
for (size_t j = r_h(i); j < r_h(i+1); ++j) {
myfile << std::setprecision (15) << i+1 << " " << c_h(j)+1 << " " <<
V_h(0, j) << std::endl;
}
}
myfile.close();
*/
}

template <class VType, class IntType>
Expand Down Expand Up @@ -238,17 +208,4 @@ void getInvDiagFromCRS(const VType &V, const IntType &r, const IntType &c,
}

Kokkos::deep_copy(diag, diag_values_host);

/*
std::ofstream myfile;
myfile.open("a-diag.txt");
for (size_t i = 0; i < BlkSize; ++i) {
myfile << std::setprecision (15) << i+1 << " " << diag_values_host(0, i)
<< std::endl;
}
myfile.close();
*/
}
55 changes: 27 additions & 28 deletions perf_test/batched/sparse/SPMV/KokkosBatched_Test_SPMV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,12 @@

/// Kokkos headers
#include "Kokkos_Core.hpp"
#include "Kokkos_Timer.hpp"
#include "Kokkos_Random.hpp"
#include "Kokkos_UnorderedMap.hpp"
#include "Kokkos_Sort.hpp"

/// KokkosKernels headers
#include "Kokkos_ArithTraits.hpp"
#include "KokkosBatched_Util.hpp"
#include "KokkosBatched_Vector.hpp"

#include <Kokkos_ArithTraits.hpp>
#include <KokkosBatched_Util.hpp>
#include <KokkosBatched_Vector.hpp>
#include <KokkosBatched_Copy_Decl.hpp>
#include <KokkosBatched_AddRadial_Decl.hpp>
#include <KokkosBatched_Gemm_Decl.hpp>
#include <KokkosBatched_Gemv_Decl.hpp>
#include <KokkosBatched_Trsm_Decl.hpp>
#include <KokkosBatched_Trsv_Decl.hpp>
#include <KokkosBatched_LU_Decl.hpp>
#include <KokkosSparse_CrsMatrix.hpp>
#include <KokkosBatched_SPMV_View.hpp>

#include "KokkosBatched_Test_Sparse_Helper.hpp"

#include "KokkosBatched_SPMV_View.hpp"
#include "KokkosBatched_Spmv.hpp"

typedef Kokkos::DefaultExecutionSpace exec_space;
Expand Down Expand Up @@ -106,9 +88,6 @@ struct Functor_TestBatchedTeamVectorSpmv {

template <typename MemberType>
KOKKOS_INLINE_FUNCTION void operator()(const MemberType &member) const {
// int team_size = member.team_size();
// printf("team_size %d\n", team_size);
// std::cout << "member.team_size() = " << member.team_size() << std::endl;
const int first_matrix =
static_cast<int>(member.league_rank()) * _matrices_per_team;
const int N = _D.extent(0);
Expand Down Expand Up @@ -209,15 +188,36 @@ int main(int argc, char *argv[]) {
<< std::endl
<< "-timers : Filename of the output timers."
<< std::endl
<< "-n1 : Number of repetitions 1." << std::endl
<< "-n2 : Number of repetitions 2." << std::endl
<< "-n1 : Number of repetitions of the experience."
<< std::endl
<< "-n2 : Number of the kernel calls inside one "
"experience."
<< std::endl
<< "-team_size : Used team size." << std::endl
<< "-n_implementations: Number of implementations to use: test "
"all "
"implementations [0, specified number -1]."
<< std::endl
<< "-implementation : Specify only one implementation at a time."
<< std::endl
<< " Note: implementation 0 : use a Team "
"approach where a Team have to apply N_team SPMV. A given team "
"applies N_team SPMV sequentially and uses a ThreadRange over "
"the row and a VectorRange over the non zero entries of a given "
"row."
<< std::endl
<< " Note: implementation 1 : use a Team "
"approach where a Team have to apply N_team SPMV. A given team "
"uses a fused thread vector range policy to loop over the "
"independent fibers."
<< std::endl
<< " Note: implementation 2 : same as "
"implementation 1 but using scratch pad for the graph."
<< std::endl
<< " Note: implementation 3 : same as "
"implementation 1 but using the kernels from "
"batched/sparse/impl/*."
<< std::endl
<< "-l : Specify left layout." << std::endl
<< "-r : Specify right layout." << std::endl
<< "-N_team : Specify the number of systems per team."
Expand Down Expand Up @@ -348,9 +348,8 @@ int main(int argc, char *argv[]) {
timer.reset();
exec_space().fence();

int N_team = i_impl == 0 ? 1 : N_team_potential;
N_team = N_team_potential;
int number_of_teams = i_impl == 0 ? N : ceil(1. * N / N_team);
int N_team = N_team_potential;
int number_of_teams = ceil(static_cast<double>(N) / N_team);

if (layout_left) {
using policy_type = Kokkos::TeamPolicy<exec_space>;
Expand Down
Loading

0 comments on commit 372493d

Please sign in to comment.