Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Minimal Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Tobias Meisel
Minimal Examples
Merge requests
!1
Couldn't fetch the linked file.
HDF5 minimal example
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
HDF5 minimal example
without_odds
into
main
Overview
0
Commits
11
Pipelines
0
Changes
1
Merged
Tobias Meisel
requested to merge
without_odds
into
main
3 years ago
Overview
0
Commits
11
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
e7e835d9
Prev
Next
Show latest version
1 file
+
9
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
e7e835d9
parallel write
· e7e835d9
Tobias Meisel
authored
3 years ago
hdf5.cpp
+
9
−
9
Options
@@ -13,11 +13,15 @@
#include
<iostream>
#include
<vector>
const
hsize_t
CHUNK_SIZE
=
314
;
int
main
(
int
argc
,
char
**
argv
)
{
MPI_Init
(
&
argc
,
&
argv
);
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
std
::
cout
<<
argv
[
i
]
<<
"
\n
"
;
int
data_length
=
std
::
atoi
(
argv
[
1
]);
int
comm_size
,
comm_rank
;
assert
(
MPI_SUCCESS
==
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
comm_size
));
assert
(
MPI_SUCCESS
==
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
comm_rank
));
@@ -30,21 +34,21 @@ int main(int argc, char** argv)
// Let's create some sample data!
// MPI ranks have (100 + rank) integers worth of data
std
::
vector
<
int
>
v
(
100
+
comm_rank
,
comm_rank
);
std
::
vector
<
int
>
v
(
data_length
,
comm_rank
+
1
);
// The extent of the dataspace in the file can be computed accordingly.
hsize_t
size
=
100
*
comm_size
+
comm_size
*
(
comm_size
-
1
)
/
2
;
hsize_t
size
=
data_length
*
comm_size
;
//
+ comm_size*(comm_size-1)/2;
printf
(
"Size %d"
,
size
);
// Make a dataset!
// I can't believe that takes 10 lines of code :-(
hsize_t
infty
=
406
;
hsize_t
infty
=
H5S_UNLIMITED
;
;
hid_t
fspace
=
H5Screate_simple
(
1
,
&
size
,
&
infty
);
assert
(
fspace
>=
0
);
hid_t
dcpl
=
H5Pcreate
(
H5P_DATASET_CREATE
);
assert
(
dcpl
>=
0
);
//
assert(H5Pset_chunk(dcpl, 1, &CHUNK_SIZE) >= 0);
assert
(
H5Pset_chunk
(
dcpl
,
1
,
&
CHUNK_SIZE
)
>=
0
);
hid_t
dset
=
H5Dcreate
(
file
,
"1D"
,
H5T_STD_I32LE
,
fspace
,
H5P_DEFAULT
,
dcpl
,
H5P_DEFAULT
);
assert
(
dset
>=
0
);
@@ -55,17 +59,13 @@ int main(int argc, char** argv)
hid_t
mspace
=
H5Screate_simple
(
1
,
&
blk
,
NULL
);
assert
(
H5Sselect_all
(
mspace
)
>=
0
);
offset
=
comm_rank
/
2
*
100
+
(
comm_rank
-
1
)
/
2
*
((
comm_rank
-
1
)
/
2
+
1
);
offset
=
comm_rank
*
100
;
//+(comm_rank)*(comm_rank-1)/2;
offset
=
(
comm_rank
)
*
data_length
;
//+comm_rank;
printf
(
"offset %d of rank %d
\n
"
,
offset
,
comm_rank
);
assert
(
H5Sselect_hyperslab
(
fspace
,
H5S_SELECT_SET
,
&
offset
,
NULL
,
&
one
,
&
blk
)
>=
0
);
assert
(
H5Sselect_all
(
mspace
)
>=
0
);
offset
=
comm_rank
*
100
;
assert
(
H5Sselect_hyperslab
(
fspace
,
H5S_SELECT_SET
,
&
offset
,
NULL
,
&
one
,
&
blk
)
>=
0
);
Loading