Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
SWIFT
SWIFTsim
Commits
73636dd9
Commit
73636dd9
authored
6 years ago
by
Matthieu Schaller
Committed by
Matthieu Schaller
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Also add the new feature to the serial-io module.
parent
2fbd65cc
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!710
Snapshot offsets
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/common_io.c
+2
-7
2 additions, 7 deletions
src/common_io.c
src/parallel_io.c
+10
-5
10 additions, 5 deletions
src/parallel_io.c
src/serial_io.c
+25
-0
25 additions, 0 deletions
src/serial_io.c
src/single_io.c
+3
-1
3 additions, 1 deletion
src/single_io.c
with
40 additions
and
13 deletions
src/common_io.c
+
2
−
7
View file @
73636dd9
...
...
@@ -415,7 +415,6 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3],
offset_spart
[
0
]
=
0
;
/* Collect the cell information of *local* cells */
int
count_local_cells
=
0
;
long
long
local_offset_part
=
0
;
long
long
local_offset_gpart
=
0
;
long
long
local_offset_spart
=
0
;
...
...
@@ -443,8 +442,6 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3],
offset_gpart
[
i
]
=
local_offset_gpart
+
global_offsets
[
swift_type_dark_matter
];
offset_spart
[
i
]
=
local_offset_spart
+
global_offsets
[
swift_type_stars
];
++
count_local_cells
;
local_offset_part
+=
count_part
[
i
];
local_offset_gpart
+=
count_gpart
[
i
];
local_offset_spart
+=
count_spart
[
i
];
...
...
@@ -468,7 +465,7 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3],
}
#ifdef WITH_MPI
/* Now, reduce all the arrays. Note that we use a bit-
by-bit
OR here. This
/* Now, reduce all the arrays. Note that we use a bit-
wise
OR here. This
is safe as we made sure only local cells have non-zero values. */
if
(
nodeID
==
0
)
{
MPI_Reduce
(
MPI_IN_PLACE
,
count_part
,
nr_cells
,
MPI_LONG_LONG_INT
,
MPI_BOR
,
...
...
@@ -513,8 +510,7 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3],
0
,
MPI_COMM_WORLD
);
}
/* For the centres we use a sum as MPI does not like bitwise operations
/* For the centres we use a sum as MPI does not like bit-wise operations
on floating point numbers */
if
(
nodeID
==
0
)
{
MPI_Reduce
(
MPI_IN_PLACE
,
centres
,
3
*
nr_cells
,
MPI_DOUBLE
,
MPI_SUM
,
...
...
@@ -552,7 +548,6 @@ void io_write_cell_offsets(hid_t h_grp, const int cdim[3],
H5Dclose
(
h_data
);
H5Sclose
(
h_space
);
/* Group containing the offsets for each particle type */
h_subgrp
=
H5Gcreate
(
h_grp
,
"Offsets"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_subgrp
<
0
)
error
(
"Error while creating offsets sub-group"
);
...
...
This diff is collapsed.
Click to expand it.
src/parallel_io.c
+
10
−
5
View file @
73636dd9
...
...
@@ -1282,22 +1282,27 @@ void write_output_parallel(struct engine* e, const char* baseName,
snprintf
(
fileName
,
FILENAME_BUFFER_SIZE
,
"%s_%04i.hdf5"
,
baseName
,
e
->
snapshot_output_count
);
hid_t
h_file_cells
,
h_grp_cells
;
if
(
e
->
nodeID
==
0
)
{
/* Now write the top-level cell structure */
hid_t
h_file_cells
=
0
,
h_grp_cells
=
0
;
if
(
mpi_rank
==
0
)
{
/* Open the snapshot on rank 0 */
h_file_cells
=
H5Fopen
(
fileName
,
H5F_ACC_RDWR
,
H5P_DEFAULT
);
if
(
h_file_cells
<
0
)
error
(
"Error while opening file '%s' on rank %d."
,
fileName
,
mpi_rank
);
/* Create the group we want in the file */
h_grp_cells
=
H5Gcreate
(
h_file_cells
,
"/Cells"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp_cells
<
0
)
error
(
"Error while creating cells group"
);
}
else
{
h_file_cells
=
0
;
}
/* Write the location of the particles in the arrays */
io_write_cell_offsets
(
h_grp_cells
,
e
->
s
->
cdim
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
e
->
s
->
width
,
mpi_rank
,
N_total
,
offset
);
if
(
e
->
nodeID
==
0
)
{
/* Close everything */
if
(
mpi_rank
==
0
)
{
H5Gclose
(
h_grp_cells
);
H5Fclose
(
h_file_cells
);
}
...
...
This diff is collapsed.
Click to expand it.
src/serial_io.c
+
25
−
0
View file @
73636dd9
...
...
@@ -1028,6 +1028,31 @@ void write_output_serial(struct engine* e, const char* baseName,
H5Fclose
(
h_file
);
}
/* Now write the top-level cell structure */
hid_t
h_file_cells
=
0
,
h_grp_cells
=
0
;
if
(
mpi_rank
==
0
)
{
/* Open the snapshot on rank 0 */
h_file_cells
=
H5Fopen
(
fileName
,
H5F_ACC_RDWR
,
H5P_DEFAULT
);
if
(
h_file_cells
<
0
)
error
(
"Error while opening file '%s' on rank %d."
,
fileName
,
mpi_rank
);
/* Create the group we want in the file */
h_grp_cells
=
H5Gcreate
(
h_file_cells
,
"/Cells"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp_cells
<
0
)
error
(
"Error while creating cells group"
);
}
/* Write the location of the particles in the arrays */
io_write_cell_offsets
(
h_grp_cells
,
e
->
s
->
cdim
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
e
->
s
->
width
,
mpi_rank
,
N_total
,
offset
);
/* Close everything */
if
(
mpi_rank
==
0
)
{
H5Gclose
(
h_grp_cells
);
H5Fclose
(
h_file_cells
);
}
/* Now loop over ranks and write the data */
for
(
int
rank
=
0
;
rank
<
mpi_size
;
++
rank
)
{
...
...
This diff is collapsed.
Click to expand it.
src/single_io.c
+
3
−
1
View file @
73636dd9
...
...
@@ -826,10 +826,12 @@ void write_output_single(struct engine* e, const char* baseName,
/* Print the system of Units used internally */
io_write_unit_system
(
h_file
,
internal_units
,
"InternalCodeUnits"
);
/*
W
rite the
location of the particles in the arrays
*/
/*
Now w
rite the
top-level cell structure
*/
long
long
global_offsets
[
swift_type_count
]
=
{
0
};
h_grp
=
H5Gcreate
(
h_file
,
"/Cells"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
h_grp
<
0
)
error
(
"Error while creating cells group"
);
/* Write the location of the particles in the arrays */
io_write_cell_offsets
(
h_grp
,
e
->
s
->
cdim
,
e
->
s
->
cells_top
,
e
->
s
->
nr_cells
,
e
->
s
->
width
,
e
->
nodeID
,
N_total
,
global_offsets
);
H5Gclose
(
h_grp
);
...
...
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