From 6925d7fdfe8ccf65d556f2aa4ea5f6dee956d344 Mon Sep 17 00:00:00 2001 From: Aleksa Milisavljevic Date: Mon, 26 Feb 2024 16:42:04 +0100 Subject: [PATCH 1/9] bugfix --- include/graphblas/utils.hpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/include/graphblas/utils.hpp b/include/graphblas/utils.hpp index c5239afdc..4eea3eff4 100644 --- a/include/graphblas/utils.hpp +++ b/include/graphblas/utils.hpp @@ -323,7 +323,10 @@ namespace grb { ret = assigned; } else { // if based on value, if there is a value, cast it to bool - if( assigned ) { + if( !assigned ) { + return false; + } + else { ret = static_cast< bool >( val[ offset ] ); } // otherwise there is no value and false is assumed @@ -350,7 +353,10 @@ namespace grb { ret = assigned; } else { // if based on value, if there is a value, cast it to bool - if( assigned ) { + if( !assigned ) { + return false; + } + else { ret = static_cast< bool >( real( val [ offset ] ) ) || static_cast< bool >( imag( val [ offset ] ) ); } @@ -371,14 +377,7 @@ namespace grb { const void * const, const size_t ) { - // set default mask to false - bool ret = assigned; - // check whether we should return the inverted value - if( descriptor & descriptors::invert_mask ) { - return !ret; - } else { - return ret; - } + return assigned; } } // namespace utils From 3db7cccf750193369a948d232aa9a89135cdc1df Mon Sep 17 00:00:00 2001 From: Aleksa Milisavljevic Date: Mon, 26 Feb 2024 16:52:22 +0100 Subject: [PATCH 2/9] void valued masks special case --- include/graphblas/utils.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/graphblas/utils.hpp b/include/graphblas/utils.hpp index 4eea3eff4..b1060208e 100644 --- a/include/graphblas/utils.hpp +++ b/include/graphblas/utils.hpp @@ -377,7 +377,12 @@ namespace grb { const void * const, const size_t ) { - return assigned; + bool ret = assigned; + if( ( descriptor & descriptors::structural_complement ) == descriptors::structural_complement ) { + return !ret; + } else { + return ret; + } } } // namespace utils From 81b4ff150f84f8d637ce39ea9d52fc41be181312 Mon Sep 17 00:00:00 2001 From: Aleksa Milisavljevic Date: Mon, 26 Feb 2024 18:18:39 +0100 Subject: [PATCH 3/9] modifying the unit tests according to the documentation of invert_mask descriptor --- tests/unit/eWiseMul.cpp | 2 +- tests/unit/launcher/reduce.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/eWiseMul.cpp b/tests/unit/eWiseMul.cpp index c9900c508..19e6235a5 100644 --- a/tests/unit/eWiseMul.cpp +++ b/tests/unit/eWiseMul.cpp @@ -50,7 +50,7 @@ void grb_program( const size_t &n, RC &rc ) { }, temp ); rc = rc ? rc : set( even_mask, temp, true ); rc = rc ? rc : set< descriptors::invert_mask >( - odd_mask, even_mask, true ); + odd_mask, temp, true ); rc = rc ? rc : wait(); if( rc != SUCCESS ) { std::cerr << "\t initialisation of masks FAILED\n"; diff --git a/tests/unit/launcher/reduce.cpp b/tests/unit/launcher/reduce.cpp index cf0ae43da..43c3bc055 100644 --- a/tests/unit/launcher/reduce.cpp +++ b/tests/unit/launcher/reduce.cpp @@ -468,8 +468,12 @@ void grbProgram( const size_t &P, int &exit_status ) { grb::Vector< bool > even_mask( n ); check = 0.0; for( size_t i = 0; i < n; i += 2 ) { - check += xr[ i ]; - const grb::RC setrc = grb::setElement( even_mask, true, i ); + bool set_to = false; + if( i%4 == 0 ) { + check += xr[ i ]; + set_to = true; + } + const grb::RC setrc = grb::setElement( even_mask, set_to, i ); #ifndef NDEBUG assert( setrc == grb::SUCCESS ); #else @@ -484,7 +488,7 @@ void grbProgram( const size_t &P, int &exit_status ) { } check = 0.0; - for( size_t i = 1; i < n; i += 2 ) { + for( size_t i = 2; i < n; i += 4 ) { check += xr[ i ]; } @@ -555,7 +559,7 @@ void grbProgram( const size_t &P, int &exit_status ) { } exit_status = expect_sparse_success< grb::descriptors::invert_mask >( - sparse, realm, grb::nnz(sparse), empty_mask ); + sparse, realm, 0.0, empty_mask, grb::nnz(sparse) ); if( exit_status != 0 ) { exit_status += 500; return; @@ -606,7 +610,7 @@ void grbProgram( const size_t &P, int &exit_status ) { } exit_status = expect_sparse_success< grb::descriptors::invert_mask >( - sparse, realm, grb::nnz(sparse), odd_mask ); + sparse, realm, 0.0, odd_mask, grb::nnz(sparse) ); if( exit_status != 0 ) { exit_status += 1100; return; From 578b5f3c5c73e75d245198b68169115a836325b7 Mon Sep 17 00:00:00 2001 From: Aleksa Milisavljevic Date: Tue, 27 Feb 2024 13:46:54 +0100 Subject: [PATCH 4/9] modifying the unit tests according to the documentation of invert_mask descriptor --- tests/unit/pinnedVector.cpp | 3 ++- tests/unit/set.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/pinnedVector.cpp b/tests/unit/pinnedVector.cpp index ce32122cd..6385761dd 100644 --- a/tests/unit/pinnedVector.cpp +++ b/tests/unit/pinnedVector.cpp @@ -214,7 +214,8 @@ void grbProgram( const struct input< T > &in, struct output< T > &out ) { case LEAST_SPARSE_CLEARED: { Vector< bool > mask( n ); - rc = grb::setElement( mask, true, n/2 ); + rc = grb::set( mask, false ); + rc = rc ? rc : grb::setElement( mask, true, n/2 ); rc = rc ? rc : grb::set< grb::descriptors::invert_mask >( nonempty, mask, in.element ); diff --git a/tests/unit/set.cpp b/tests/unit/set.cpp index 44d06b5a5..cb393c324 100644 --- a/tests/unit/set.cpp +++ b/tests/unit/set.cpp @@ -730,7 +730,8 @@ void grb_program( const size_t &n, grb::RC &rc ) { // test sparse inverted mask set grb::Vector< bool > mask( n ); - rc = grb::setElement( mask, true, n / 2 ); + rc = grb::set( mask, false ); + rc = rc ? rc : grb::setElement( mask, true, n / 2 ); if( rc == SUCCESS ) { rc = grb::set( src, 1.5 ); rc = rc ? rc : grb::wait( src ); From 728a828346817d856cf99f3885a93b002131dd96 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:18:28 +0100 Subject: [PATCH 5/9] Reverted structural_complement check to just invert_mask for void case --- include/graphblas/utils.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graphblas/utils.hpp b/include/graphblas/utils.hpp index b1060208e..29a894df4 100644 --- a/include/graphblas/utils.hpp +++ b/include/graphblas/utils.hpp @@ -378,7 +378,7 @@ namespace grb { const size_t ) { bool ret = assigned; - if( ( descriptor & descriptors::structural_complement ) == descriptors::structural_complement ) { + if( ( descriptor & descriptors::invert_mask ) == descriptors::invert_mask ) { return !ret; } else { return ret; From d37c6d1af275eef5a2aed19cf1482ff666b55586 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 26 Nov 2025 08:44:33 +0100 Subject: [PATCH 6/9] Added missing include for github pipeline --- include/graphblas/base/io.hpp | 1 + include/graphblas/reference/init.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/graphblas/base/io.hpp b/include/graphblas/base/io.hpp index 2b1a8d88a..5bd962533 100644 --- a/include/graphblas/base/io.hpp +++ b/include/graphblas/base/io.hpp @@ -26,6 +26,7 @@ #include #include +#include #ifndef _H_GRB_IO_BASE #define _H_GRB_IO_BASE diff --git a/include/graphblas/reference/init.hpp b/include/graphblas/reference/init.hpp index 9332c8b88..671ff1d99 100644 --- a/include/graphblas/reference/init.hpp +++ b/include/graphblas/reference/init.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include From 6b01bb46ced01be71f7ea67b5bd65ecaa5da45a7 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 26 Nov 2025 08:47:33 +0100 Subject: [PATCH 7/9] fixup! Added missing include for github pipeline --- include/graphblas/nonblocking/coordinates.hpp | 1 + include/graphblas/reference/coordinates.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/graphblas/nonblocking/coordinates.hpp b/include/graphblas/nonblocking/coordinates.hpp index 1aca8e322..dfd69b785 100644 --- a/include/graphblas/nonblocking/coordinates.hpp +++ b/include/graphblas/nonblocking/coordinates.hpp @@ -35,6 +35,7 @@ #include //size_t #include +#include // uintptr_t #include #include diff --git a/include/graphblas/reference/coordinates.hpp b/include/graphblas/reference/coordinates.hpp index 59ea0326f..efc4a4672 100644 --- a/include/graphblas/reference/coordinates.hpp +++ b/include/graphblas/reference/coordinates.hpp @@ -29,6 +29,7 @@ #include #include //memcpy +#include // uintptr_t #include #include From 327169c397b0b08f1e6a65b2efd318d3d5409d24 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 26 Nov 2025 08:56:45 +0100 Subject: [PATCH 8/9] fixup! Added missing include for github pipeline - this time for real --- include/graphblas/banshee/coordinates.hpp | 1 + include/graphblas/bsp1d/init.hpp | 2 ++ include/graphblas/bsp1d/io.hpp | 1 + include/graphblas/bsp1d/matrix.hpp | 2 ++ include/graphblas/bsp1d/vector.hpp | 1 + include/graphblas/hyperdags/blas1.hpp | 1 + include/graphblas/hyperdags/blas2.hpp | 1 + include/graphblas/hyperdags/blas3.hpp | 1 + include/graphblas/hyperdags/hyperdags.hpp | 1 + include/graphblas/hyperdags/io.hpp | 1 + include/graphblas/nonblocking/io.hpp | 2 ++ include/graphblas/nonblocking/matrix.hpp | 1 + include/graphblas/reference/io.hpp | 1 + include/graphblas/reference/matrix.hpp | 1 + include/graphblas/reference/vector.hpp | 1 + 15 files changed, 18 insertions(+) diff --git a/include/graphblas/banshee/coordinates.hpp b/include/graphblas/banshee/coordinates.hpp index 8118bb747..30c3533ab 100644 --- a/include/graphblas/banshee/coordinates.hpp +++ b/include/graphblas/banshee/coordinates.hpp @@ -24,6 +24,7 @@ #define _H_GRB_BANSHEE_COORDINATES #include //size_t +#include //size_t #include diff --git a/include/graphblas/bsp1d/init.hpp b/include/graphblas/bsp1d/init.hpp index ec33adb33..be2fbaf63 100644 --- a/include/graphblas/bsp1d/init.hpp +++ b/include/graphblas/bsp1d/init.hpp @@ -24,6 +24,8 @@ #define _H_GRB_BSP1D_INIT #include //queue of HP put and get requests +#include // uintptr_t + #include "config.hpp" diff --git a/include/graphblas/bsp1d/io.hpp b/include/graphblas/bsp1d/io.hpp index 3a5949f91..bf83d3d82 100644 --- a/include/graphblas/bsp1d/io.hpp +++ b/include/graphblas/bsp1d/io.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/include/graphblas/bsp1d/matrix.hpp b/include/graphblas/bsp1d/matrix.hpp index 26c5a9d75..57f843f80 100644 --- a/include/graphblas/bsp1d/matrix.hpp +++ b/include/graphblas/bsp1d/matrix.hpp @@ -23,6 +23,8 @@ #ifndef _H_GRB_BSP1D_MATRIX #define _H_GRB_BSP1D_MATRIX +#include + #include #include #include diff --git a/include/graphblas/bsp1d/vector.hpp b/include/graphblas/bsp1d/vector.hpp index ba6109a85..ac5fb9664 100644 --- a/include/graphblas/bsp1d/vector.hpp +++ b/include/graphblas/bsp1d/vector.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include diff --git a/include/graphblas/hyperdags/blas1.hpp b/include/graphblas/hyperdags/blas1.hpp index 623174345..4cb44390a 100644 --- a/include/graphblas/hyperdags/blas1.hpp +++ b/include/graphblas/hyperdags/blas1.hpp @@ -32,6 +32,7 @@ #include #include +#include namespace grb { diff --git a/include/graphblas/hyperdags/blas2.hpp b/include/graphblas/hyperdags/blas2.hpp index 421b0b646..bc84ab673 100644 --- a/include/graphblas/hyperdags/blas2.hpp +++ b/include/graphblas/hyperdags/blas2.hpp @@ -32,6 +32,7 @@ #include #include +#include namespace grb { diff --git a/include/graphblas/hyperdags/blas3.hpp b/include/graphblas/hyperdags/blas3.hpp index ee0c10f36..e8fbdc883 100644 --- a/include/graphblas/hyperdags/blas3.hpp +++ b/include/graphblas/hyperdags/blas3.hpp @@ -33,6 +33,7 @@ #include #include +#include namespace grb { diff --git a/include/graphblas/hyperdags/hyperdags.hpp b/include/graphblas/hyperdags/hyperdags.hpp index 4ef0e0059..f637e2563 100644 --- a/include/graphblas/hyperdags/hyperdags.hpp +++ b/include/graphblas/hyperdags/hyperdags.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include diff --git a/include/graphblas/hyperdags/io.hpp b/include/graphblas/hyperdags/io.hpp index 901d20c48..e96714515 100644 --- a/include/graphblas/hyperdags/io.hpp +++ b/include/graphblas/hyperdags/io.hpp @@ -27,6 +27,7 @@ #include #include +#include namespace grb { diff --git a/include/graphblas/nonblocking/io.hpp b/include/graphblas/nonblocking/io.hpp index 64e53172d..20a7583ba 100644 --- a/include/graphblas/nonblocking/io.hpp +++ b/include/graphblas/nonblocking/io.hpp @@ -27,6 +27,8 @@ #ifndef _H_GRB_NONBLOCKING_IO #define _H_GRB_NONBLOCKING_IO +#include + #include #include #include "vector.hpp" diff --git a/include/graphblas/nonblocking/matrix.hpp b/include/graphblas/nonblocking/matrix.hpp index 6fdd70343..dac1418ce 100644 --- a/include/graphblas/nonblocking/matrix.hpp +++ b/include/graphblas/nonblocking/matrix.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include diff --git a/include/graphblas/reference/io.hpp b/include/graphblas/reference/io.hpp index 891b13488..30a6db707 100644 --- a/include/graphblas/reference/io.hpp +++ b/include/graphblas/reference/io.hpp @@ -24,6 +24,7 @@ #define _H_GRB_REFERENCE_IO #include +#include #include "vector.hpp" #include "matrix.hpp" diff --git a/include/graphblas/reference/matrix.hpp b/include/graphblas/reference/matrix.hpp index 179017c5c..4d5fdb993 100644 --- a/include/graphblas/reference/matrix.hpp +++ b/include/graphblas/reference/matrix.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include diff --git a/include/graphblas/reference/vector.hpp b/include/graphblas/reference/vector.hpp index fcd2516d8..fe0a70b31 100644 --- a/include/graphblas/reference/vector.hpp +++ b/include/graphblas/reference/vector.hpp @@ -24,6 +24,7 @@ #define _H_GRB_REFERENCE_VECTOR #include +#include #include #include #include From 63952ba5c6a73cbbee425114f06be430abd502a7 Mon Sep 17 00:00:00 2001 From: Giovanni Gaio <48856010+GiovaGa@users.noreply.github.com> Date: Wed, 26 Nov 2025 10:00:27 +0100 Subject: [PATCH 9/9] Update setToIndex unit test to match expected behavior of inverted masking --- tests/unit/setToIndex.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/setToIndex.cpp b/tests/unit/setToIndex.cpp index 2a5590af2..e771e3059 100644 --- a/tests/unit/setToIndex.cpp +++ b/tests/unit/setToIndex.cpp @@ -1205,7 +1205,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, 3.14 ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_all_but_one( dst, half_size ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 20:"; @@ -1256,7 +1256,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, src ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_one( dst, 0, 0 ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 22:"; @@ -1277,7 +1277,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, src ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_all_but_one( dst, half_size ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 24:"; @@ -1298,7 +1298,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, 7.17 ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_all_but_one( dst, half_size ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 26:"; @@ -1365,7 +1365,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, src ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_one( dst, 0, 0 ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 28:"; @@ -1408,7 +1408,7 @@ void grb_program( const size_t &n, grb::RC &rc ) { rc = grb::set< invert >( dst, one_mask, src ); rc = rc ? rc : grb::wait( dst ); if( !expect_success( rc ) ) { return; } - rc = expect_all_but_one( dst, half_size ); + rc = expect_none( dst ); if( rc != grb::SUCCESS ) { return; } std::cerr << "\b 30:";