From 1423bacfe1d35654af77c39ada7ad6afa02199bb Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:26:33 +0200 Subject: [PATCH 1/9] Added static casts to suppress warnings --- include/graphblas/utils/unordered_memmove.hpp | 12 ++++++------ src/transition/fuselets.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/graphblas/utils/unordered_memmove.hpp b/include/graphblas/utils/unordered_memmove.hpp index de4cd1546..e36dcfeef 100644 --- a/include/graphblas/utils/unordered_memmove.hpp +++ b/include/graphblas/utils/unordered_memmove.hpp @@ -303,11 +303,11 @@ namespace grb { size_t lStartBatch = std::lower_bound( src_offsets, src_offsets + endBatch + 1, lStart ) - src_offsets; - assert( src_offsets[ endBatch ] >= lStart ); + assert( static_cast< size_t >( src_offsets[ endBatch ] ) >= lStart ); if( src_offsets[ lStartBatch ] > static_cast< IND >(lStart) ) { assert( lStartBatch > 0 ); (void) --lStartBatch; - assert( src_offsets[ lStartBatch ] < lStart ); + assert( static_cast< size_t >( src_offsets[ lStartBatch ] ) < lStart ); } assert( lStartBatch >= startBatch ); assert( lStartBatch <= endBatch ); @@ -337,8 +337,8 @@ namespace grb { // process complete batches for( ; lCurBatch < lEndBatch - 1; ++lCurBatch ) { - assert( lStart <= src_offsets[ lCurBatch ] ); - assert( lEnd >= src_offsets[ lCurBatch + 1 ] ); + assert( lStart <= static_cast< size_t >( src_offsets[ lCurBatch ] ) ); + assert( lEnd >= static_cast< size_t >( src_offsets[ lCurBatch + 1 ] ) ); const size_t nElems = (src_offsets[ lCurBatch + 1 ] - src_offsets[ lCurBatch ]); (void) std::memcpy( @@ -350,8 +350,8 @@ namespace grb { } // process last batch, which may be incomplete - assert( lEnd > src_offsets[ lEndBatch - 1 ] ); - assert( lEnd <= src_offsets[ lEndBatch ] ); + assert( lEnd > static_cast< size_t >( src_offsets[ lEndBatch - 1 ] ) ); + assert( lEnd <= static_cast< size_t >( src_offsets[ lEndBatch ] ) ); (void) std::memcpy( source + dst_offsets[ lEndBatch - 1 ], buffer + bOffset, diff --git a/src/transition/fuselets.cpp b/src/transition/fuselets.cpp index a366fa6d0..ea289b09b 100644 --- a/src/transition/fuselets.cpp +++ b/src/transition/fuselets.cpp @@ -338,8 +338,8 @@ static int update_spmv_dot( // compiled in debug mode: for( size_t i = 0; i < n; ++i ) { assert( ia[ i + 1 ] >= ia[ i ] ); - for( size_t k = ia[ i ]; k < ia[ i + 1 ]; ++k ) { - assert( ij[ k ] < n ); + for( OffsetT k = ia[ i ]; k < ia[ i + 1 ]; ++k ) { + assert( ij[ k ] < static_cast( n ) ); } } #endif From 3bc4b948228ae8e386542044eaadcbbddd5f7cd4 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:20:22 +0200 Subject: [PATCH 2/9] Assert check as suggested in review --- src/transition/fuselets.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transition/fuselets.cpp b/src/transition/fuselets.cpp index ea289b09b..90ceb7548 100644 --- a/src/transition/fuselets.cpp +++ b/src/transition/fuselets.cpp @@ -336,6 +336,7 @@ static int update_spmv_dot( #ifndef NDEBUG // we employ defensive programming and perform expensive input checks when // compiled in debug mode: + assert(n <= std::numeric_limits< OffsetT >::max() ); for( size_t i = 0; i < n; ++i ) { assert( ia[ i + 1 ] >= ia[ i ] ); for( OffsetT k = ia[ i ]; k < ia[ i + 1 ]; ++k ) { From 4f5422075e180768febfb8ff59da49d7d7663a95 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:20:53 +0200 Subject: [PATCH 3/9] Fused loops to avoid warning --- include/graphblas/reference/blas1.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/graphblas/reference/blas1.hpp b/include/graphblas/reference/blas1.hpp index 35ebc02f9..6e1fd8732 100644 --- a/include/graphblas/reference/blas1.hpp +++ b/include/graphblas/reference/blas1.hpp @@ -3734,15 +3734,11 @@ namespace grb { } } } - for( size_t k = 0; k < block_size; ++k ) { - if( mask_b[ k ] ) { - apply( z_b[ k ], x_b[ k ], y_b[ k ], op ); - } - } for( size_t k = 0; k < block_size; ++k ) { const size_t index = i + k; assert( index < n ); if( mask_b[ k ] ) { + apply( z_b[ k ], x_b[ k ], y_b[ k ], op ); #ifdef _H_GRB_REFERENCE_OMP_BLAS1 if( !z_coors.asyncAssign( index, update ) ) { (void) ++asyncAssigns; From df01e76ad49a3e6615be1cc1867026eecdf1522a Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:08:06 +0200 Subject: [PATCH 4/9] Revert "Fused loops to avoid warning" This reverts commit 319640648965a68359b21a1afaca1bd68864751f. --- include/graphblas/reference/blas1.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/graphblas/reference/blas1.hpp b/include/graphblas/reference/blas1.hpp index 6e1fd8732..35ebc02f9 100644 --- a/include/graphblas/reference/blas1.hpp +++ b/include/graphblas/reference/blas1.hpp @@ -3734,11 +3734,15 @@ namespace grb { } } } + for( size_t k = 0; k < block_size; ++k ) { + if( mask_b[ k ] ) { + apply( z_b[ k ], x_b[ k ], y_b[ k ], op ); + } + } for( size_t k = 0; k < block_size; ++k ) { const size_t index = i + k; assert( index < n ); if( mask_b[ k ] ) { - apply( z_b[ k ], x_b[ k ], y_b[ k ], op ); #ifdef _H_GRB_REFERENCE_OMP_BLAS1 if( !z_coors.asyncAssign( index, update ) ) { (void) ++asyncAssigns; From 82570d02cc1c1ef3eace7ba98873f626a3adbe3f Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Thu, 16 Oct 2025 08:56:00 +0200 Subject: [PATCH 5/9] Added warning suppressions --- include/graphblas/reference/blas1.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/graphblas/reference/blas1.hpp b/include/graphblas/reference/blas1.hpp index 35ebc02f9..c71babc00 100644 --- a/include/graphblas/reference/blas1.hpp +++ b/include/graphblas/reference/blas1.hpp @@ -3750,7 +3750,12 @@ namespace grb { #else (void) z_coors.assign( index ); #endif + GRB_UTIL_IGNORE_MAYBE_UNINITIALIZED + // z_b[ k ] has been initialized in te loop just before + // Some compilers do not see it, others do. + // See issue #345 and related PR *( z_p + index ) = z_b[ k ]; + GRB_UTIL_RESTORE_WARNINGS } } #ifdef _H_GRB_REFERENCE_OMP_BLAS1 From 0338d94d85bce0936095380a85516c92a150f2a1 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:03:50 +0200 Subject: [PATCH 6/9] Documented suppression --- docs/Suppressions.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/Suppressions.md b/docs/Suppressions.md index 630b044ab..e2c27f412 100644 --- a/docs/Suppressions.md +++ b/docs/Suppressions.md @@ -82,3 +82,32 @@ for( size_t k = 0; k < block_size; ++k ) { } ``` +7. `include/graphblas/reference/blas1.hpp`, masked_apply_generic +``` +for( size_t k = 0; k < block_size; ++k ) { + if( mask_b[ k ] ) { + apply( z_b[ k ], x_b[ k ], y_b[ k ], op ); + } +} +for( size_t k = 0; k < block_size; ++k ) { + const size_t index = i + k; + assert( index < n ); + if( mask_b[ k ] ) { +#ifdef _H_GRB_REFERENCE_OMP_BLAS1 + if( !z_coors.asyncAssign( index, update ) ) { + (void) ++asyncAssigns; + } +#else + (void) z_coors.assign( index ); +#endif + GRB_UTIL_IGNORE_MAYBE_UNINITIALIZED + // z_b[ k ] has been initialized in te loop just before + // Some compilers do not see it, others do. + // See issue #345 and related PR + *( z_p + index ) = z_b[ k ]; + GRB_UTIL_RESTORE_WARNINGS + } +} +#ifdef _H_GRB_REFERENCE_OMP_BLAS1 + +``` From 45967bb83b1492498427a41c6bb41f0f99919a2e Mon Sep 17 00:00:00 2001 From: "Albert-Jan N. Yzelman" Date: Fri, 17 Oct 2025 10:52:05 +0200 Subject: [PATCH 7/9] Code review: fix typo and better to keep the rationales for suppressions short (removed two lines). (Also for referring to the source of a change, git praise/blame will work:) --- docs/Suppressions.md | 4 +--- include/graphblas/reference/blas1.hpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/Suppressions.md b/docs/Suppressions.md index e2c27f412..4583fcde4 100644 --- a/docs/Suppressions.md +++ b/docs/Suppressions.md @@ -101,9 +101,7 @@ for( size_t k = 0; k < block_size; ++k ) { (void) z_coors.assign( index ); #endif GRB_UTIL_IGNORE_MAYBE_UNINITIALIZED - // z_b[ k ] has been initialized in te loop just before - // Some compilers do not see it, others do. - // See issue #345 and related PR + // z_b[ k ] has been initialized in the loop just before *( z_p + index ) = z_b[ k ]; GRB_UTIL_RESTORE_WARNINGS } diff --git a/include/graphblas/reference/blas1.hpp b/include/graphblas/reference/blas1.hpp index c71babc00..05c1de938 100644 --- a/include/graphblas/reference/blas1.hpp +++ b/include/graphblas/reference/blas1.hpp @@ -3751,9 +3751,7 @@ namespace grb { (void) z_coors.assign( index ); #endif GRB_UTIL_IGNORE_MAYBE_UNINITIALIZED - // z_b[ k ] has been initialized in te loop just before - // Some compilers do not see it, others do. - // See issue #345 and related PR + // z_b[ k ] has been initialized in the loop just before *( z_p + index ) = z_b[ k ]; GRB_UTIL_RESTORE_WARNINGS } From cc9964c27b0398d9acbb13adff4a819403cc2212 Mon Sep 17 00:00:00 2001 From: "Albert-Jan N. Yzelman" Date: Fri, 17 Oct 2025 12:11:10 +0200 Subject: [PATCH 8/9] (Hotfix) (Metabug) Somehow the previous commit made a bug appear in the performance tests, herewith fixed. Also improves error reporting in that test. --- tests/performance/scaling.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/performance/scaling.cpp b/tests/performance/scaling.cpp index 1606e7d8d..8d8e85c6e 100644 --- a/tests/performance/scaling.cpp +++ b/tests/performance/scaling.cpp @@ -124,11 +124,14 @@ void grbProgram( const struct input &data_in, struct output &out ) { out.times.io = 0; timer.reset(); out.error_code = grb::set( vx, 1 ); + out.error_code = out.error_code ? out.error_code : + grb::set( vy, 0 ); out.error_code = out.error_code ? out.error_code : setupSparseMatrix( mx, n ); out.error_code = out.error_code ? out.error_code : grb::wait(); if( out.error_code != grb::SUCCESS ) { - std::cerr << "Error in experiment set-up\n"; + std::cerr << "Error in experiment set-up: " + << grb::toString( out.error_code ) << "\n"; init_error = true; } out.times.preamble = timer.time(); @@ -142,7 +145,8 @@ void grbProgram( const struct input &data_in, struct output &out ) { } out.times.useful = timer.time() / static_cast< double >( data_in.rep ); if( out.error_code != grb::SUCCESS && !init_error ) { - std::cerr << "Error during experiment hot loop\n"; + std::cerr << "Error during experiment hot loop: " + << grb::toString( out.error_code ) << "\n"; } // done out.times.postamble = 0; @@ -156,11 +160,14 @@ void grbProgram( const struct input &data_in, struct output &out ) { out.times.io = 0; timer.reset(); out.error_code = grb::set( vx, 1 ); + out.error_code = out.error_code ? out.error_code : + grb::set( vy, 0 ); out.error_code = out.error_code ? out.error_code : setupSparseMatrix( mx, n ); out.error_code = out.error_code ? out.error_code : grb::wait(); if( out.error_code != grb::SUCCESS ) { - std::cerr << "Error in experiment set-up\n"; + std::cerr << "Error in experiment set-up: " + << grb::toString( out.error_code ) << "\n"; init_error = true; } out.times.preamble = timer.time(); @@ -175,7 +182,8 @@ void grbProgram( const struct input &data_in, struct output &out ) { } out.times.useful = timer.time() / static_cast< double >( data_in.rep ); if( out.error_code != grb::SUCCESS && !init_error ) { - std::cerr << "Error during experiment hot loop\n"; + std::cerr << "Error during experiment hot loop: " + << grb::toString( out.error_code ) << "\n"; } // done out.times.postamble = 0; @@ -189,11 +197,14 @@ void grbProgram( const struct input &data_in, struct output &out ) { out.times.io = 0; timer.reset(); out.error_code = grb::set( vx, 1 ); + out.error_code = out.error_code ? out.error_code : + grb::set( vy, 0 ); out.error_code = out.error_code ? out.error_code : setupSparseMatrix( mx, n ); out.error_code = out.error_code ? out.error_code : grb::wait(); if( out.error_code != grb::SUCCESS ) { - std::cerr << "Error in experiment set-up\n"; + std::cerr << "Error in experiment set-up: " + << grb::toString( out.error_code ) << "\n"; init_error = true; } out.times.preamble = timer.time(); @@ -207,7 +218,8 @@ void grbProgram( const struct input &data_in, struct output &out ) { } out.times.useful = timer.time() / static_cast< double >( data_in.rep ); if( out.error_code != grb::SUCCESS && !init_error ) { - std::cerr << "Error during experiment hot loop\n"; + std::cerr << "Error during experiment hot loop: " + << grb::toString( out.error_code ) << "\n"; } // done out.times.postamble = 0; @@ -221,11 +233,14 @@ void grbProgram( const struct input &data_in, struct output &out ) { out.times.io = 0; timer.reset(); out.error_code = grb::set( vx, 1 ); + out.error_code = out.error_code ? out.error_code : + grb::set( vy, 0 ); out.error_code = out.error_code ? out.error_code : setupSparseMatrix( mx, n ); out.error_code = out.error_code ? out.error_code : grb::wait(); if( out.error_code != grb::SUCCESS ) { - std::cerr << "Error in experiment set-up\n"; + std::cerr << "Error in experiment set-up: " + << grb::toString( out.error_code ) << "\n"; init_error = true; } out.times.preamble = timer.time(); @@ -240,7 +255,8 @@ void grbProgram( const struct input &data_in, struct output &out ) { } out.times.useful = timer.time() / static_cast< double >( data_in.rep ); if( out.error_code != grb::SUCCESS && !init_error ) { - std::cerr << "Error during experiment hot loop\n"; + std::cerr << "Error during experiment hot loop: " + << grb::toString( out.error_code ) << "\n"; } // done out.times.postamble = 0; From 4e4aa8c363aea3cb7c52b00bb8ff5e97d46374bc Mon Sep 17 00:00:00 2001 From: "Albert-Jan N. Yzelman" Date: Fri, 17 Oct 2025 12:11:25 +0200 Subject: [PATCH 9/9] Unrelated code style fixes --- include/graphblas/nonblocking/pipeline.hpp | 2 ++ src/graphblas/nonblocking/pipeline.cpp | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/graphblas/nonblocking/pipeline.hpp b/include/graphblas/nonblocking/pipeline.hpp index 2ea724bd6..e01939e11 100644 --- a/include/graphblas/nonblocking/pipeline.hpp +++ b/include/graphblas/nonblocking/pipeline.hpp @@ -319,6 +319,7 @@ namespace grb { const Coordinates< nonblocking > * const vector_ptr ); #endif + void markMaybeSparseDenseDescriptorVerification( Coordinates< nonblocking > * const vector_ptr ); @@ -330,6 +331,7 @@ namespace grb { void merge( Pipeline &pipeline ); void clear(); + #ifdef GRB_ALREADY_DENSE_OPTIMIZATION void buildAlreadyDenseVectors(); #endif diff --git a/src/graphblas/nonblocking/pipeline.cpp b/src/graphblas/nonblocking/pipeline.cpp index 739a88fd4..07fa87166 100644 --- a/src/graphblas/nonblocking/pipeline.cpp +++ b/src/graphblas/nonblocking/pipeline.cpp @@ -746,6 +746,10 @@ grb::RC Pipeline::verifyDenseDescriptor() { it != dense_descr_coordinates.end(); ++it ) { if( !( *it )->isDense() ) { +#ifdef _NONBLOCKING_DEBUG + std::cout << "\t error in pipeline execution: the dense descriptor was " + << "illegally used" << std::endl; +#endif return ILLEGAL; } } @@ -1031,13 +1035,6 @@ grb::RC Pipeline::execution() { // verify that the dense descriptor was legally used ret = ret ? ret : verifyDenseDescriptor(); -#ifdef _NONBLOCKING_DEBUG - if( ret == ILLEGAL ) { - std::cerr << "error in pipeline execution: the dense descriptor was " - << "illegally used" << std::endl; - } -#endif - clear(); return ret;