21 #ifdef KRATOS_SMP_OPENMP
25 #if !defined(__cpp_lib_atomic_ref) && defined(KRATOS_SMP_CXX11)
26 #include <boost/atomic/atomic_ref.hpp>
35 #if defined(KRATOS_SMP_CXX11)
36 #if defined(__cpp_lib_atomic_ref)
38 using AtomicRef = std::atomic_ref<T>;
41 using AtomicRef = boost::atomic_ref<T>;
54 template<
class TDataType>
55 inline void AtomicAdd(TDataType& target,
const TDataType& value)
57 #ifdef KRATOS_SMP_OPENMP
60 #elif defined(KRATOS_SMP_CXX11)
61 AtomicRef<TDataType>{target} += value;
73 template <
class TDataType, std::
size_t ArraySize>
76 for (std::size_t
i=0;
i<ArraySize; ++
i) {
86 template<
class TVectorType1,
class TVectorType2>
89 KRATOS_DEBUG_ERROR_IF(target.size() != value.size()) <<
"vector size mismatch in vector AtomicAddVector- Sizes are: " << target.size() <<
" for target and " << value.size() <<
" for value " << std::endl;
91 for(std::size_t
i=0;
i<target.size(); ++
i) {
101 template<
class TMatrixType1,
class TMatrixType2>
104 KRATOS_DEBUG_ERROR_IF(target.size1() != value.size1() || target.size2() != value.size2()) <<
"matrix size mismatch in matrix AtomicAddMatrix- Sizes are: " << target.size1() <<
"x" << target.size2() <<
" for target and " << value.size1() <<
"x" << value.size2() <<
" for value " << std::endl;
106 for(std::size_t
i=0;
i<target.size1(); ++
i) {
107 for(std::size_t
j=0;
j<target.size2(); ++
j) {
117 template<
class TDataType>
118 inline void AtomicSub(TDataType& target,
const TDataType& value)
120 #ifdef KRATOS_SMP_OPENMP
123 #elif defined(KRATOS_SMP_CXX11)
124 AtomicRef<TDataType>{target} -= value;
136 template <
class TDataType, std::
size_t ArraySize>
139 for(std::size_t
i=0;
i<ArraySize; ++
i) {
149 template<
class TVectorType1,
class TVectorType2>
151 KRATOS_DEBUG_ERROR_IF(target.size() != value.size()) <<
"vector size mismatch in vector AtomicSubVector- Sizes are: " << target.size() <<
" for target and " << value.size() <<
" for value " << std::endl;
153 for(std::size_t
i=0;
i<target.size(); ++
i) {
163 template<
class TMatrixType1,
class TMatrixType2>
166 KRATOS_DEBUG_ERROR_IF(target.size1() != value.size1() || target.size2() != value.size2()) <<
"matrix size mismatch in matrix AtomicSubMatrix- Sizes are: " << target.size1() <<
"x" << target.size2() <<
" for target and " << value.size1() <<
"x" << value.size2() <<
" for value " << std::endl;
168 for(std::size_t
i=0;
i<target.size1(); ++
i) {
169 for(std::size_t
j=0;
j<target.size2(); ++
j) {
178 template<
class TDataType>
179 inline void AtomicMult(TDataType& target,
const TDataType& value)
181 #ifdef KRATOS_SMP_OPENMP
184 #elif defined(KRATOS_SMP_CXX11)
185 AtomicRef<TDataType> at_ref{target};
186 at_ref = at_ref*value;
197 template <
class TDataType, std::
size_t ArraySize>
200 for(std::size_t
i=0;
i<ArraySize; ++
i) {
209 template<
class TVectorType1,
class TVectorType2>
212 KRATOS_DEBUG_ERROR_IF(target.size() != value.size()) <<
"vector size mismatch in vector AtomicMultVector- Sizes are: " << target.size() <<
" for target and " << value.size() <<
" for value " << std::endl;
214 for(std::size_t
i=0;
i<target.size(); ++
i) {
224 template<
class TMatrixType1,
class TMatrixType2>
227 KRATOS_DEBUG_ERROR_IF(target.size1() != value.size1() || target.size2() != value.size2()) <<
"matrix size mismatch in matrix AtomicMultMatrix- Sizes are: " << target.size1() <<
"x" << target.size2() <<
" for target and " << value.size1() <<
"x" << value.size2() <<
" for value " << std::endl;
229 for(std::size_t
i=0;
i<target.size1(); ++
i) {
230 for(std::size_t
j=0;
j<target.size2(); ++
j) {
239 template<
class TDataType>
240 inline void AtomicDiv(TDataType& target,
const TDataType& value)
250 template <
class TDataType, std::
size_t ArraySize>
253 for(std::size_t
i=0;
i<ArraySize; ++
i) {
262 template<
class TVectorType1,
class TVectorType2>
265 KRATOS_DEBUG_ERROR_IF(target.size() != value.size()) <<
"vector size mismatch in vector AtomicDivVector- Sizes are: " << target.size() <<
" for target and " << value.size() <<
" for value " << std::endl;
267 for(std::size_t
i=0;
i<target.size(); ++
i) {
277 template<
class TMatrixType1,
class TMatrixType2>
280 KRATOS_DEBUG_ERROR_IF(target.size1() != value.size1() || target.size2() != value.size2()) <<
"matrix size mismatch in matrix AtomicDivMatrix- Sizes are: " << target.size1() <<
"x" << target.size2() <<
" for target and " << value.size1() <<
"x" << value.size2() <<
" for value " << std::endl;
282 for(std::size_t
i=0;
i<target.size1(); ++
i) {
283 for(std::size_t
j=0;
j<target.size2(); ++
j) {
Short class definition.
Definition: array_1d.h:61
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void AtomicAdd(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:55
void AtomicAddVector(TVectorType1 &target, const TVectorType2 &value)
Definition: atomic_utilities.h:87
void AtomicDivVector(TVectorType1 &target, const TVectorType2 &value)
Definition: atomic_utilities.h:263
void AtomicDiv(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:240
void AtomicSubVector(TVectorType1 &target, const TVectorType2 &value)
Definition: atomic_utilities.h:150
void AtomicSubMatrix(TMatrixType1 &target, const TMatrixType2 &value)
Definition: atomic_utilities.h:164
void AtomicMultVector(TVectorType1 &target, const TVectorType2 &value)
Definition: atomic_utilities.h:210
void AtomicMultMatrix(TMatrixType1 &target, const TMatrixType2 &value)
Definition: atomic_utilities.h:225
void AtomicDivMatrix(TMatrixType1 &target, const TMatrixType2 &value)
Definition: atomic_utilities.h:278
void AtomicAddMatrix(TMatrixType1 &target, const TMatrixType2 &value)
Definition: atomic_utilities.h:102
void AtomicSub(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:118
void AtomicMult(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:179
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17