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

Hdf5 #101

Merged
merged 20 commits into from
May 6, 2017
Merged

Hdf5 #101

merged 20 commits into from
May 6, 2017

Conversation

guj
Copy link
Contributor

@guj guj commented May 2, 2017

added timestep and read write.
looks like I need to merge with master? structure was changed

for using reader in current write-read test, see helloHDF5Writer.cpp at the end of write section, there is a few lines to read what was written.

Copy link
Contributor

@chuckatkins chuckatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs most member variables renamed. Also please fix the HDF5 Write test

myCLongDoubles.data() + complexOffset);
int ts = 0;
int totalts = 2;
while (true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while(true) is clunky here. Should be a for loop. Try:

for(int ts = 0; ts < totalts; ++ts)


else if (type == "HDF5Reader") // -Junmin
{
#if defined(ADIOS_HAVE_PHDF5) && defined(ADIOS_HAVE_MPI)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just be #ifdef ADIOS2_HAVE_HDF5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

H5Pclose(_plist_id);
}

HDF5Common::~HDF5Common() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty destructor can be left out completely and a default destructor will be inserted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

*/
HDF5Common();

virtual ~HDF5Common();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No inheritance so no need to make this virtual. Also can be removed entirely since the implementation is empty and just let the compiler generate a default destructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

int GetNumTimeSteps();
void WriteTimeSteps();

hid_t _plist_id, _file_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All member variables should be named as m_VarName not _var_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Variable<void> *HDF5Reader::InquireVariable(const std::string &variableName,
const bool readIn)
{
std::cout << "Not implemented: HDF5Reder::InquireVariable()" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return value. Add return nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

Variable<double> *
HDF5Reader::InquireVariableDouble(const std::string &variableName, const bool)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually return anything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added null return, for now.

This function has a body now, because I noticed ReadMe(), which is not inherited from any parent class, was not touched during compilation, unless I call it from a parent class function, like InquireVariableDouble().

Do you know why?


virtual ~HDF5Reader();

Variable<void> *InquireVariable(const std::string &variableName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these InquireVariableTypeName member functions would be better suited to a single template function with specializations for each type.

void ReadMe(Variable<T> variable, T *values, hid_t h5type);

private:
HDF5Common _H5File;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use m_VarName for all data members, not _var_name

@chuckatkins chuckatkins dismissed their stale review May 4, 2017 18:19

re-examining with updated commits

Copy link
Contributor

@chuckatkins chuckatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All access in user-facing code to the engines should be through the abstract engine class, not through the HDF5Writer class directly.

I think you misunderstood what I meant in the test. For the ADIOS2HDF5WriteHDF5Read tests, we want to use the ADIOS2 HDF5Writer engine to write the data but then use HDF5 directly to read the data, i.e. not the HDF5Reader engine. The ADIOS2 Read API is still in quite a bit of flux so I don't want to build tests on it yet. Besides, those will be seperate tests: Write with hdf5 -> read with adios2+hdf5, write with adios2+hdf5 -> read with adios2+hdf5, but don't bother with those yet. Currently we jsut want write with adios2+hdf5 -> read with hdf5.

Also, most of the comments from the previos review remain unaddressed.

@guj
Copy link
Contributor Author

guj commented May 4, 2017

Hi Chuck, I understood your request. I just put the function ReadMe() in HDF5Reader for convenience. I assume this hdf5 direct access check will disappear after ADIOS2 read is in place. At the time, I will just simply remove that function.

@guj
Copy link
Contributor Author

guj commented May 4, 2017

To be precise, ReadMe() is invoked directly through HDR5Reader, not going through the ADIOS engine at all.

@chuckatkins
Copy link
Contributor

It will remain as a permanent test. It's part of ensuring correctness for the interoperability aspect. We need to make sure that all of the following situations work:

  • Write with adios2, read with hdf5
  • Write with adios2, read with adios2
  • Write with hdf5, read with adios2

Currently the second two will remain empty until the adios2 read API settles, but the first one needs to be in place now. Having the read validation test not using adios2 at all ensures that we don't create hdf5 files that are incompatible with apps only using hdf5 and not adios2.

@guj
Copy link
Contributor Author

guj commented May 4, 2017

I will put a read function in the HDF5Common class. It is better?

@chuckatkins
Copy link
Contributor

The read validation should be directly in the test and directly using hdf5, not as any component of the engine. Basically you should be able to read the data back and verify it's dimensions and contents without using anything from adios2.

@guj
Copy link
Contributor Author

guj commented May 5, 2017

hdf5 read engine will call hdf5 interface too, and that is what HDF5Common is for. It has nothing to do with engine, just make hdf5 calls.
so sounds like you want to see a duplicate of HDF5Common in the test/ directory?

@guj
Copy link
Contributor Author

guj commented May 5, 2017

never mind. I put a simple hdf5 read class in the TestHDF5WriteRead.cpp
to do direct hdf5 access. It should serve the purpose.

@chuckatkins chuckatkins dismissed their stale review May 5, 2017 18:54

Re-examining with new changes

@chuckatkins
Copy link
Contributor

The ADIOSWriteInterfcace test now fails. I assume this has to do with the swapping for global and local dimension parameters in the variable class.

$ ./bin/TestADIOSInterfaceWrite
[==========] Running 20 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 20 tests from ADIOSInterfaceWriteTest
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarChar1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:36: Failure
      Expected: var_i8.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarChar1x10 (1 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarShort1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:53: Failure
      Expected: var_i16.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarShort1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarInt1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:67: Failure
      Expected: var_i32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarInt1x10 (1 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarLong1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:81: Failure
      Expected: var_i64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarLong1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUChar1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:97: Failure
      Expected: var_u8.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUChar1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUShort1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:114: Failure
      Expected: var_u16.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUShort1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUInt1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:130: Failure
      Expected: var_u32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUInt1x10 (1 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarULong1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:146: Failure
      Expected: var_u64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarULong1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarFloat1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:162: Failure
      Expected: var_r32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarFloat1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarDouble1x10
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:178: Failure
      Expected: var_r64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 1
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarDouble1x10 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarChar2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:193: Failure
      Expected: var_i8.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarChar2x5 (1 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarShort2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:210: Failure
      Expected: var_i16.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarShort2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarInt2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:226: Failure
      Expected: var_i32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarInt2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarLong2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:242: Failure
      Expected: var_i64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarLong2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUChar2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:259: Failure
      Expected: var_u8.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUChar2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUShort2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:277: Failure
      Expected: var_u16.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUShort2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarUInt2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:295: Failure
      Expected: var_u32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUInt2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarULong2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:313: Failure
      Expected: var_u64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarULong2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarFloat2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:330: Failure
      Expected: var_r32.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarFloat2x5 (0 ms)
[ RUN      ] ADIOSInterfaceWriteTest.DefineVarDouble2x5
/home/khq.kitware.com/chuck.atkins/Code/adios/source/hdf5/testing/adios2/interface/TestADIOSInterfaceWrite.cpp:347: Failure
      Expected: var_r64.m_LocalDimensions.size()
      Which is: 0
To be equal to: 2
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarDouble2x5 (0 ms)
[----------] 20 tests from ADIOSInterfaceWriteTest (5 ms total)

[----------] Global test environment tear-down
[==========] 20 tests from 1 test case ran. (5 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 20 tests, listed below:
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarChar1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarShort1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarInt1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarLong1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUChar1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUShort1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUInt1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarULong1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarFloat1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarDouble1x10
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarChar2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarShort2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarInt2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarLong2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUChar2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUShort2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarUInt2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarULong2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarFloat2x5
[  FAILED  ] ADIOSInterfaceWriteTest.DefineVarDouble2x5

20 FAILED TESTS
$

@pnorbert
Copy link
Contributor

pnorbert commented May 5, 2017 via email

Copy link
Contributor

@chuckatkins chuckatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it looks like a lot, but really it's mostly just formatting a changes for variable names and removing large blocks of disabled code. Almost there!

@@ -10,7 +10,10 @@

#include <mpi.h>

#include <adios2.h>
#define ADIOS_HAVE_PHDF5 // so hdf5 related items are loaded in ADIOS_CPP.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User-code doesn't see the internal ADIOS headers anymore. This whole include block should just be #include <adios2.h>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/

#ifndef NEVER
adios::HDF5Common myReader;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove #ifdef'd out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

else if (type == "HDF5Reader") // -Junmin
{
//#if defined(ADIOS_HAVE_PHDF5) && defined(ADIOS_HAVE_MPI)
#ifdef ADIOS_HAVE_PHDF5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ADIADIOS2_HAVE_HDF5, not ADIOS_HAVE_PHDF5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const std::size_t elementSize, const Dims localDimensions,
const Dims globalDimensions, const Dims offsets,
const std::size_t elementSize, const Dims globalDimensions,
const Dims localDimensions, const Dims offsets,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ordering makes more sense but now it's not consistent with Variable.h. Please revert.

}

#ifdef NEVER
template <class T>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove #ifdef'd code block

// H5Sclose(_memspace);
// H5Pclose(_plist_id);
H5Fclose(_file_id);
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

_filespace = H5Screate_simple(dimSize, dimsf.data(), NULL);
hid_t _filespace = H5Screate_simple(dimSize, dimsf.data(), NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -86,22 +85,30 @@ class HDF5Writer : public Engine
void Write(const std::string variableName,
const std::complex<long double> *values);

void Advance(float timeout_sec = 0.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


HDF5Common _H5File;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_H5File -> m_H5File

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


HDF5Common _H5File;

/*
hid_t _plist_id, _file_id, _dset_id;
hid_t _memspace, _filespace;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@chuckatkins
Copy link
Contributor

Fixes #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants