diff --git a/src/TNL/Containers/Segments/CSR.hpp b/src/TNL/Containers/Segments/CSR.hpp index 3581748fad75f832fcb121e265eb3433faf6d74f..9a05d84f75ad60b11c831846e8ee0beed1a17932 100644 --- a/src/TNL/Containers/Segments/CSR.hpp +++ b/src/TNL/Containers/Segments/CSR.hpp @@ -207,7 +207,7 @@ void CSR< Device, Index, IndexAllocator >:: forAll( Function& f, Args... args ) const { - this->forSegments( 0, this->getSize(), f, args... ); + this->forSegments( 0, this->getSegmentsCount(), f, args... ); } template< typename Device, diff --git a/src/TNL/Containers/Segments/CSRView.hpp b/src/TNL/Containers/Segments/CSRView.hpp index d8ea9b06ed71df4ff5acdc93657bf7cc886ba23b..d6ec55b6afd5c1ccc1bd423bc071b7d5c413dcbf 100644 --- a/src/TNL/Containers/Segments/CSRView.hpp +++ b/src/TNL/Containers/Segments/CSRView.hpp @@ -156,7 +156,7 @@ auto CSRView< Device, Index >:: getSegmentView( const IndexType segmentIdx ) const -> SegmentViewType { - printf( "----> size %d \n", offsets[ segmentIdx + 1 ] ); + printf( "----> segmentIdx %d offset %d size %d ptr %p \n", segmentIdx, offsets[ segmentIdx ], offsets.getSize(), offsets.getData() ); return SegmentViewType( offsets[ segmentIdx ], offsets[ segmentIdx + 1 ] - offsets[ segmentIdx ], 1 ); } @@ -186,7 +186,7 @@ void CSRView< Device, Index >:: forAll( Function& f, Args... args ) const { - this->forSegments( 0, this->getSize(), f, args... ); + this->forSegments( 0, this->getSegmentsCount(), f, args... ); } template< typename Device, diff --git a/src/TNL/Containers/Segments/SegmentView.h b/src/TNL/Containers/Segments/SegmentView.h index edfe31df43b19ab8669feec6d9ec87f914aa4340..eeb3f9d244cc2c4126bb8d92c824b5ca7ffc9a67 100644 --- a/src/TNL/Containers/Segments/SegmentView.h +++ b/src/TNL/Containers/Segments/SegmentView.h @@ -29,16 +29,12 @@ class SegmentView< Index, false > SegmentView( const IndexType offset, const IndexType size, const IndexType step ) - : segmentOffset( offset ), segmentSize( size ), step( step ) - { - printf( "--- size = %d \n", size ); - }; + : segmentOffset( offset ), segmentSize( size ), step( step ){}; __cuda_callable__ SegmentView( const SegmentView& view ) - : segmentOffset( view.segmentOffset ), segmentSize( view.segmentSize ), step( view.step ) - { - }; + : segmentOffset( view.segmentOffset ), segmentSize( view.segmentSize ), step( view.step ){}; + __cuda_callable__ IndexType getSize() const { diff --git a/src/UnitTests/Containers/Segments/SegmentsTest.hpp b/src/UnitTests/Containers/Segments/SegmentsTest.hpp index 8320fafe57455190780fa25b6d16b6b463df2eb6..590b39881fbb859037433c4d919dd7550f43b462 100644 --- a/src/UnitTests/Containers/Segments/SegmentsTest.hpp +++ b/src/UnitTests/Containers/Segments/SegmentsTest.hpp @@ -127,17 +127,17 @@ void test_AllReduction_MaximumInSegments() TNL::Containers::Vector< IndexType, DeviceType, IndexType > v( segments.getStorageSize() ); - IndexType k( 1 ); + /*IndexType k( 1 ); for( IndexType i = 0; i < segmentsCount; i++ ) for( IndexType j = 0; j < segmentSize; j++ ) - v.setElement( segments.getGlobalIndex( i, j ), k++ ); - /*auto view = v.getView(); - auto init = [=] __cuda_callable__ ( const IndexType i, const IndexType j ) mutable -> bool { - view[ j ] = j + 1; + v.setElement( segments.getGlobalIndex( i, j ), k++ );*/ + auto view = v.getView(); + auto init = [=] __cuda_callable__ ( const IndexType segmentIdx, const IndexType localIdx, const IndexType globalIdx ) mutable -> bool { + view[ globalIdx ] = segmentIdx * 5 + localIdx + 1; return true; }; segments.forAll( init ); - std::cerr << v << std::endl;*/ + std::cerr << v << std::endl; TNL::Containers::Vector< IndexType, DeviceType, IndexType >result( segmentsCount );