Skip to content
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

atomic_fetch_add: explicit casts needed for '1' increments #159

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/common/KokkosKernels_HashmapAccumulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ struct HashmapAccumulator{
(*used_size_) += num_writes;
});
*/
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));


if (my_write_index >= max_value_size_) {
Expand All @@ -749,7 +749,7 @@ struct HashmapAccumulator{
values[my_write_index] = value;
size_type hashbeginning = Kokkos::atomic_exchange(hash_begins+hash, my_write_index);
if (hashbeginning == -1){
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, 1)] = hash;
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, size_type(1))] = hash;
}
hash_nexts[my_write_index] = hashbeginning;
return INSERT_SUCCESS;
Expand Down Expand Up @@ -821,7 +821,7 @@ struct HashmapAccumulator{
if (used_size_[0] >= max_value_size_){
return INSERT_FULL;
}
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));


if (my_write_index >= max_value_size_) {
Expand Down Expand Up @@ -886,7 +886,7 @@ struct HashmapAccumulator{

size_type my_write_index = 0;
if (key_not_found){
my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));
//my_write_index = used_size_[0]++;
}
else {
Expand Down Expand Up @@ -975,7 +975,7 @@ struct HashmapAccumulator{

size_type my_write_index = 0;
if (key_not_found){
my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));
//my_write_index = used_size_[0]++;
}
else {
Expand Down Expand Up @@ -1103,7 +1103,7 @@ struct HashmapAccumulator{
//md note somehow commented part
if (initial_hash_begin == end_of_link || (keys[initial_hash_begin] > key)){
{
volatile size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
volatile size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));
#if 0
if (print) std::cout << "\t 8 my_write_index :" << my_write_index << " max_value_size_:" << max_value_size_ << std::endl;
#endif
Expand Down Expand Up @@ -1255,7 +1255,7 @@ struct HashmapAccumulator{
#endif
//we need to insert it to beginning.
{
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, 1);
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));
#if 0
if (print) std::cout << "\t 13 my_write_index :" << my_write_index << " max_value_size_:" << max_value_size_ << std::endl;
#endif
Expand Down Expand Up @@ -1708,7 +1708,7 @@ struct HashmapAccumulator{
values[my_write_index] = value;
size_type hashbeginning = Kokkos::atomic_exchange(hash_begins+hash, my_write_index);
if (hashbeginning == -1){
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, 1)] = hash;
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, size_type(1))] = hash;
}
hash_nexts[my_write_index] = hashbeginning;
vals_counts_gmem[my_write_index] = 1;
Expand Down Expand Up @@ -1742,7 +1742,7 @@ struct HashmapAccumulator{
return INSERT_SUCCESS;
}

size_type my_write_index = Kokkos::atomic_fetch_add(used_size_,1 );
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));

if (my_write_index >= max_value_size_) {
return INSERT_FULL;
Expand Down Expand Up @@ -1790,7 +1790,7 @@ struct HashmapAccumulator{
return INSERT_SUCCESS;
}

size_type my_write_index = Kokkos::atomic_fetch_add(used_size_,1 );
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));

if (my_write_index >= max_value_size_) {
return INSERT_FULL;
Expand Down Expand Up @@ -1877,7 +1877,7 @@ struct HashmapAccumulator{
return INSERT_SUCCESS;
}

size_type my_write_index = Kokkos::atomic_fetch_add(used_size_,1 );
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));

if (my_write_index >= max_value_size_) {
return INSERT_FULL;
Expand All @@ -1888,7 +1888,7 @@ struct HashmapAccumulator{
values[my_write_index] = value;
size_type hashbeginning = Kokkos::atomic_exchange(hash_begins+hash, my_write_index);
if (hashbeginning == -1){
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, 1)] = hash;
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, size_type(1))] = hash;
}
hash_nexts[my_write_index] = hashbeginning;
return INSERT_SUCCESS;
Expand Down Expand Up @@ -1921,7 +1921,7 @@ struct HashmapAccumulator{
return INSERT_SUCCESS;
}

size_type my_write_index = Kokkos::atomic_fetch_add(used_size_,1 );
size_type my_write_index = Kokkos::atomic_fetch_add(used_size_, size_type(1));

if (my_write_index >= max_value_size_) {
return INSERT_FULL;
Expand All @@ -1932,7 +1932,7 @@ struct HashmapAccumulator{
//values[my_write_index] = value;
size_type hashbeginning = Kokkos::atomic_exchange(hash_begins+hash, my_write_index);
if (hashbeginning == -1){
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, 1)] = hash;
used_hashes[Kokkos::atomic_fetch_add(used_hash_size, size_type(1))] = hash;
}
hash_nexts[my_write_index] = hashbeginning;
return INSERT_SUCCESS;
Expand Down
3 changes: 2 additions & 1 deletion src/common/KokkosKernels_PrintUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ struct Histogram{

KOKKOS_INLINE_FUNCTION
void operator()(const size_t &ii) const {
Kokkos::atomic_fetch_add(&(outview(inview(ii))),1);
typedef typename std::remove_reference< decltype(outview(0)) >::type atomic_incr_type;
Kokkos::atomic_fetch_add(&(outview(inview(ii))), atomic_incr_type(1));
}
};

