Skip to content

Commit 1561878

Browse files
committed
Unit tests caught that sometimes uninitialised coordinate instances are retrieved (and the instance is then inspected to check whether it is valid or not-- which is valid use). The new thread assertion check mechanism now copes with that
1 parent 526413d commit 1561878

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/graphblas/reference/coordinates.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ namespace grb {
515515
* however.
516516
*/
517517
bool checkNumThreadsSeq() const noexcept {
518+
// guard against (valid) use of non-initialised coordinates
519+
if( _threads == 0 ) {
520+
return true;
521+
}
522+
// then, get actual number of threads now active and compare
518523
const size_t actualThreads = config::OMP::threads();
519524
if( actualThreads != _threads ) {
520525
std::cerr << "\t Error: coordinates instance was set for " << _threads
@@ -547,6 +552,11 @@ namespace grb {
547552
* however.
548553
*/
549554
bool checkNumThreadsPar() const noexcept {
555+
// guard against (valid) use of non-initialised coordinates
556+
if( _threads == 0 ) {
557+
return true;
558+
}
559+
// then, get actual number of threads now active and compare
550560
const size_t actualThreads =
551561
static_cast< size_t >( omp_get_num_threads() );
552562
if( actualThreads != _threads ) {

0 commit comments

Comments
 (0)