Skip to content

Commit 7dd3d04

Browse files
committed
Add an assertion for changing num_threads along execution
1 parent 8783ca2 commit 7dd3d04

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/graphblas/reference/coordinates.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ namespace grb {
9797
/** Per-thread capacity for parallel stack updates. */
9898
size_t _buf;
9999

100+
/** Number of threads for which these coordinates have been initialised. */
101+
#ifdef _H_GRB_REFERENCE_OMP_COORDINATES
102+
const size_t _threads = config::OMP::threads();
103+
#else
104+
const size_t _threads = 1;
105+
#endif
106+
100107
/**
101108
* Increments the number of nonzeroes in the current thread-local stack.
102109
*
@@ -294,6 +301,10 @@ namespace grb {
294301
// blocks are not managed by this class)
295302
}
296303

304+
size_t requiredThreadsForUpdate() const noexcept {
305+
return _threads;
306+
}
307+
297308
/**
298309
* @returns An empty thread-local stack for new nonzeroes.
299310
*/

include/graphblas/reference/vector.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,9 @@ namespace grb {
12741274

12751275
template< typename D, typename C >
12761276
inline C & getCoordinates( Vector< D, reference, C > &x ) noexcept {
1277+
#ifdef _H_GRB_REFERENCE_OMP_VECTOR
1278+
assert( x._coordinates.requiredThreadsForUpdate() == config::OMP::threads() );
1279+
#endif
12771280
return x._coordinates;
12781281
}
12791282

0 commit comments

Comments
 (0)