Skip to content

Commit 43e85b6

Browse files
committed
Armadillo 11.4.1
1 parent ba637a6 commit 43e85b6

File tree

4 files changed

+149
-83
lines changed

4 files changed

+149
-83
lines changed

inst/include/armadillo_bits/Cube_bones.hpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ class Cube : public BaseCube< eT, Cube<eT> >
3939
typedef eT elem_type; //!< the type of elements stored in the cube
4040
typedef typename get_pod_type<eT>::result pod_type; //!< if eT is std::complex<T>, pod_type is T; otherwise pod_type is eT
4141

42-
const uword n_rows; //!< number of rows in each slice (read-only)
43-
const uword n_cols; //!< number of columns in each slice (read-only)
44-
const uword n_elem_slice; //!< number of elements in each slice (read-only)
45-
const uword n_slices; //!< number of slices in the cube (read-only)
46-
const uword n_elem; //!< number of elements in the cube (read-only)
47-
const uword n_alloc; //!< number of allocated elements (read-only); NOTE: n_alloc can be 0, even if n_elem > 0
48-
const uword mem_state;
42+
const uword n_rows; //!< number of rows in each slice (read-only)
43+
const uword n_cols; //!< number of columns in each slice (read-only)
44+
const uword n_elem_slice; //!< number of elements in each slice (read-only)
45+
const uword n_slices; //!< number of slices in the cube (read-only)
46+
const uword n_elem; //!< number of elements in the cube (read-only)
47+
const uword n_alloc; //!< number of allocated elements (read-only); NOTE: n_alloc can be 0, even if n_elem > 0
48+
const uword mem_state;
4949

5050
// mem_state = 0: normal cube which manages its own memory
5151
// mem_state = 1: use auxiliary memory until a size change
@@ -57,10 +57,27 @@ class Cube : public BaseCube< eT, Cube<eT> >
5757

5858
protected:
5959

60-
arma_aligned const Mat<eT>** const mat_ptrs;
60+
using mat_type = Mat<eT>;
61+
62+
#if defined(ARMA_USE_OPENMP)
63+
using raw_mat_ptr_type = mat_type*;
64+
using atomic_mat_ptr_type = mat_type*;
65+
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
66+
using raw_mat_ptr_type = mat_type*;
67+
using atomic_mat_ptr_type = std::atomic<mat_type*>;
68+
#else
69+
using raw_mat_ptr_type = mat_type*;
70+
using atomic_mat_ptr_type = mat_type*;
71+
#endif
72+
73+
atomic_mat_ptr_type* mat_ptrs = nullptr;
74+
75+
#if (!defined(ARMA_DONT_USE_STD_MUTEX))
76+
mutable std::mutex mat_mutex; // required for slice()
77+
#endif
6178

62-
arma_align_mem Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
63-
arma_align_mem eT mem_local[ Cube_prealloc::mem_n_elem ]; // local storage, for small cubes
79+
arma_aligned atomic_mat_ptr_type mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
80+
arma_align_mem eT mem_local[ Cube_prealloc::mem_n_elem ]; // local storage, for small cubes
6481

6582

6683
public:
@@ -124,7 +141,7 @@ class Cube : public BaseCube< eT, Cube<eT> >
124141

125142
inline Mat<eT>& slice(const uword in_slice);
126143
inline const Mat<eT>& slice(const uword in_slice) const;
127-
144+
128145
arma_inline subview_cube<eT> rows(const uword in_row1, const uword in_row2);
129146
arma_inline const subview_cube<eT> rows(const uword in_row1, const uword in_row2) const;
130147

@@ -445,6 +462,9 @@ class Cube : public BaseCube< eT, Cube<eT> >
445462
inline void delete_mat();
446463
inline void create_mat();
447464

465+
inline void create_mat_ptr(const uword in_slice) const;
466+
inline Mat<eT>* get_mat_ptr(const uword in_slice) const;
467+
448468
friend class glue_join;
449469
friend class op_reshape;
450470
friend class op_resize;
@@ -471,8 +491,8 @@ class Cube<eT>::fixed : public Cube<eT>
471491

472492
static constexpr bool use_extra = (fixed_n_elem > Cube_prealloc::mem_n_elem);
473493

474-
arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? fixed_n_slices : 1 ];
475-
arma_align_mem eT mem_local_extra [ use_extra ? fixed_n_elem : 1 ];
494+
arma_aligned atomic_mat_ptr_type mat_ptrs_local_extra[ (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? fixed_n_slices : 1 ];
495+
arma_align_mem eT mem_local_extra[ use_extra ? fixed_n_elem : 1 ];
476496

477497
arma_inline void mem_setup();
478498

0 commit comments

Comments
 (0)