Expand Down
34 changes: 22 additions & 12 deletions src/common/KokkosKernels_SparseUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ struct TransposeMatrix{
[&] (nnz_lno_t i) {
const size_type adjind = i + col_begin;
const nnz_lno_t colIndex = adj[adjind];
Kokkos::atomic_fetch_add(&(t_xadj(colIndex)),1);
typedef typename std::remove_reference< decltype( t_xadj(0) ) >::type atomic_incr_type;
Kokkos::atomic_fetch_add(&(t_xadj(colIndex)), atomic_incr_type(1));
});
});
}
Expand All @@ -157,7 +158,8 @@ struct TransposeMatrix{
[&] (nnz_lno_t i) {
const size_type adjind = i + col_begin;
const nnz_lno_t colIndex = adj[adjind];
const size_type pos = Kokkos::atomic_fetch_add(&(tmp_txadj(colIndex)),1);
typedef typename std::remove_reference< decltype( tmp_txadj(0) ) >::type atomic_incr_type;
const size_type pos = Kokkos::atomic_fetch_add(&(tmp_txadj(colIndex)), atomic_incr_type(1));

t_adj(pos) = row_index;
if (transpose_values){
Expand Down Expand Up @@ -300,7 +302,8 @@ struct Fill_Reverse_Scale_Functor{
forward_type fm = forward_map[ii];
fm = fm << multiply_shift_for_scale;
fm += ii >> division_shift_for_bucket;
Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm)), 1);
typedef typename std::remove_reference< decltype( reverse_map_xadj(0) ) >::type atomic_incr_type;
Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm)), atomic_incr_type(1));
}

KOKKOS_INLINE_FUNCTION
Expand All @@ -309,7 +312,8 @@ struct Fill_Reverse_Scale_Functor{

fm = fm << multiply_shift_for_scale;
fm += ii >> division_shift_for_bucket;
const reverse_type future_index = Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm )), 1);
typedef typename std::remove_reference< decltype( reverse_map_xadj(0) ) >::type atomic_incr_type;
const reverse_type future_index = Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm) ), atomic_incr_type(1));
reverse_map_adj(future_index) = ii;
}
};
Expand Down Expand Up @@ -358,13 +362,15 @@ struct Reverse_Map_Functor{
KOKKOS_INLINE_FUNCTION
void operator()(const CountTag&, const size_t &ii) const {
forward_type fm = forward_map[ii];
Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm)), 1);
typedef typename std::remove_reference< decltype( reverse_map_xadj(0) ) >::type atomic_incr_type;
Kokkos::atomic_fetch_add( &(reverse_map_xadj(fm)), atomic_incr_type(1));
}

KOKKOS_INLINE_FUNCTION
void operator()(const FillTag&, const size_t &ii) const {
forward_type c = forward_map[ii];
const reverse_type future_index = Kokkos::atomic_fetch_add( &(reverse_map_xadj(c)), 1);
typedef typename std::remove_reference< decltype( reverse_map_xadj(0) ) >::type atomic_incr_type;
const reverse_type future_index = Kokkos::atomic_fetch_add( &(reverse_map_xadj(c)), atomic_incr_type(1));
reverse_map_adj(future_index) = ii;
}
};
Expand Down Expand Up @@ -1657,7 +1663,8 @@ void kk_create_incidence_matrix_from_lower_triangle(

Kokkos::parallel_for(my_exec_space(0, ne),
KOKKOS_LAMBDA(const lno_t& i) {
Kokkos::atomic_fetch_add(&(out_rowmap[in_lower_entries[i]]),1);
typedef typename std::remove_reference< decltype( out_rowmap[0] ) >::type atomic_incr_type;
Kokkos::atomic_fetch_add(&(out_rowmap[in_lower_entries[i]]), atomic_incr_type(1));
});

exec_space::fence();
Expand Down Expand Up @@ -1694,7 +1701,8 @@ void kk_create_incidence_matrix_from_lower_triangle(
Kokkos::parallel_for(my_exec_space(0, ne),
KOKKOS_LAMBDA(const size_type& edge_ind) {
lno_t col = in_lower_entries[edge_ind];
size_type write_ind = Kokkos::atomic_fetch_add(&(out_rowmap_copy(col)),1);
typedef typename std::remove_reference< decltype( out_rowmap_copy(0) ) >::type atomic_incr_type;
size_type write_ind = Kokkos::atomic_fetch_add(&(out_rowmap_copy(col)), atomic_incr_type(1));
out_entries[write_ind] = edge_ind;
});

Expand Down Expand Up @@ -1786,8 +1794,9 @@ void kk_create_incidence_matrix_from_original_matrix(
lno_t col_perm = col;
if (perm) col_perm = perm[col];
if (row_perm > col_perm){
size_type row_write_index = Kokkos::atomic_fetch_add(&(out_rowmap_copy[row]),1);
size_type col_write_index = Kokkos::atomic_fetch_add(&(out_rowmap_copy[col]),1);
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(&(out_rowmap_copy[col]), atomic_incr_type(1));
out_entries[row_write_index] = used_edge_index + used_count;
out_entries[col_write_index] = used_edge_index + used_count;
++used_count;
Expand Down Expand Up @@ -1817,8 +1826,9 @@ void kk_create_incidence_matrix_from_original_matrix(
lno_t col_perm = col;
if (perm) col_perm = perm[col];
if (row_perm < col_perm){
size_type row_write_index = Kokkos::atomic_fetch_add(&(out_rowmap_copy[row]),1);
size_type col_write_index = Kokkos::atomic_fetch_add(&(out_rowmap_copy[col]),1);
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(&(out_rowmap_copy[col]), atomic_incr_type(1));
out_entries[row_write_index] = used_edge_index + used_count;
out_entries[col_write_index] = used_edge_index + used_count;
++used_count;
Expand Down
Loading