From 1dd41ea363abd51b2ed4215f67f4f0a3bf8c1b66 Mon Sep 17 00:00:00 2001 From: anindex Date: Tue, 10 Mar 2020 14:53:21 +0100 Subject: [PATCH 1/5] Add StoreHDF5::read and write test for dash matrix 1D, 2D with signed and unsigned type --- dash/test/io/HDF5MatrixTest.cc | 120 +++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/dash/test/io/HDF5MatrixTest.cc b/dash/test/io/HDF5MatrixTest.cc index 4b4802daa..f6e9c45ba 100644 --- a/dash/test/io/HDF5MatrixTest.cc +++ b/dash/test/io/HDF5MatrixTest.cc @@ -20,6 +20,8 @@ typedef int value_t; namespace dio = dash::io::hdf5; +using dash::io::hdf5::StoreHDF; + /** * Cantors pairing function to map n-tuple to single number */ @@ -513,6 +515,124 @@ TEST_F(HDF5MatrixTest, GroupTest) { verify_matrix(matrix_c, secret[2]); } +TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix1D) { + auto numunits = dash::Team::All().size(); + + // Add some randomness to the data + std::srand(time(NULL)); + int local_secret = std::rand() % 1000; + int myid = dash::myid(); + + typedef dash::Matrix matrix_t; + + int extend = 1000; + auto size_spec = dash::SizeSpec<1>(extend); + + DASH_LOG_DEBUG("Pattern", pattern1d); + { + matrix_t mat1(size_spec); + dash::barrier(); + LOG_MESSAGE("Matrix created"); + + fill_matrix(mat1, local_secret); + dash::barrier(); + DASH_LOG_DEBUG("BEGIN STORE HDF"); + + StoreHDF::write(mat1, _filename, _dataset); + + DASH_LOG_DEBUG("END STORE HDF"); + dash::barrier(); + } + + matrix_t mat1_verified(size_spec); + dash::barrier(); + StoreHDF::read(mat1_verified, _filename, _dataset); + dash::barrier(); + + verify_matrix(mat1_verified, local_secret); +} + +TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2D) { + auto numunits = dash::Team::All().size(); + + // Add some randomness to the data + std::srand(time(NULL)); + int local_secret = std::rand() % 1000; + int myid = dash::myid(); + + typedef dash::TilePattern<2, dash::ROW_MAJOR, long> pattern_t; + typedef dash::Matrix matrix_t; + + typedef dash::TilePattern<2, dash::ROW_MAJOR, unsigned long> upattern_t; + typedef dash::Matrix umatrix_t; + + //test default type + dash::TeamSpec<2, pattern_t::index_type> team_spec(numunits, 1); + team_spec.balance_extents(); + + auto extend_x = 2 * 2 * team_spec.extent(0); + auto extend_y = 2 * 5 * team_spec.extent(1); + + pattern_t pattern(dash::SizeSpec<2, pattern_t::size_type>(extend_x, extend_y), + dash::DistributionSpec<2>(dash::TILE(2), dash::TILE(5)), + team_spec); + + DASH_LOG_DEBUG("Pattern", pattern); + { + matrix_t mat1(pattern); + dash::barrier(); + LOG_MESSAGE("Matrix created"); + + fill_matrix(mat1, local_secret); + dash::barrier(); + DASH_LOG_DEBUG("BEGIN STORE HDF"); + + StoreHDF::write(mat1, _filename, _dataset); + + DASH_LOG_DEBUG("END STORE HDF"); + dash::barrier(); + } + + matrix_t mat1_verified(pattern); + dash::barrier(); + StoreHDF::read(mat1_verified, _filename, _dataset); + dash::barrier(); + + verify_matrix(mat1_verified, local_secret); + + //test unsigned type + dash::TeamSpec<2, upattern_t::index_type> uteam_spec(numunits, 1); //here signifies the inflexibity of type acceptance + uteam_spec.balance_extents(); + + upattern_t upattern(dash::SizeSpec<2, upattern_t::size_type>(extend_x, extend_y), + dash::DistributionSpec<2>(dash::TILE(2), dash::TILE(5)), + uteam_spec); + + DASH_LOG_DEBUG("Pattern", upattern); + { + umatrix_t mat2(upattern); + dash::barrier(); + LOG_MESSAGE("Matrix created"); + + fill_matrix(mat2, local_secret); + dash::barrier(); + DASH_LOG_DEBUG("BEGIN STORE HDF"); + + StoreHDF::write(mat2, _filename, _dataset); + + DASH_LOG_DEBUG("END STORE HDF"); + dash::barrier(); + } + + umatrix_t mat2_verified(upattern); + dash::barrier(); + StoreHDF::read(mat2_verified, _filename, _dataset); + dash::barrier(); + + verify_matrix(mat2_verified, local_secret); +} + + #if 0 TEST_F(HDF5MatrixTest, DashView) { From 1f2e308bd4c669b24ed269beee63c20faf293363 Mon Sep 17 00:00:00 2001 From: anindex Date: Wed, 11 Mar 2020 13:32:42 +0100 Subject: [PATCH 2/5] Split matrix 2D signed and unsigned test --- dash/test/io/HDF5MatrixTest.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dash/test/io/HDF5MatrixTest.cc b/dash/test/io/HDF5MatrixTest.cc index f6e9c45ba..1fc7385b7 100644 --- a/dash/test/io/HDF5MatrixTest.cc +++ b/dash/test/io/HDF5MatrixTest.cc @@ -563,9 +563,6 @@ TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2D) { typedef dash::TilePattern<2, dash::ROW_MAJOR, long> pattern_t; typedef dash::Matrix matrix_t; - typedef dash::TilePattern<2, dash::ROW_MAJOR, unsigned long> upattern_t; - typedef dash::Matrix umatrix_t; - //test default type dash::TeamSpec<2, pattern_t::index_type> team_spec(numunits, 1); team_spec.balance_extents(); @@ -599,11 +596,26 @@ TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2D) { dash::barrier(); verify_matrix(mat1_verified, local_secret); +} + +TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2DUnsigned) { + typedef dash::TilePattern<2, dash::ROW_MAJOR, unsigned long> upattern_t; + typedef dash::Matrix umatrix_t; + + auto numunits = dash::Team::All().size(); + + // Add some randomness to the data + std::srand(time(NULL)); + int local_secret = std::rand() % 1000; + int myid = dash::myid(); //test unsigned type dash::TeamSpec<2, upattern_t::index_type> uteam_spec(numunits, 1); //here signifies the inflexibity of type acceptance uteam_spec.balance_extents(); + auto extend_x = 2 * 2 * uteam_spec.extent(0); + auto extend_y = 2 * 5 * uteam_spec.extent(1); + upattern_t upattern(dash::SizeSpec<2, upattern_t::size_type>(extend_x, extend_y), dash::DistributionSpec<2>(dash::TILE(2), dash::TILE(5)), uteam_spec); From 7353500e0106c6976227fd7e94246f2f353a7783 Mon Sep 17 00:00:00 2001 From: anindex Date: Wed, 11 Mar 2020 14:03:32 +0100 Subject: [PATCH 3/5] Temporary remove matrix 1D test --- dash/test/io/HDF5MatrixTest.cc | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/dash/test/io/HDF5MatrixTest.cc b/dash/test/io/HDF5MatrixTest.cc index 1fc7385b7..058026e7c 100644 --- a/dash/test/io/HDF5MatrixTest.cc +++ b/dash/test/io/HDF5MatrixTest.cc @@ -515,43 +515,6 @@ TEST_F(HDF5MatrixTest, GroupTest) { verify_matrix(matrix_c, secret[2]); } -TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix1D) { - auto numunits = dash::Team::All().size(); - - // Add some randomness to the data - std::srand(time(NULL)); - int local_secret = std::rand() % 1000; - int myid = dash::myid(); - - typedef dash::Matrix matrix_t; - - int extend = 1000; - auto size_spec = dash::SizeSpec<1>(extend); - - DASH_LOG_DEBUG("Pattern", pattern1d); - { - matrix_t mat1(size_spec); - dash::barrier(); - LOG_MESSAGE("Matrix created"); - - fill_matrix(mat1, local_secret); - dash::barrier(); - DASH_LOG_DEBUG("BEGIN STORE HDF"); - - StoreHDF::write(mat1, _filename, _dataset); - - DASH_LOG_DEBUG("END STORE HDF"); - dash::barrier(); - } - - matrix_t mat1_verified(size_spec); - dash::barrier(); - StoreHDF::read(mat1_verified, _filename, _dataset); - dash::barrier(); - - verify_matrix(mat1_verified, local_secret); -} - TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2D) { auto numunits = dash::Team::All().size(); From 50f294803cc8fbdaededddfd6545087b9e9c7946 Mon Sep 17 00:00:00 2001 From: anindex Date: Wed, 11 Mar 2020 14:43:32 +0100 Subject: [PATCH 4/5] add again matrix 1D test, now with more rigorous typedefs --- dash/test/io/HDF5MatrixTest.cc | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dash/test/io/HDF5MatrixTest.cc b/dash/test/io/HDF5MatrixTest.cc index 058026e7c..6560d6a9c 100644 --- a/dash/test/io/HDF5MatrixTest.cc +++ b/dash/test/io/HDF5MatrixTest.cc @@ -515,6 +515,46 @@ TEST_F(HDF5MatrixTest, GroupTest) { verify_matrix(matrix_c, secret[2]); } +TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix1D) { + auto numunits = dash::Team::All().size(); + + // Add some randomness to the data + std::srand(time(NULL)); + int local_secret = std::rand() % 1000; + int myid = dash::myid(); + + typedef dash::TilePattern<1> pattern_t; // using default order and index type + typedef dash::Matrix matrix_t; + + int extend = 8; + pattern_t pattern(dash::SizeSpec<1, pattern_t::size_type>(extend), + dash::DistributionSpec<1>(dash::TILE(2)), + dash::TeamSpec<1, pattern_t::index_type>()); + + DASH_LOG_DEBUG("Pattern", pattern); + { + matrix_t mat1(pattern); + dash::barrier(); + LOG_MESSAGE("Matrix created"); + + fill_matrix(mat1, local_secret); + dash::barrier(); + DASH_LOG_DEBUG("BEGIN STORE HDF"); + + StoreHDF::write(mat1, _filename, _dataset); + + DASH_LOG_DEBUG("END STORE HDF"); + dash::barrier(); + } + + matrix_t mat1_verified(pattern); + dash::barrier(); + StoreHDF::read(mat1_verified, _filename, _dataset); + dash::barrier(); + + verify_matrix(mat1_verified, local_secret); +} + TEST_F(HDF5MatrixTest, ReadAndWriteDashMatrix2D) { auto numunits = dash::Team::All().size(); From 6461b91635d6b16349dfdc5ecf66b9105982ae4c Mon Sep 17 00:00:00 2001 From: anindex Date: Wed, 11 Mar 2020 14:57:59 +0100 Subject: [PATCH 5/5] Fix formatting issue from previous PR --- dart-impl/base/src/hwinfo.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index e1b573b0b..c133756d5 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -11,7 +11,7 @@ #define CPUID(INFO, LEAF, SUBLEAF) __cpuid_count(LEAF, SUBLEAF, INFO[0], INFO[1], INFO[2], INFO[3]) -static int osx_sched_getcpu() { +static int osx_sched_getcpu() { uint32_t CPUInfo[4]; int cpuid; CPUID(CPUInfo, 1, 0); @@ -400,17 +400,17 @@ dart_ret_t dart_hwinfo( } #endif /* DART_ENABLE_PAPI */ -if (hw.cpu_id < 0) { - #ifdef DART__PLATFORM__LINUX + if (hw.cpu_id < 0) { +#ifdef DART__PLATFORM__LINUX hw.cpu_id = sched_getcpu(); - #elif defined(DART__PLATFORM__OSX) +#elif defined(DART__PLATFORM__OSX) hw.cpu_id = osx_sched_getcpu(); - #else +#else DART_LOG_ERROR("dart_hwinfo: " - "HWLOC or PAPI required if not running on a Linux or OSX platform"); + "HWLOC or PAPI required if not running on a Linux or OSX platform"); return DART_ERR_OTHER; - #endif -} +#endif + } #ifdef DART__ARCH__IS_MIC /*