From b4e3741090e6f4816ac6a303b681ebb999a33504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Mon, 19 Apr 2021 16:04:53 +0200 Subject: [PATCH] Trying to debug segments printing for GPUs. --- .../Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp | 2 +- .../Algorithms/Segments/SegmentsExample_CSR_constructor_2.cpp | 2 +- .../Algorithms/Segments/SegmentsExample_CSR_forElements.cpp | 2 +- .../Algorithms/Segments/SegmentsExample_CSR_forSegments.cpp | 2 +- .../Examples/Algorithms/Segments/SegmentsExample_General.cpp | 2 -- .../Algorithms/Segments/SegmentsExample_forElements.cpp | 4 ++-- .../Algorithms/Segments/SegmentsExample_forSegments-1.cpp | 2 +- .../Algorithms/Segments/SegmentsExample_forSegments-2.cpp | 4 ++-- .../Algorithms/Segments/SegmentsExample_reduceSegments.cpp | 2 +- .../Algorithms/Segments/SegmentsPrintingExample-2.cpp | 3 +-- src/TNL/Algorithms/Segments/SegmentsPrinting.h | 4 ++-- 11 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp index ed25d6df47..0ceb7a6bd4 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_1.cpp @@ -35,7 +35,7 @@ void SegmentsExample() * Print the data managed by the segments. */ auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_2.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_2.cpp index a71c51519e..9493758b49 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_2.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_constructor_2.cpp @@ -34,7 +34,7 @@ void SegmentsExample() * Print the data managed by the segments. */ auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forElements.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forElements.cpp index 2649980462..37267a889f 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forElements.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forElements.cpp @@ -33,7 +33,7 @@ void SegmentsExample() * Print the data managed by the segments. */ auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forSegments.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forSegments.cpp index f2eb0ae13a..3bf7cc50bd 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forSegments.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_CSR_forSegments.cpp @@ -36,7 +36,7 @@ void SegmentsExample() * Print the data managed by the segments. */ auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_General.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_General.cpp index d64fdbfde0..ade0263fbc 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_General.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_General.cpp @@ -35,10 +35,8 @@ void SegmentsExample() /*** * Print the data managed by the segments. */ - std::cerr << data << std::endl; auto fetch = [=] __cuda_callable__ ( IndexType globalIdx ) -> double { return data_view[ globalIdx ]; }; printSegments( segments, fetch, std::cout ); - std::cout << segments.print( fetch ) << std::endl; /*** * Compute sums of elements in particular segments. diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forElements.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forElements.cpp index 621a2123ae..7d7eac76c1 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forElements.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forElements.cpp @@ -34,7 +34,7 @@ void SegmentsExample() std::cout << "Data setup with no check ... " << std::endl; std::cout << "Array: " << data << std::endl; auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); /*** * Insert data into particular segments. @@ -50,7 +50,7 @@ void SegmentsExample() */ std::cout << "Data setup with check for padding elements..." << std::endl; std::cout << "Array: " << data << std::endl; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-1.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-1.cpp index fa81662e8a..d8be1f04c7 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-1.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-1.cpp @@ -39,7 +39,7 @@ void SegmentsExample() * Print the data managed by the segments. */ auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-2.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-2.cpp index 0439b846a1..a5d7d0caa9 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-2.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_forSegments-2.cpp @@ -33,7 +33,7 @@ void SegmentsExample() */ std::cout << "Values of elements after intial setup: " << std::endl; auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ); + printSegments( segments, fetch, std::cout ); /*** * Divide elements in each segment by a sum of all elements in the segment @@ -55,7 +55,7 @@ void SegmentsExample() * Print the data managed by the segments. */ std::cout << "Value of elements after dividing by sum in each segment:" << std::endl; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); } int main( int argc, char* argv[] ) diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsExample_reduceSegments.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsExample_reduceSegments.cpp index e6701f36bb..c9a7476c72 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsExample_reduceSegments.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsExample_reduceSegments.cpp @@ -36,7 +36,7 @@ void SegmentsExample() */ std::cout << "Values of elements after intial setup: " << std::endl; auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; + printSegments( segments, fetch, std::cout ); /*** * Compute sums of elements in each segment. diff --git a/Documentation/Examples/Algorithms/Segments/SegmentsPrintingExample-2.cpp b/Documentation/Examples/Algorithms/Segments/SegmentsPrintingExample-2.cpp index 73d2e415d7..8f25b8bad9 100644 --- a/Documentation/Examples/Algorithms/Segments/SegmentsPrintingExample-2.cpp +++ b/Documentation/Examples/Algorithms/Segments/SegmentsPrintingExample-2.cpp @@ -32,8 +32,7 @@ void SegmentsExample() */ auto data_view = data.getView(); auto fetch = [=] __cuda_callable__ ( int globalIdx ) -> double { return data_view[ globalIdx ]; }; - std::cout << segments.print( fetch ) << std::endl; - std::cout << std::endl; + printSegments( segments, fetch, std::cout ) << std::endl; } int main( int argc, char* argv[] ) diff --git a/src/TNL/Algorithms/Segments/SegmentsPrinting.h b/src/TNL/Algorithms/Segments/SegmentsPrinting.h index fa5d6c6284..f8fd7412ed 100644 --- a/src/TNL/Algorithms/Segments/SegmentsPrinting.h +++ b/src/TNL/Algorithms/Segments/SegmentsPrinting.h @@ -92,12 +92,12 @@ struct SegmentsPrinter Fetch fetch; }; -template< typename Segments, +/*template< typename Segments, typename Fetch > std::ostream& operator<<( std::ostream& str, const SegmentsPrinter< Segments, Fetch >& printer ) { return printer.print( str ); -} +}*/ template< typename Segments, typename Fetch > -- GitLab