Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
6b54b8db
Commit
6b54b8db
authored
Jul 11, 2016
by
Matthieu Schaller
Browse files
New i/o infrastructure now also for parallel writes
parent
856ed10d
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
6b54b8db
...
...
@@ -336,9 +336,9 @@ int main(int argc, char *argv[]) {
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
#if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5)
read_ic_parallel
(
ICfileName
,
dim
,
&
parts
,
&
gparts
,
&
Ngas
,
&
Ngpart
,
&
periodic
,
&
flag_entropy_ICs
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
,
dry_run
);
read_ic_parallel
(
ICfileName
,
&
us
,
dim
,
&
parts
,
&
gparts
,
&
Ngas
,
&
Ngpart
,
&
periodic
,
&
flag_entropy_ICs
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
,
dry_run
);
#else
read_ic_serial
(
ICfileName
,
dim
,
&
parts
,
&
gparts
,
&
Ngas
,
&
Ngpart
,
&
periodic
,
&
flag_entropy_ICs
,
myrank
,
nr_nodes
,
MPI_COMM_WORLD
,
...
...
src/engine.c
View file @
6b54b8db
...
...
@@ -2672,8 +2672,9 @@ void engine_dump_snapshot(struct engine *e) {
/* Dump... */
#if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5)
write_output_parallel
(
e
,
e
->
snapshotBaseName
,
e
->
snapshotUnits
,
e
->
nodeID
,
e
->
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
);
write_output_parallel
(
e
,
e
->
snapshotBaseName
,
e
->
internalUnits
,
e
->
snapshotUnits
,
e
->
nodeID
,
e
->
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
);
#else
write_output_serial
(
e
,
e
->
snapshotBaseName
,
e
->
snapshotUnits
,
e
->
nodeID
,
e
->
nr_nodes
,
MPI_COMM_WORLD
,
MPI_INFO_NULL
);
...
...
src/parallel_io.c
View file @
6b54b8db
This diff is collapsed.
Click to expand it.
src/parallel_io.h
View file @
6b54b8db
...
...
@@ -34,15 +34,17 @@
#if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5)
void
read_ic_parallel
(
char
*
fileName
,
double
dim
[
3
],
struct
part
**
parts
,
struct
gpart
**
gparts
,
size_t
*
Ngas
,
size_t
*
Ngparts
,
int
*
periodic
,
int
*
flag_entropy
,
int
mpi_rank
,
int
mpi_size
,
MPI_Comm
comm
,
MPI_Info
info
,
int
dry_run
);
void
read_ic_parallel
(
char
*
fileName
,
const
struct
UnitSystem
*
internal_units
,
double
dim
[
3
],
struct
part
**
parts
,
struct
gpart
**
gparts
,
size_t
*
Ngas
,
size_t
*
Ngparts
,
int
*
periodic
,
int
*
flag_entropy
,
int
mpi_rank
,
int
mpi_size
,
MPI_Comm
comm
,
MPI_Info
info
,
int
dry_run
);
void
write_output_parallel
(
struct
engine
*
e
,
const
char
*
baseName
,
struct
UnitSystem
*
us
,
int
mpi_rank
,
int
mpi_size
,
MPI_Comm
comm
,
MPI_Info
info
);
const
struct
UnitSystem
*
internal_units
,
const
struct
UnitSystem
*
snapshot_units
,
int
mpi_rank
,
int
mpi_size
,
MPI_Comm
comm
,
MPI_Info
info
);
#endif
#endif
/* SWIFT_PARALLEL_IO_H */
src/single_io.c
View file @
6b54b8db
...
...
@@ -81,7 +81,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
/* message("Optional data set '%s' not present. Zeroing this particle
* prop...", name); */
for
(
in
t
i
=
0
;
i
<
N
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
N
;
++
i
)
memset
(
prop
.
field
+
i
*
prop
.
partSize
,
0
,
copySize
);
return
;
...
...
@@ -126,16 +126,16 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
if
(
isDoublePrecision
(
prop
.
type
))
{
double
*
temp_d
=
temp
;
for
(
in
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_d
[
i
]
*=
factor
;
for
(
size_
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_d
[
i
]
*=
factor
;
}
else
{
float
*
temp_f
=
temp
;
for
(
in
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_f
[
i
]
*=
factor
;
for
(
size_
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_f
[
i
]
*=
factor
;
}
}
/* Copy temporary buffer to particle data */
char
*
temp_c
=
temp
;
for
(
in
t
i
=
0
;
i
<
N
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
N
;
++
i
)
memcpy
(
prop
.
field
+
i
*
prop
.
partSize
,
&
temp_c
[
i
*
copySize
],
copySize
);
/* Free and close everything */
...
...
@@ -162,8 +162,7 @@ void readArray(hid_t h_grp, const struct io_props prop, size_t N,
* @param snapshot_units The #UnitSystem used in the snapshots
*
* @todo A better version using HDF5 hyper-slabs to write the file directly from
* the part array
* will be written once the structures have been stabilized.
* the part array will be written once the structures have been stabilized.
*/
void
writeArray
(
hid_t
grp
,
char
*
fileName
,
FILE
*
xmfFile
,
char
*
partTypeGroupName
,
const
struct
io_props
props
,
size_t
N
,
...
...
@@ -182,7 +181,7 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
/* Copy particle data to temporary buffer */
char
*
temp_c
=
temp
;
for
(
in
t
i
=
0
;
i
<
N
;
++
i
)
for
(
size_
t
i
=
0
;
i
<
N
;
++
i
)
memcpy
(
&
temp_c
[
i
*
copySize
],
props
.
field
+
i
*
props
.
partSize
,
copySize
);
/* Unit conversion if necessary */
...
...
@@ -194,10 +193,10 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
if
(
isDoublePrecision
(
props
.
type
))
{
double
*
temp_d
=
temp
;
for
(
in
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_d
[
i
]
*=
factor
;
for
(
size_
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_d
[
i
]
*=
factor
;
}
else
{
float
*
temp_f
=
temp
;
for
(
in
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_f
[
i
]
*=
factor
;
for
(
size_
t
i
=
0
;
i
<
num_elements
;
++
i
)
temp_f
[
i
]
*=
factor
;
}
}
...
...
@@ -297,7 +296,8 @@ void writeArray(hid_t grp, char* fileName, FILE* xmfFile,
* @param Ngas (output) number of Gas particles read.
* @param Ngparts (output) The number of #gpart read.
* @param periodic (output) 1 if the volume is periodic, 0 if not.
* @param flag_entropy 1 if the ICs contained Entropy in the InternalEnergy
* @param flag_entropy (output) 1 if the ICs contained Entropy in the
* InternalEnergy
* field
* @param dry_run If 1, don't read the particle. Only allocates the arrays.
*
...
...
@@ -366,7 +366,7 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units,
/* Close header */
H5Gclose
(
h_grp
);
/* Read the unit system used in the
snapshot
s */
/* Read the unit system used in the
IC
s */
struct
UnitSystem
*
ic_units
=
malloc
(
sizeof
(
struct
UnitSystem
));
if
(
ic_units
==
NULL
)
error
(
"Unable to allocate memory for IC unit system"
);
readUnitSystem
(
h_file
,
ic_units
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment