Skip to content

Commit

Permalink
Replace atomic_{inc, dec}[rement] (#2386)
Browse files Browse the repository at this point in the history
Signed-off-by: Damien L-G <[email protected]>
  • Loading branch information
dalg24 authored Oct 17, 2024
1 parent 3886cf9 commit 7f53afa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion graph/impl/KokkosGraph_Distance2MIS_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ struct D2_MIS_Aggregation {
KOKKOS_INLINE_FUNCTION void operator()(lno_t i) const {
lno_t agg = labels_(i);
if (agg != -1) {
Kokkos::atomic_increment(&aggSizes_(agg));
Kokkos::atomic_inc(&aggSizes_(agg));
// compute connectivity of i
size_type rowBegin = rowmap_(i);
size_type rowEnd = rowmap_(i + 1);
Expand Down
2 changes: 1 addition & 1 deletion graph/impl/KokkosGraph_ExplicitCoarsening_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ExplicitGraphCoarsening {
struct ClusterSizeFunctor {
ClusterSizeFunctor(const ordinal_view_t& counts_, const labels_t& vertClusters_)
: counts(counts_), vertClusters(vertClusters_) {}
KOKKOS_INLINE_FUNCTION void operator()(const lno_t i) const { Kokkos::atomic_increment(&counts(vertClusters(i))); }
KOKKOS_INLINE_FUNCTION void operator()(const lno_t i) const { Kokkos::atomic_inc(&counts(vertClusters(i))); }
ordinal_view_t counts;
labels_t vertClusters;
};
Expand Down
8 changes: 4 additions & 4 deletions sparse/impl/KokkosSparse_bspgemm_impl_kkmem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ struct KokkosBSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
kk_vector_block_add_mul(block_dim, vals + trial * block_size, a_val, b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -631,7 +631,7 @@ struct KokkosBSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
kk_vector_block_add_mul(block_dim, vals + trial * block_size, a_val, b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -653,7 +653,7 @@ struct KokkosBSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_
} else if (global_acc_row_keys[trial] == init_value) {
if (Kokkos::atomic_compare_exchange_strong(global_acc_row_keys + trial, init_value, my_b_col)) {
kk_vector_block_add_mul(block_dim, global_acc_row_vals + trial * block_size, a_val, b_val);
// Kokkos::atomic_increment(used_hash_sizes + 1);
// Kokkos::atomic_inc(used_hash_sizes + 1);
// c_row_vals[trial] = my_b_val;
fail = 0;
break;
Expand All @@ -670,7 +670,7 @@ struct KokkosBSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_
break;
} else if (global_acc_row_keys[trial] == init_value) {
if (Kokkos::atomic_compare_exchange_strong(global_acc_row_keys + trial, init_value, my_b_col)) {
// Kokkos::atomic_increment(used_hash_sizes + 1);
// Kokkos::atomic_inc(used_hash_sizes + 1);
kk_vector_block_add_mul(block_dim, global_acc_row_vals + trial * block_size, a_val, b_val);
// c_row_vals[trial] = my_b_val;
break;
Expand Down
6 changes: 3 additions & 3 deletions sparse/impl/KokkosSparse_partitioning_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct BalloonClustering {
nnz_lno_t cluster = state.rand(numClusters);
randPool.free_state(state);
vertClusters(i) = cluster;
Kokkos::atomic_increment(&clusterCounts(cluster));
Kokkos::atomic_inc(&clusterCounts(cluster));
distances(i) = numRows;
pressure(i) = 0.1;
}
Expand Down Expand Up @@ -175,8 +175,8 @@ struct BalloonClustering {
// this cluster will take over weakNei
if (vertLocks.set(i)) {
if (vertLocks.set(weakNei)) {
Kokkos::atomic_increment(&clusterCounts(cluster));
if (weakNeiCluster != numClusters) Kokkos::atomic_decrement(&clusterCounts(weakNeiCluster));
Kokkos::atomic_inc(&clusterCounts(cluster));
if (weakNeiCluster != numClusters) Kokkos::atomic_dec(&clusterCounts(weakNeiCluster));
vertClusters(weakNei) = cluster;
pressure(i) -= pressure(weakNei);
pressure(weakNei) = pressure(i);
Expand Down
8 changes: 4 additions & 4 deletions sparse/impl/KokkosSparse_spgemm_impl_kkmem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -716,7 +716,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -739,7 +739,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
} else if (global_acc_row_keys[trial] == init_value) {
if (Kokkos::atomic_compare_exchange_strong(global_acc_row_keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(global_acc_row_vals + trial, my_b_val);
// Kokkos::atomic_increment(used_hash_sizes + 1);
// Kokkos::atomic_inc(used_hash_sizes + 1);
// c_row_vals[trial] = my_b_val;
fail = 0;
break;
Expand All @@ -757,7 +757,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (global_acc_row_keys[trial] == init_value) {
if (Kokkos::atomic_compare_exchange_strong(global_acc_row_keys + trial, init_value, my_b_col)) {
// Kokkos::atomic_increment(used_hash_sizes + 1);
// Kokkos::atomic_inc(used_hash_sizes + 1);
Kokkos::atomic_add(global_acc_row_vals + trial, my_b_val);
// c_row_vals[trial] = my_b_val;
break;
Expand Down
8 changes: 4 additions & 4 deletions sparse/impl/KokkosSparse_spgemm_jacobi_sparseacc_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -837,7 +837,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand Down Expand Up @@ -939,7 +939,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand All @@ -962,7 +962,7 @@ struct KokkosSPGEMM<HandleType, a_row_view_t_, a_lno_nnz_view_t_, a_scalar_nnz_v
break;
} else if (Kokkos::atomic_compare_exchange_strong(keys + trial, init_value, my_b_col)) {
Kokkos::atomic_add(vals + trial, my_b_val);
Kokkos::atomic_increment(used_hash_sizes);
Kokkos::atomic_inc(used_hash_sizes);
if (used_hash_sizes[0] > max_first_level_hash_size) insert_is_on = false;
fail = 0;
break;
Expand Down

0 comments on commit 7f53afa

Please sign in to comment.