From d77fa2bbb4c76bacf5ae9aca49fcdbd0c6b8a7bb Mon Sep 17 00:00:00 2001 From: conrad Date: Wed, 13 Aug 2025 17:38:17 +1000 Subject: [PATCH] use seq_cst for openmp atomic read/write --- include/armadillo_bits/Cube_meat.hpp | 6 +++--- include/armadillo_bits/arma_forward.hpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/armadillo_bits/Cube_meat.hpp b/include/armadillo_bits/Cube_meat.hpp index e9de1e22..d4d97feb 100644 --- a/include/armadillo_bits/Cube_meat.hpp +++ b/include/armadillo_bits/Cube_meat.hpp @@ -615,7 +615,7 @@ Cube::get_mat_ptr(const uword in_slice) const #if defined(ARMA_USE_OPENMP) { - #pragma omp atomic read + #pragma omp atomic read seq_cst mat_ptr = mat_ptrs[in_slice]; } #elif defined(ARMA_USE_STD_MUTEX) @@ -634,12 +634,12 @@ Cube::get_mat_ptr(const uword in_slice) const { #pragma omp critical (arma_Cube_mat_ptrs) { - #pragma omp atomic read + #pragma omp atomic read seq_cst mat_ptr = mat_ptrs[in_slice]; if(mat_ptr == nullptr) { mat_ptr = create_mat_ptr(in_slice); } - #pragma omp atomic write + #pragma omp atomic write seq_cst mat_ptrs[in_slice] = mat_ptr; } } diff --git a/include/armadillo_bits/arma_forward.hpp b/include/armadillo_bits/arma_forward.hpp index 20ee5032..8c9fed7b 100644 --- a/include/armadillo_bits/arma_forward.hpp +++ b/include/armadillo_bits/arma_forward.hpp @@ -312,7 +312,7 @@ struct state_type int out; #if defined(ARMA_USE_OPENMP) - #pragma omp atomic read + #pragma omp atomic read seq_cst out = state; #elif defined(ARMA_USE_STD_MUTEX) out = state.load(); @@ -328,7 +328,7 @@ struct state_type operator= (const int in_state) { #if defined(ARMA_USE_OPENMP) - #pragma omp atomic write + #pragma omp atomic write seq_cst state = in_state; #elif defined(ARMA_USE_STD_MUTEX) state.store(in_state);