Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADIOS2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Podhorszki, Norbert
ADIOS2
Commits
c606e13c
Commit
c606e13c
authored
7 years ago
by
guj
Browse files
Options
Downloads
Patches
Plain Diff
removed comments
parent
8f7389e9
No related branches found
No related tags found
1 merge request
!49
setting up for hdf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/engine/hdf5/HDF5WriterP.h
+80
-189
80 additions, 189 deletions
include/engine/hdf5/HDF5WriterP.h
with
80 additions
and
189 deletions
include/engine/hdf5/HDF5WriterP.h
+
80
−
189
View file @
c606e13c
...
...
@@ -16,7 +16,6 @@
#include
"core/Engine.h"
// supported capsules
#include
"capsule/heap/STLVector.h"
...
...
@@ -24,200 +23,92 @@
#include
<hdf5.h>
namespace
adios
{
/*
typedef struct {
double _re; //real part
double _im; //imaginary part
} ADIOS2_Complex_Double;
typedef struct {
float _re; // real
float _im; // imaginary part
} ADIOS2_Complex_Float;
namespace
adios
{
// using ADIOS2_Complex_Float = std::complex<float>;
typedef struct {
long double _re; //real part
long double _im; //imaginary part
} ADIOS2_Complex_LongDouble;
*/
class
HDF5Writer
:
public
Engine
{
class
HDF5Writer
:
public
Engine
{
public:
/**
* Constructor for single BP capsule engine, writes in BP format into a single
* heap capsule
* @param name unique name given to the engine
* @param accessMode
* @param mpiComm
* @param method
* @param debugMode
*/
HDF5Writer
(
ADIOS
&
adios
,
const
std
::
string
name
,
const
std
::
string
accessMode
,
MPI_Comm
mpiComm
,
const
Method
&
method
);
virtual
~
HDF5Writer
();
void
Write
(
Variable
<
char
>
&
variable
,
const
char
*
values
);
void
Write
(
Variable
<
unsigned
char
>
&
variable
,
const
unsigned
char
*
values
);
void
Write
(
Variable
<
short
>
&
variable
,
const
short
*
values
);
void
Write
(
Variable
<
unsigned
short
>
&
variable
,
const
unsigned
short
*
values
);
void
Write
(
Variable
<
int
>
&
variable
,
const
int
*
values
);
void
Write
(
Variable
<
unsigned
int
>
&
variable
,
const
unsigned
int
*
values
);
void
Write
(
Variable
<
long
int
>
&
variable
,
const
long
int
*
values
);
void
Write
(
Variable
<
unsigned
long
int
>
&
variable
,
const
unsigned
long
int
*
values
);
void
Write
(
Variable
<
long
long
int
>
&
variable
,
const
long
long
int
*
values
);
void
Write
(
Variable
<
unsigned
long
long
int
>
&
variable
,
const
unsigned
long
long
int
*
values
);
void
Write
(
Variable
<
float
>
&
variable
,
const
float
*
values
);
void
Write
(
Variable
<
double
>
&
variable
,
const
double
*
values
);
void
Write
(
Variable
<
long
double
>
&
variable
,
const
long
double
*
values
);
void
Write
(
Variable
<
std
::
complex
<
float
>>
&
variable
,
const
std
::
complex
<
float
>
*
values
);
void
Write
(
Variable
<
std
::
complex
<
double
>>
&
variable
,
const
std
::
complex
<
double
>
*
values
);
void
Write
(
Variable
<
std
::
complex
<
long
double
>>
&
variable
,
const
std
::
complex
<
long
double
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
char
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
char
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
short
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
short
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
long
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
float
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
double
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
double
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
float
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
double
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
long
double
>
*
values
);
void
Close
(
const
int
transportIndex
=
-
1
);
/*
{
std::cout<<" ===> CLOSING HDF5 <===== "<<std::endl;
//H5Dclose(_dset_id);
//H5Sclose(_filespace);
//H5Sclose(_memspace);
//H5Pclose(_plist_id);
H5Fclose(_file_id);
}
*/
/**
* Constructor for single BP capsule engine, writes in BP format into a
* single
* heap capsule
* @param name unique name given to the engine
* @param accessMode
* @param mpiComm
* @param method
* @param debugMode
*/
HDF5Writer
(
ADIOS
&
adios
,
const
std
::
string
name
,
const
std
::
string
accessMode
,
MPI_Comm
mpiComm
,
const
Method
&
method
);
virtual
~
HDF5Writer
();
void
Write
(
Variable
<
char
>
&
variable
,
const
char
*
values
);
void
Write
(
Variable
<
unsigned
char
>
&
variable
,
const
unsigned
char
*
values
);
void
Write
(
Variable
<
short
>
&
variable
,
const
short
*
values
);
void
Write
(
Variable
<
unsigned
short
>
&
variable
,
const
unsigned
short
*
values
);
void
Write
(
Variable
<
int
>
&
variable
,
const
int
*
values
);
void
Write
(
Variable
<
unsigned
int
>
&
variable
,
const
unsigned
int
*
values
);
void
Write
(
Variable
<
long
int
>
&
variable
,
const
long
int
*
values
);
void
Write
(
Variable
<
unsigned
long
int
>
&
variable
,
const
unsigned
long
int
*
values
);
void
Write
(
Variable
<
long
long
int
>
&
variable
,
const
long
long
int
*
values
);
void
Write
(
Variable
<
unsigned
long
long
int
>
&
variable
,
const
unsigned
long
long
int
*
values
);
void
Write
(
Variable
<
float
>
&
variable
,
const
float
*
values
);
void
Write
(
Variable
<
double
>
&
variable
,
const
double
*
values
);
void
Write
(
Variable
<
long
double
>
&
variable
,
const
long
double
*
values
);
void
Write
(
Variable
<
std
::
complex
<
float
>>
&
variable
,
const
std
::
complex
<
float
>
*
values
);
void
Write
(
Variable
<
std
::
complex
<
double
>>
&
variable
,
const
std
::
complex
<
double
>
*
values
);
void
Write
(
Variable
<
std
::
complex
<
long
double
>>
&
variable
,
const
std
::
complex
<
long
double
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
char
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
char
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
short
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
short
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
unsigned
long
long
int
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
float
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
double
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
long
double
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
float
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
double
>
*
values
);
void
Write
(
const
std
::
string
variableName
,
const
std
::
complex
<
long
double
>
*
values
);
void
Close
(
const
int
transportIndex
=
-
1
);
private:
capsule
::
STLVector
m_Buffer
;
///< heap capsule, contains data and metadata buffers
capsule
::
STLVector
m_Buffer
;
///< heap capsule, contains data and metadata buffers
void
Init
();
void
clean
();
hid_t
_plist_id
,
_file_id
,
_dset_id
;
hid_t
_memspace
,
_filespace
;
hid_t
DefH5T_COMPLEX_DOUBLE
;
hid_t
DefH5T_COMPLEX_FLOAT
;
hid_t
DefH5T_COMPLEX_LongDOUBLE
;
void
Init
();
void
clean
();
hid_t
_plist_id
,
_file_id
,
_dset_id
;
hid_t
_memspace
,
_filespace
;
hid_t
DefH5T_COMPLEX_DOUBLE
;
hid_t
DefH5T_COMPLEX_FLOAT
;
hid_t
DefH5T_COMPLEX_LongDOUBLE
;
//hid_t DefH5T_filetype_COMPLEX_DOUBLE;
//hid_t DefH5T_filetype_COMPLEX_FLOAT;
//hid_t DefH5T_filetype_COMPLEX_LongDOUBLE;
template
<
class
T
>
void
UseHDFWrite
(
Variable
<
T
>
&
variable
,
const
T
*
values
,
hid_t
h5type
);
/*
template<class T>
void UseHDFWrite( Variable<T>& variable, const T* values, hid_t h5type )
{
//here comes your magic at Writing now variable.m_UserValues has the data
passed by the user
//set variable
variable.m_AppValues = values;
m_WrittenVariables.insert( variable.m_Name );
std::cout<<"writting : "<<variable.m_Name<<" dim
size:"<<variable.m_GlobalDimensions.size()<<std::endl;
int dimSize = variable.m_GlobalDimensions.size();
//hsize_t dimsf[dimSize], count[dimSize], offset[dimSize];
std::vector<hsize_t> dimsf, count, offset;
for(int i=0; i<dimSize; i++) {
dimsf.push_back(variable.m_GlobalDimensions[i]);
count.push_back(dimsf[i]);
offset.push_back(0);
}
count[0] = dimsf[0]/m_SizeMPI;
offset[0]= m_RankMPI*count[0];
_filespace = H5Screate_simple(dimSize, dimsf.data(), NULL);
_dset_id = H5Dcreate(_file_id, variable.m_Name.c_str(), h5type,
_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Sclose(_filespace);
_memspace = H5Screate_simple(dimSize, count.data(), NULL);
//Select hyperslab
_filespace = H5Dget_space(_dset_id);
H5Sselect_hyperslab(_filespace, H5S_SELECT_SET, offset.data(), NULL,
count.data(), NULL);
// Create property list for collective dataset write.
_plist_id = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(_plist_id, H5FD_MPIO_COLLECTIVE);
herr_t status;
if (m_SizeMPI == 1) {
status = H5Dwrite(_dset_id, h5type, _memspace, _filespace, _plist_id,
values);
} else {
std::vector<T> val;
for (int i=0; i<100; i++) {
//hsize_t c = count[i];
//hsize_t o = offset[i];
val.push_back(0);
}
status = H5Dwrite(_dset_id, h5type, _memspace, _filespace, _plist_id,
val.data());
}
if (status < 0) {
// error
std::cerr<<" Write failed. "<<std::endl;
}
std::cout <<" ==> User is responsible for freeing the data "<<std::endl;
//free(values);
//Close/release resources.
//H5Dclose(_dset_id);
//H5Sclose(_filespace);
//H5Sclose(_memspace);
//H5Pclose(_plist_id);
//H5Fclose(_file_id);
H5Dclose(_dset_id);
H5Sclose(_filespace);
H5Sclose(_memspace);
H5Pclose(_plist_id);
template
<
class
T
>
void
UseHDFWrite
(
Variable
<
T
>
&
variable
,
const
T
*
values
,
hid_t
h5type
);
}
*/
};
}
// end namespace adios
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment