Skip to content

Commit

Permalink
Reformat with clang-format 8
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-kelley committed Aug 1, 2024
1 parent 92267d9 commit baf6809
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
14 changes: 7 additions & 7 deletions common/src/KokkosKernels_SimpleUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ struct ReduceMaxFunctor {

template <typename view_type, typename MyExecSpace>
void kk_view_reduce_max(
const MyExecSpace& exec,
size_t num_elements, view_type view_to_reduce,
const MyExecSpace &exec, size_t num_elements, view_type view_to_reduce,
typename view_type::non_const_value_type &max_reduction) {
typedef Kokkos::RangePolicy<MyExecSpace> policy_t;
Kokkos::parallel_reduce(
Expand All @@ -418,7 +417,8 @@ template <typename view_type, typename MyExecSpace>
void kk_view_reduce_max(
size_t num_elements, view_type view_to_reduce,
typename view_type::non_const_value_type &max_reduction) {
kk_view_reduce_max(MyExecSpace(), num_elements, view_to_reduce, max_reduction);
kk_view_reduce_max(MyExecSpace(), num_elements, view_to_reduce,
max_reduction);
}

// xorshift hash/pseudorandom function (supported for 32- and 64-bit integer
Expand Down Expand Up @@ -492,10 +492,10 @@ struct SequentialFillFunctor {
};

template <typename ExecSpace, typename V>
void sequential_fill(const ExecSpace& exec, const V &v, typename V::non_const_value_type start = 0) {
Kokkos::parallel_for(
Kokkos::RangePolicy<ExecSpace>(exec, 0, v.extent(0)),
SequentialFillFunctor<V>(v, start));
void sequential_fill(const ExecSpace &exec, const V &v,
typename V::non_const_value_type start = 0) {
Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpace>(exec, 0, v.extent(0)),
SequentialFillFunctor<V>(v, start));
}

template <typename V>
Expand Down
3 changes: 2 additions & 1 deletion common/src/KokkosKernels_Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,8 @@ void view_reduce_max(size_t num_elements, view_type view_to_reduce,
}

template <typename view_type, typename MyExecSpace>
void view_reduce_max(const MyExecSpace& exec, size_t num_elements, view_type view_to_reduce,
void view_reduce_max(const MyExecSpace &exec, size_t num_elements,
view_type view_to_reduce,
typename view_type::non_const_value_type &max_reduction) {
kk_view_reduce_max<view_type, MyExecSpace>(exec, num_elements, view_to_reduce,
max_reduction);
Expand Down
30 changes: 18 additions & 12 deletions perf_test/sparse/KokkosSparse_sort_crs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void print_options() {
std::cerr << perf_test::list_common_options();

std::cerr << "\t[Required] --mtx <path> :: matrix to sort\n";
std::cerr << "\t[Optional] --repeat :: how many times to repeat sorting\n";
std::cerr
<< "\t[Optional] --repeat :: how many times to repeat sorting\n";
}

int parse_inputs(LocalParams& params, int argc, char** argv) {
Expand All @@ -53,7 +54,8 @@ int parse_inputs(LocalParams& params, int argc, char** argv) {
}

template <typename exec_space>
void run_experiment(int argc, char** argv, const CommonInputParams& common_params) {
void run_experiment(int argc, char** argv,
const CommonInputParams& common_params) {
using namespace KokkosSparse;

using mem_space = typename exec_space::memory_space;
Expand All @@ -64,25 +66,28 @@ void run_experiment(int argc, char** argv, const CommonInputParams& common_param
using crsMat_t =
KokkosSparse::CrsMatrix<scalar_t, lno_t, device_t, void, size_type>;

using graph_t = typename crsMat_t::StaticCrsGraphType;
using graph_t = typename crsMat_t::StaticCrsGraphType;

LocalParams params;
if (parse_inputs(params, argc, argv)) return;

crsMat_t A = KokkosSparse::Impl::read_kokkos_crst_matrix<crsMat_t>(
params.mtxFile.c_str());
std::cout << "Loaded matrix: " << A.numRows() << "x" << A.numCols() << " with " << A.nnz() << " entries.\n";
params.mtxFile.c_str());
std::cout << "Loaded matrix: " << A.numRows() << "x" << A.numCols()
<< " with " << A.nnz() << " entries.\n";
// This first sort call serves as a warm-up
KokkosSparse::sort_crs_matrix(A);
lno_t m = A.numRows();
lno_t n = A.numCols();
auto rowmapHost = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.row_map);
auto entriesHost = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries);
auto rowmapHost =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.row_map);
auto entriesHost =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries);
typename crsMat_t::index_type shuffledEntries("shuffled entries", A.nnz());
// Randomly shuffle the entries within each row, so that the rows aren't already sorted.
// Leave the values alone; this changes the matrix numerically but this doesn't affect sorting.
for(lno_t i = 0; i < m; i++)
{
// Randomly shuffle the entries within each row, so that the rows aren't
// already sorted. Leave the values alone; this changes the matrix numerically
// but this doesn't affect sorting.
for (lno_t i = 0; i < m; i++) {
std::random_shuffle(entriesHost.data() + i, entriesHost.data() + i + 1);
}
Kokkos::deep_copy(shuffledEntries, entriesHost);
Expand All @@ -97,7 +102,8 @@ void run_experiment(int argc, char** argv, const CommonInputParams& common_param
exec.fence();
totalTime += timer.seconds();
}
std::cout << "Mean sort_crs_matrix time over " << common_params.repeat << " trials: ";
std::cout << "Mean sort_crs_matrix time over " << common_params.repeat
<< " trials: ";
std::cout << totalTime / common_params.repeat << "\n";
}

Expand Down
8 changes: 4 additions & 4 deletions sparse/src/KokkosSparse_SortCrs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void sort_and_merge_matrix(

if (numRows == 0) {
rowmap_out = typename rowmap_t::non_const_type("SortedMerged rowmap",
rowmap_in.extent(0));
rowmap_in.extent(0));
entries_out = entries_t();
values_out = values_t();
return;
Expand Down Expand Up @@ -479,8 +479,8 @@ void sort_and_merge_matrix(
"SortedMerged entries"),
numCompressedEntries);
values_out = values_t(Kokkos::view_alloc(exec, Kokkos::WithoutInitializing,
"SortedMerged values"),
numCompressedEntries);
"SortedMerged values"),
numCompressedEntries);
// Compute merged entries and values
Kokkos::parallel_for(
range_t(exec, 0, numRows),
Expand Down Expand Up @@ -563,7 +563,7 @@ void sort_and_merge_graph(
Ordinal numRows = rowmap_in.extent(0) ? rowmap_in.extent(0) - 1 : 0;
if (numRows == 0) {
rowmap_out = typename rowmap_t::non_const_type("SortedMerged rowmap",
rowmap_in.extent(0));
rowmap_in.extent(0));
entries_out = entries_t();
return;
}
Expand Down
8 changes: 4 additions & 4 deletions sparse/src/KokkosSparse_Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,8 +1640,8 @@ void kk_create_incidence_matrix_from_original_matrix(
lno_t col_perm = col;
if (perm) col_perm = perm[col];
if (row_perm > col_perm) {
typedef typename std::remove_reference<
decltype(out_rowmap_copy[0])>::type atomic_incr_type;
typedef typename std::remove_reference<decltype(
out_rowmap_copy[0])>::type atomic_incr_type;
size_type row_write_index = Kokkos::atomic_fetch_add(
&(out_rowmap_copy[row]), atomic_incr_type(1));
size_type col_write_index = Kokkos::atomic_fetch_add(
Expand Down Expand Up @@ -1673,8 +1673,8 @@ void kk_create_incidence_matrix_from_original_matrix(
lno_t col_perm = col;
if (perm) col_perm = perm[col];
if (row_perm < col_perm) {
typedef typename std::remove_reference<
decltype(out_rowmap_copy[0])>::type atomic_incr_type;
typedef typename std::remove_reference<decltype(
out_rowmap_copy[0])>::type atomic_incr_type;
size_type row_write_index = Kokkos::atomic_fetch_add(
&(out_rowmap_copy[row]), atomic_incr_type(1));
size_type col_write_index = Kokkos::atomic_fetch_add(
Expand Down

0 comments on commit baf6809

Please sign in to comment.