@@ -277,6 +277,61 @@ TEST_F(HDF5MatrixTest, UnderfilledPattern) {
277
277
verify_matrix (matrix_b, 1 );
278
278
}
279
279
280
+ template <typename MatrixT>
281
+ void print_matrix (const MatrixT& matrix) {
282
+ using namespace std ;
283
+ dash::barrier ();
284
+ if (!dash::myid ()) {
285
+ auto rows = matrix.extent (0 );
286
+ auto cols = matrix.extent (1 );
287
+ cout << fixed;
288
+ cout.precision (4 );
289
+ cout << " Matrix:" << endl;
290
+ for (auto r = 0 ; r < rows; ++r) {
291
+ for (auto c = 0 ; c < cols; ++c) {
292
+ auto lindex = matrix.pattern ().local_index ({r,c});
293
+ cout << " " << setw (3 ) << (double ) matrix[r][c] << " (" << lindex.unit << " ," << lindex.index << " )" ;
294
+ }
295
+ cout << endl;
296
+ }
297
+ }
298
+ dash::barrier ();
299
+ }
300
+
301
+ /* *
302
+ * Allocate a matrix with extents that cannot fit into full blocks
303
+ * TilePattern
304
+ */
305
+ TEST_F (HDF5MatrixTest, UnderfilledPatternTile) {
306
+ using Matrix_t = dash::Matrix<double , 2 >;
307
+
308
+ auto team_size = dash::Team::All ().size ();
309
+
310
+ int ext_x = 5 * team_size + 1 ;
311
+ int ext_y = 10 * team_size;
312
+
313
+ double test_value = dash::myid ()+1 ;
314
+
315
+ LOG_MESSAGE (" Matrix extent (%i,%i)" , ext_x, ext_y);
316
+
317
+ auto size_spec = dash::SizeSpec<2 >(ext_x, ext_y);
318
+
319
+ {
320
+ Matrix_t matrix_a (size_spec);
321
+ // dash::fill(matrix_a.begin(), matrix_a.end(), test_value);
322
+ fill_matrix (matrix_a, test_value);
323
+ dio::OutputStream os (_filename);
324
+ os << dio::dataset (_dataset) << matrix_a;
325
+ }
326
+
327
+ Matrix_t matrix_b (size_spec);
328
+ dio::InputStream is (_filename);
329
+ is >> dio::dataset (_dataset) >> matrix_b;
330
+ dash::barrier ();
331
+
332
+ verify_matrix (matrix_b, test_value);
333
+ }
334
+
280
335
TEST_F (HDF5MatrixTest, UnderfilledPatMultiple) {
281
336
typedef dash::Pattern<2 , dash::ROW_MAJOR> pattern_t ;
282
337
typedef typename pattern_t ::index_type index_t ;
@@ -519,23 +574,23 @@ TEST_F(HDF5MatrixTest, DashView)
519
574
int secret = 0;
520
575
dash::NArray<int,2> matrix2d(100,80);
521
576
fill_matrix(matrix2d, secret);
522
-
577
+
523
578
{
524
579
auto output_view = dash::sub(0,5, matrix2d);
525
-
580
+
526
581
// TODO: Does not work
527
582
dash::fill(dash::begin(output_view), dash::end(output_view), 5);
528
583
529
584
// Store View
530
585
dio::OutputStream os(_filename);
531
586
os << output_view;
532
587
}
533
-
588
+
534
589
// Load data into a existing view
535
590
auto input_view = dash::sub(0,10, matrix2d);
536
591
dio::InputStream is(_filename);
537
592
is >> input_view;
538
-
593
+
539
594
// Load data into new matrix
540
595
dash::Array<int> matrix1d;
541
596
is >> matrix1d;
@@ -548,20 +603,20 @@ TEST_F(HDF5MatrixTest, HDFView)
548
603
int secret = 0;
549
604
dash::NArray<int,3> matrix3d(10,8,5);
550
605
fill_matrix(matrix3d, secret);
551
-
606
+
552
607
{
553
608
dio::OutputStream os(_filename);
554
609
os << matrix3d;
555
610
}
556
-
611
+
557
612
// Load subset of data into new matrix
558
613
dash::NArray<int,3> sub_matrix3d;
559
614
auto position = std::array<size_t,3>({2,4,1}); // top left corner of desired block
560
615
auto extent = std::array<size_t,3>({4,2,1}); // extents of block
561
616
dio::InputStream is(_filename);
562
617
is >> dash::block(position, extent)
563
618
>> sub_matrix3d;
564
-
619
+
565
620
// post condition
566
621
// sub_matrix3d has extent {4,2,1}
567
622
}
@@ -571,29 +626,29 @@ TEST_F(HDF5MatrixTest, WriteCorresponding)
571
626
int secret = 0;
572
627
dash::NArray<int,3> matrix3d(10,8,5);
573
628
fill_matrix(matrix3d, secret);
574
-
629
+
575
630
{
576
631
dio::OutputStream os(_filename);
577
632
os << matrix3d;
578
633
}
579
-
634
+
580
635
auto view = matrix3d.col(1);
581
636
// modify view
582
637
dash::fill(view.begin(), view.end(), 0);
583
-
638
+
584
639
// write slice back
585
640
dio::OutputStream os(_filename, dio::DeviceMode::App);
586
641
is >> dio::modify_dataset()
587
642
>> dash::block(position, extent)
588
643
>> sub_matrix3d;
589
-
644
+
590
645
// post condition
591
646
// slice in file is updated
592
647
dash::NArray<int,3> new_matrix3d(10,8,5);
593
-
648
+
594
649
dio::InputStream is(_filename);
595
650
is << new_matrix3d;
596
-
651
+
597
652
auto view = new_matrix3d.col(1);
598
653
dash::for_each(view.begin(), view.end(), [](int & el){ASSERT_EQ_U(0, el)});
599
654
}
0 commit comments