XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
access_add.hpp
Go to the documentation of this file.
1 #ifndef ACCESS_ADD_HPP
2 #define ACCESS_ADD_HPP
3 #include "space_settings.hpp"
4 
5 // returns omp thread if on CPU (using array replication strategy for scatter) or
6 // returns 0 on GPU (uses atomics, no replication needed)
7 KOKKOS_INLINE_FUNCTION int get_thread(){
8 #if defined(USE_ARRAY_REPLICATION) && defined(USE_OMP)
9  return omp_get_thread_num();
10 #else
11  return 0;
12 #endif
13 }
14 
15 // access_add (could use scatter view instead): Uses atomic if array replication is off
16 template<typename T>
17 KOKKOS_INLINE_FUNCTION void access_add(T* addr, T val){
18 #ifdef USE_ARRAY_REPLICATION
19  *addr += val;
20 #else
21  Kokkos::atomic_add(addr, val);
22 #endif
23 }
24 
25 #endif
KOKKOS_INLINE_FUNCTION int get_thread()
Definition: access_add.hpp:7
KOKKOS_INLINE_FUNCTION void access_add(T *addr, T val)
Definition: access_add.hpp:17