-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add main functions for batched sparse solver performance tests #1554
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d4c2168
Add main functions for batched sparse solver performance tests
kliegeois 5e013fe
Remove unneeded function
kliegeois 372493d
Update of the perf tests based on Luc's comments
kliegeois 31a041f
Merge remote-tracking branch 'upstream/develop' into PR_batched_paper_2
kliegeois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
#KOKKOSKERNELS_ADD_EXECUTABLE(KokkosBatched_Test_BlockTridiag | ||
# SOURCES KokkosBatched_Test_BlockTridiagDirect.cpp | ||
#) | ||
#KOKKOSKERNELS_ADD_EXECUTABLE(KokkosBatched_Test_BlockJacobi | ||
# SOURCES KokkosBatched_Test_BlockJacobi_Tutorial.cpp | ||
#) | ||
ADD_SUBDIRECTORY(dense) | ||
ADD_SUBDIRECTORY(sparse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
#KOKKOSKERNELS_ADD_EXECUTABLE(KokkosBatched_Test_BlockTridiag | ||
# SOURCES KokkosBatched_Test_BlockTridiagDirect.cpp | ||
#) | ||
#KOKKOSKERNELS_ADD_EXECUTABLE(KokkosBatched_Test_BlockJacobi | ||
# SOURCES KokkosBatched_Test_BlockJacobi_Tutorial.cpp | ||
#) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) | ||
KOKKOSKERNELS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
|
||
KOKKOSKERNELS_ADD_EXECUTABLE(KokkosBatched_Test_CG | ||
SOURCES KokkosBatched_Test_CG.cpp | ||
) |
124 changes: 124 additions & 0 deletions
124
perf_test/batched/sparse/CG/Functor_TestBatchedTeamVectorCG_1.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
//@HEADER | ||
// ************************************************************************ | ||
// | ||
// Kokkos v. 3.4 | ||
// Copyright (2021) National Technology & Engineering | ||
// Solutions of Sandia, LLC (NTESS). | ||
// | ||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the Corporation nor the names of the | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// Questions? Contact Siva Rajamanickam (srajama@sandia.gov) | ||
// | ||
// ************************************************************************ | ||
//@HEADER | ||
|
||
template <typename DeviceType, typename ValuesViewType, typename IntView, | ||
typename VectorViewType, typename KrylovHandleType> | ||
struct Functor_TestBatchedTeamVectorCG_1 { | ||
const ValuesViewType _D; | ||
const IntView _r; | ||
const IntView _c; | ||
const VectorViewType _X; | ||
const VectorViewType _B; | ||
const int _N_team, _team_size, _vector_length; | ||
KrylovHandleType _handle; | ||
|
||
KOKKOS_INLINE_FUNCTION | ||
Functor_TestBatchedTeamVectorCG_1(const ValuesViewType &D, const IntView &r, | ||
const IntView &c, const VectorViewType &X, | ||
const VectorViewType &B, const int N_team, | ||
const int team_size, | ||
const int vector_length, | ||
KrylovHandleType &handle) | ||
: _D(D), | ||
_r(r), | ||
_c(c), | ||
_X(X), | ||
_B(B), | ||
_N_team(N_team), | ||
_team_size(team_size), | ||
_vector_length(vector_length), | ||
_handle(handle) {} | ||
|
||
template <typename MemberType> | ||
KOKKOS_INLINE_FUNCTION void operator()(const MemberType &member) const { | ||
const int first_matrix = _handle.first_index(member.league_rank()); | ||
const int last_matrix = _handle.last_index(member.league_rank()); | ||
|
||
auto d = Kokkos::subview(_D, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
auto x = Kokkos::subview(_X, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
auto b = Kokkos::subview(_B, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
|
||
using Operator = KokkosBatched::CrsMatrix<ValuesViewType, IntView>; | ||
|
||
Operator A(d, _r, _c); | ||
|
||
KokkosBatched::TeamVectorCG<MemberType>::template invoke<Operator, | ||
VectorViewType>( | ||
member, A, b, x, _handle); | ||
} | ||
|
||
inline double run() { | ||
std::string name("KokkosBatched::Test::TeamCG"); | ||
Kokkos::Timer timer; | ||
Kokkos::Profiling::pushRegion(name.c_str()); | ||
|
||
_handle.set_memory_strategy(1); | ||
|
||
_handle.tmp_view = typename KrylovHandleType::TemporaryViewType( | ||
"", _X.extent(0), 4 * _X.extent(1)); | ||
|
||
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) | ||
policy = auto_policy; | ||
else | ||
policy = tuned_policy; | ||
|
||
size_t bytes_0 = ValuesViewType::shmem_size(_N_team, 5); | ||
policy.set_scratch_size(0, Kokkos::PerTeam(bytes_0)); | ||
|
||
timer.reset(); | ||
Kokkos::parallel_for(name.c_str(), policy, *this); | ||
exec_space().fence(); | ||
double sec = timer.seconds(); | ||
Kokkos::Profiling::popRegion(); | ||
|
||
return sec; | ||
} | ||
}; |
149 changes: 149 additions & 0 deletions
149
perf_test/batched/sparse/CG/Functor_TestBatchedTeamVectorCG_2.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
//@HEADER | ||
// ************************************************************************ | ||
// | ||
// Kokkos v. 3.4 | ||
// Copyright (2021) National Technology & Engineering | ||
// Solutions of Sandia, LLC (NTESS). | ||
// | ||
// Under the terms of Contract DE-NA0003525 with NTESS, | ||
// the U.S. Government retains certain rights in this software. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the Corporation nor the names of the | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY | ||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// Questions? Contact Siva Rajamanickam (srajama@sandia.gov) | ||
// | ||
// ************************************************************************ | ||
//@HEADER | ||
|
||
template <typename DeviceType, typename ValuesViewType, typename IntView, | ||
typename VectorViewType, typename KrylovHandleType> | ||
struct Functor_TestBatchedTeamVectorCG_2 { | ||
const ValuesViewType _D; | ||
const IntView _r; | ||
const IntView _c; | ||
const VectorViewType _X; | ||
const VectorViewType _B; | ||
const int _N_team, _team_size, _vector_length; | ||
KrylovHandleType _handle; | ||
|
||
KOKKOS_INLINE_FUNCTION | ||
Functor_TestBatchedTeamVectorCG_2(const ValuesViewType &D, const IntView &r, | ||
const IntView &c, const VectorViewType &X, | ||
const VectorViewType &B, const int N_team, | ||
const int team_size, | ||
const int vector_length, | ||
KrylovHandleType &handle) | ||
: _D(D), | ||
_r(r), | ||
_c(c), | ||
_X(X), | ||
_B(B), | ||
_N_team(N_team), | ||
_team_size(team_size), | ||
_vector_length(vector_length), | ||
_handle(handle) {} | ||
|
||
template <typename MemberType> | ||
KOKKOS_INLINE_FUNCTION void operator()(const MemberType &member) const { | ||
const int first_matrix = _handle.first_index(member.league_rank()); | ||
const int last_matrix = _handle.last_index(member.league_rank()); | ||
|
||
using TeamVectorCopy1D = | ||
KokkosBatched::TeamVectorCopy<MemberType, | ||
KokkosBatched::Trans::NoTranspose, 1>; | ||
|
||
auto d = Kokkos::subview(_D, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
auto x = Kokkos::subview(_X, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
auto b = Kokkos::subview(_B, Kokkos::make_pair(first_matrix, last_matrix), | ||
Kokkos::ALL); | ||
|
||
using ScratchPadIntViewType = | ||
Kokkos::View<typename IntView::non_const_value_type *, | ||
typename IntView::array_layout, | ||
typename IntView::execution_space::scratch_memory_space>; | ||
|
||
using Operator = | ||
KokkosBatched::CrsMatrix<ValuesViewType, ScratchPadIntViewType>; | ||
|
||
ScratchPadIntViewType tmp_1D_int(member.team_scratch(0), | ||
_r.extent(0) + _c.extent(0)); | ||
|
||
auto r = | ||
Kokkos::subview(tmp_1D_int, Kokkos::make_pair(0, (int)_r.extent(0))); | ||
auto c = Kokkos::subview( | ||
tmp_1D_int, | ||
Kokkos::make_pair((int)_r.extent(0), (int)tmp_1D_int.extent(0))); | ||
|
||
TeamVectorCopy1D::invoke(member, _r, r); | ||
TeamVectorCopy1D::invoke(member, _c, c); | ||
Operator A(d, r, c); | ||
|
||
KokkosBatched::TeamVectorCG<MemberType>::template invoke<Operator, | ||
VectorViewType>( | ||
member, A, b, x, _handle); | ||
} | ||
|
||
inline double run() { | ||
std::string name("KokkosBatched::Test::TeamCG"); | ||
Kokkos::Timer timer; | ||
Kokkos::Profiling::pushRegion(name.c_str()); | ||
|
||
_handle.set_memory_strategy(1); | ||
|
||
_handle.tmp_view = typename KrylovHandleType::TemporaryViewType( | ||
"", _X.extent(0), 4 * _X.extent(1)); | ||
|
||
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) | ||
policy = auto_policy; | ||
else | ||
policy = tuned_policy; | ||
|
||
size_t bytes_row_ptr = IntView::shmem_size(_r.extent(0)); | ||
size_t bytes_col_idc = IntView::shmem_size(_c.extent(0)); | ||
size_t bytes_int = bytes_row_ptr + bytes_col_idc; | ||
size_t bytes_0 = ValuesViewType::shmem_size(_N_team, 5); | ||
|
||
policy.set_scratch_size(0, Kokkos::PerTeam(bytes_int + bytes_0)); | ||
|
||
timer.reset(); | ||
Kokkos::parallel_for(name.c_str(), policy, *this); | ||
exec_space().fence(); | ||
double sec = timer.seconds(); | ||
Kokkos::Profiling::popRegion(); | ||
|
||
return sec; | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that directory empty except for
.gitignore
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the file KokkosBatched_Test_Sparse_Helper.hpp