Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases for StoreHDF5 read and write for issue #692 #699

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dart-impl/base/src/hwinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
/*
Expand Down
135 changes: 135 additions & 0 deletions dash/test/io/HDF5MatrixTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -513,6 +515,139 @@ 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<value_t, 1> 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();

// 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<value_t, 2, typename pattern_t::index_type, pattern_t> matrix_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_F(HDF5MatrixTest, ReadAndWriteDashMatrix2DUnsigned) {
typedef dash::TilePattern<2, dash::ROW_MAJOR, unsigned long> upattern_t;
typedef dash::Matrix<value_t, 2, typename upattern_t::index_type, upattern_t> 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);

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)
{
Expand Down