From 536e02b6d88eef3630c6f4759fd5fb81dc20126e Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 11:34:59 +0200 Subject: [PATCH 01/10] Fix bug in _DEBUG printout --- include/graphblas/reference/matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graphblas/reference/matrix.hpp b/include/graphblas/reference/matrix.hpp index 3ca7a2709..1cda7e897 100644 --- a/include/graphblas/reference/matrix.hpp +++ b/include/graphblas/reference/matrix.hpp @@ -1749,7 +1749,7 @@ namespace grb { #ifdef _DEBUG std::cout << "Nonzero " << k << ", ( " << it.i() << ", " << it.j() << " ) " << "is stored at CRS position " - << static_cast< size_t >( crs_pos ) << ".\n" + << static_cast< size_t >( crs_pos ) << ".\n"; #endif const size_t ccs_pos = --( CCS.col_start[ it.j() ] ); CCS.recordValue( ccs_pos, true, it ); From 730ae6eea53cd16dfd86897b996bb180ad19393b Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 11:56:07 +0200 Subject: [PATCH 02/10] Fix bug in _DEBUG printout --- .../graphblas/reference/nonzero_wrapper.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/graphblas/reference/nonzero_wrapper.hpp b/include/graphblas/reference/nonzero_wrapper.hpp index 77235faae..ef423f700 100644 --- a/include/graphblas/reference/nonzero_wrapper.hpp +++ b/include/graphblas/reference/nonzero_wrapper.hpp @@ -252,6 +252,15 @@ namespace grb { return result; } +#ifdef _DEBUG + /** Overload print function. */ + static void print( std::ostream &s, const SelfType &nz ) { + s << nz.off() << ": [ " << nz.col() << ", " + << nz.row() << "]: " + << nz.val(); + } +#endif + private: @@ -338,15 +347,6 @@ namespace grb { return this->_CXX->values[ this->_off ]; } -#ifdef _DEBUG - /** Overload print function. */ - static void print( std::ostream &s, const SelfType &nz ) { - s << nz.off() << ": [ " << nz.col() << ", " - << nz.row() << "]: " - << nz.val(); - } -#endif - }; template< From 5209a6693e89684063de7ac284665068c1a2fa0d Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 14:39:10 +0200 Subject: [PATCH 03/10] Moved headers were not added to the CMakeLists, now corrected --- include/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index acb01cb6f..458eadbcb 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -51,7 +51,8 @@ set( root_files "graphblas/phase.hpp" "graphblas/pinnedvector.hpp" "graphblas/properties.hpp" "graphblas/rc.hpp" "graphblas/semiring.hpp" "graphblas/spmd.hpp" "graphblas/tags.hpp" "graphblas/type_traits.hpp" "graphblas/utils.hpp" - "graphblas/vector.hpp" + "graphblas/vector.hpp" "graphblas/SynchronizedNonzeroIterator.hpp" + "graphblas/NonzeroStorage.hpp" ) set( GRB_INCLUDE_INSTALL_DIR "${INCLUDE_INSTALL_DIR}/graphblas") install( FILES ${root_files} DESTINATION "${GRB_INCLUDE_INSTALL_DIR}" ) From dfa84dce7561a923d837c18d0977e2774dd45f23 Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 14:39:42 +0200 Subject: [PATCH 04/10] Minor code style fix and add missing include --- tests/unit/id.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/id.cpp b/tests/unit/id.cpp index a5bb84cf6..25b7ac0aa 100644 --- a/tests/unit/id.cpp +++ b/tests/unit/id.cpp @@ -15,8 +15,10 @@ * limitations under the License. */ +#include #include + struct input { bool check; std::array< size_t, 3 > values; From 2b8ea34525383370c80a37dc7ce0c795f8a61efd Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 14:39:57 +0200 Subject: [PATCH 05/10] Minor code style fixes --- include/graphblas/NonzeroStorage.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/graphblas/NonzeroStorage.hpp b/include/graphblas/NonzeroStorage.hpp index 76f05c710..8443ae547 100644 --- a/include/graphblas/NonzeroStorage.hpp +++ b/include/graphblas/NonzeroStorage.hpp @@ -269,7 +269,7 @@ namespace grb { typename V > void nonzeroStorage_printer( - std::ostream& s, + std::ostream &s, const NonzeroStorage< R, T, V > &nz, typename std::enable_if< std::is_same< V, void >::value >::type * = nullptr ) { @@ -287,8 +287,8 @@ namespace grb { typename T, typename V > - std::ostream& operator<<( - std::ostream& s, + std::ostream & operator<<( + std::ostream &s, const NonzeroStorage< R, T, V > &nz ) { s << "( " << nz.i() << ", " << nz.j() << " )"; From 6740948a57765124364af581d7749d74b58fb8d1 Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 14:40:34 +0200 Subject: [PATCH 06/10] Minor code style fixes and fix operator<< overload to std::ostream for std::pair. --- include/graphblas/ops.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/graphblas/ops.hpp b/include/graphblas/ops.hpp index 918b37db9..1275832c0 100644 --- a/include/graphblas/ops.hpp +++ b/include/graphblas/ops.hpp @@ -26,6 +26,7 @@ #include "internalops.hpp" #include "type_traits.hpp" + namespace grb { /** @@ -540,9 +541,9 @@ namespace grb { static const constexpr bool value = true; }; - } // namespace grb::internal + } // end namespace grb::internal -} // namespace grb +} // end namespace grb #ifdef __DOXYGEN__ /** @@ -552,13 +553,16 @@ namespace grb { */ #define _DEBUG_NO_IOSTREAM_PAIR_CONVERTER #endif + #ifdef _DEBUG #ifndef _DEBUG_NO_IOSTREAM_PAIR_CONVERTER +namespace std { template< typename U, typename V > - std::ostream & operator<<( std::ostream & out, const std::pair< U, V > & pair ) { + std::ostream & operator<<( std::ostream &out, const std::pair< U, V > &pair ) { out << "( " << pair.first << ", " << pair.second << " )"; return out; } +} // end namespace std #endif #endif From 2fd84fdf6cc3d355891cd80785eb5c73559c498d Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 16:35:48 +0200 Subject: [PATCH 07/10] Minor code style fix --- include/graphblas/reference/matrix.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graphblas/reference/matrix.hpp b/include/graphblas/reference/matrix.hpp index 1cda7e897..a023807a3 100644 --- a/include/graphblas/reference/matrix.hpp +++ b/include/graphblas/reference/matrix.hpp @@ -455,7 +455,7 @@ namespace grb { { std::cout << "after third step:" << std::endl; for( size_t s = 0; s < prefix_sum_buffer_size; s++ ) { - std::cout << s << ": " << prefix_sum_buffer[s] << std::endl; + std::cout << s << ": " << prefix_sum_buffer[ s ] << std::endl; } } #endif From 9b097cd4fe4e495f1941d0d61a2f9136f7e5b363 Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 16:36:10 +0200 Subject: [PATCH 08/10] Provide overload for pattern nonzeroes used in _DEBUG mode --- include/graphblas/reference/nonzero_wrapper.hpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/graphblas/reference/nonzero_wrapper.hpp b/include/graphblas/reference/nonzero_wrapper.hpp index ef423f700..284895e0d 100644 --- a/include/graphblas/reference/nonzero_wrapper.hpp +++ b/include/graphblas/reference/nonzero_wrapper.hpp @@ -254,11 +254,25 @@ namespace grb { #ifdef _DEBUG /** Overload print function. */ - static void print( std::ostream &s, const SelfType &nz ) { + static void print( std::ostream &s, const SelfType &nz, + typename std::enable_if< + !(std::is_same< ValType, void >::value) + >::type * = nullptr + ) { s << nz.off() << ": [ " << nz.col() << ", " << nz.row() << "]: " << nz.val(); } + + /** Overload print function for pattern nonzeroes. */ + static void print( std::ostream &s, const SelfType &nz, + typename std::enable_if< + std::is_same< ValType, void >::value + >::type * = nullptr + ) { + s << nz.off() << ": [ " << nz.col() << ", " + << nz.row() << "]"; + } #endif From 961d2f366ebda17d1d6bc557dee0070a150fa407 Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 17:20:07 +0200 Subject: [PATCH 09/10] Rename reference/nonzero_wrapper.hpp to the CamelCase NonzeroWrapper.hpp --- .../reference/{nonzero_wrapper.hpp => NonzeroWrapper.hpp} | 0 include/graphblas/reference/matrix.hpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename include/graphblas/reference/{nonzero_wrapper.hpp => NonzeroWrapper.hpp} (100%) diff --git a/include/graphblas/reference/nonzero_wrapper.hpp b/include/graphblas/reference/NonzeroWrapper.hpp similarity index 100% rename from include/graphblas/reference/nonzero_wrapper.hpp rename to include/graphblas/reference/NonzeroWrapper.hpp diff --git a/include/graphblas/reference/matrix.hpp b/include/graphblas/reference/matrix.hpp index a023807a3..cd9f79b39 100644 --- a/include/graphblas/reference/matrix.hpp +++ b/include/graphblas/reference/matrix.hpp @@ -50,7 +50,7 @@ #include #include -#include "nonzero_wrapper.hpp" +#include "NonzeroWrapper.hpp" #include "forward.hpp" From 363a0e1d402212ae16ed622b53ce17c2e61b5149 Mon Sep 17 00:00:00 2001 From: Albert-Jan Yzelman Date: Thu, 4 Aug 2022 17:20:44 +0200 Subject: [PATCH 10/10] Fix use of enable-if --- include/graphblas/reference/NonzeroWrapper.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/graphblas/reference/NonzeroWrapper.hpp b/include/graphblas/reference/NonzeroWrapper.hpp index 284895e0d..dec7f53ff 100644 --- a/include/graphblas/reference/NonzeroWrapper.hpp +++ b/include/graphblas/reference/NonzeroWrapper.hpp @@ -254,9 +254,10 @@ namespace grb { #ifdef _DEBUG /** Overload print function. */ + template< typename T = ValType > static void print( std::ostream &s, const SelfType &nz, typename std::enable_if< - !(std::is_same< ValType, void >::value) + !(std::is_same< T, void >::value) >::type * = nullptr ) { s << nz.off() << ": [ " << nz.col() << ", " @@ -265,9 +266,10 @@ namespace grb { } /** Overload print function for pattern nonzeroes. */ + template< typename T = ValType > static void print( std::ostream &s, const SelfType &nz, typename std::enable_if< - std::is_same< ValType, void >::value + std::is_same< T, void >::value >::type * = nullptr ) { s << nz.off() << ": [ " << nz.col() << ", "