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
092c7de0
Commit
092c7de0
authored
6 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Store group masses using doubles instead of floats to retain precision.
parent
f32a6f5b
No related branches found
No related tags found
1 merge request
!543
Fof
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/fof.c
+17
-17
17 additions, 17 deletions
src/fof.c
src/fof.h
+1
-1
1 addition, 1 deletion
src/fof.h
src/space.h
+1
-1
1 addition, 1 deletion
src/space.h
with
19 additions
and
19 deletions
src/fof.c
+
17
−
17
View file @
092c7de0
...
@@ -645,7 +645,7 @@ void fof_search_tree_serial(struct space *s) {
...
@@ -645,7 +645,7 @@ void fof_search_tree_serial(struct space *s) {
long
long
*
group_id
;
long
long
*
group_id
;
int
*
group_index
;
int
*
group_index
;
int
*
group_size
;
int
*
group_size
;
float
*
group_mass
;
double
*
group_mass
;
int
num_groups
=
0
;
int
num_groups
=
0
;
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
search_r2
=
s
->
l_x2
;
const
double
search_r2
=
s
->
l_x2
;
...
@@ -678,11 +678,11 @@ void fof_search_tree_serial(struct space *s) {
...
@@ -678,11 +678,11 @@ void fof_search_tree_serial(struct space *s) {
error
(
"Failed to allocate list of group size for FOF search."
);
error
(
"Failed to allocate list of group size for FOF search."
);
/* Allocate and initialise a group mass array. */
/* Allocate and initialise a group mass array. */
if
(
posix_memalign
((
void
**
)
&
group_mass
,
32
,
nr_gparts
*
sizeof
(
float
))
!=
0
)
if
(
posix_memalign
((
void
**
)
&
group_mass
,
32
,
nr_gparts
*
sizeof
(
double
))
!=
0
)
error
(
"Failed to allocate list of group masses for FOF search."
);
error
(
"Failed to allocate list of group masses for FOF search."
);
bzero
(
group_size
,
nr_gparts
*
sizeof
(
int
));
bzero
(
group_size
,
nr_gparts
*
sizeof
(
int
));
bzero
(
group_mass
,
nr_gparts
*
sizeof
(
float
));
bzero
(
group_mass
,
nr_gparts
*
sizeof
(
double
));
/* Loop over cells and find which cells are in range of each other to perform
/* Loop over cells and find which cells are in range of each other to perform
* the FOF search. */
* the FOF search. */
...
@@ -730,7 +730,7 @@ void fof_search_tree_serial(struct space *s) {
...
@@ -730,7 +730,7 @@ void fof_search_tree_serial(struct space *s) {
int
num_parts_in_groups
=
0
;
int
num_parts_in_groups
=
0
;
int
max_group_size
=
0
,
max_group_index
=
0
,
max_group_mass_id
=
0
;
int
max_group_size
=
0
,
max_group_index
=
0
,
max_group_mass_id
=
0
;
float
max_group_mass
=
0
;
double
max_group_mass
=
0
;
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
/* Find the total number of particles in groups. */
/* Find the total number of particles in groups. */
...
@@ -754,7 +754,7 @@ void fof_search_tree_serial(struct space *s) {
...
@@ -754,7 +754,7 @@ void fof_search_tree_serial(struct space *s) {
"in groups: %zu."
,
"in groups: %zu."
,
num_groups
,
num_parts_in_groups
,
nr_gparts
-
num_parts_in_groups
);
num_groups
,
num_parts_in_groups
,
nr_gparts
-
num_parts_in_groups
);
message
(
"Biggest group size: %d with ID: %d"
,
max_group_size
,
max_group_index
);
message
(
"Biggest group size: %d with ID: %d"
,
max_group_size
,
max_group_index
);
message
(
"Biggest group by mass: %
f
with ID: %d"
,
max_group_mass
,
max_group_mass_id
);
message
(
"Biggest group by mass: %
e
with ID: %d"
,
max_group_mass
,
max_group_mass_id
);
free
(
group_size
);
free
(
group_size
);
free
(
group_mass
);
free
(
group_mass
);
...
@@ -832,7 +832,7 @@ void fof_search_foreign_cells(struct space *s) {
...
@@ -832,7 +832,7 @@ void fof_search_foreign_cells(struct space *s) {
struct
cell
*
cells
=
s
->
cells_top
;
struct
cell
*
cells
=
s
->
cells_top
;
int
*
group_index
=
s
->
fof_data
.
group_index
;
int
*
group_index
=
s
->
fof_data
.
group_index
;
int
*
group_size
=
s
->
fof_data
.
group_size
;
int
*
group_size
=
s
->
fof_data
.
group_size
;
float
*
group_mass
=
s
->
fof_data
.
group_mass
;
double
*
group_mass
=
s
->
fof_data
.
group_mass
;
const
int
nr_gparts
=
s
->
nr_gparts
;
const
int
nr_gparts
=
s
->
nr_gparts
;
const
size_t
nr_cells
=
s
->
nr_cells
;
const
size_t
nr_cells
=
s
->
nr_cells
;
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
...
@@ -1064,7 +1064,7 @@ void fof_search_foreign_cells(struct space *s) {
...
@@ -1064,7 +1064,7 @@ void fof_search_foreign_cells(struct space *s) {
/* Transform the group IDs to a local list going from 0-group_count so a union-find can be performed. */
/* Transform the group IDs to a local list going from 0-group_count so a union-find can be performed. */
int
*
global_group_index
=
NULL
,
*
global_group_id
=
NULL
,
*
global_group_size
=
NULL
;
int
*
global_group_index
=
NULL
,
*
global_group_id
=
NULL
,
*
global_group_size
=
NULL
;
float
*
global_group_mass
=
NULL
;
double
*
global_group_mass
=
NULL
;
int
group_count
=
0
;
int
group_count
=
0
;
if
(
posix_memalign
((
void
**
)
&
global_group_index
,
SWIFT_STRUCT_ALIGNMENT
,
if
(
posix_memalign
((
void
**
)
&
global_group_index
,
SWIFT_STRUCT_ALIGNMENT
,
...
@@ -1080,11 +1080,11 @@ void fof_search_foreign_cells(struct space *s) {
...
@@ -1080,11 +1080,11 @@ void fof_search_foreign_cells(struct space *s) {
error
(
"Error while allocating memory for the displacement in memory for the global group link list"
);
error
(
"Error while allocating memory for the displacement in memory for the global group link list"
);
if
(
posix_memalign
((
void
**
)
&
global_group_mass
,
SWIFT_STRUCT_ALIGNMENT
,
if
(
posix_memalign
((
void
**
)
&
global_group_mass
,
SWIFT_STRUCT_ALIGNMENT
,
global_group_link_count
*
sizeof
(
int
))
!=
0
)
global_group_link_count
*
sizeof
(
double
))
!=
0
)
error
(
"Error while allocating memory for the displacement in memory for the global group link list"
);
error
(
"Error while allocating memory for the displacement in memory for the global group link list"
);
bzero
(
global_group_size
,
global_group_link_count
*
sizeof
(
int
));
bzero
(
global_group_size
,
global_group_link_count
*
sizeof
(
int
));
bzero
(
global_group_mass
,
global_group_link_count
*
sizeof
(
float
));
bzero
(
global_group_mass
,
global_group_link_count
*
sizeof
(
double
));
/* Compress the list of group links across an MPI domain by removing the symmetric cases. */
/* Compress the list of group links across an MPI domain by removing the symmetric cases. */
/* Store each group ID once along with its size. */
/* Store each group ID once along with its size. */
...
@@ -1233,9 +1233,9 @@ void fof_search_tree(struct space *s) {
...
@@ -1233,9 +1233,9 @@ void fof_search_tree(struct space *s) {
struct
gpart
*
gparts
=
s
->
gparts
;
struct
gpart
*
gparts
=
s
->
gparts
;
long
long
*
group_id
;
long
long
*
group_id
;
int
*
group_index
,
*
group_size
;
int
*
group_index
,
*
group_size
;
float
*
group_mass
;
double
*
group_mass
;
int
num_groups
=
0
,
num_parts_in_groups
=
0
,
max_group_size
=
0
;
int
num_groups
=
0
,
num_parts_in_groups
=
0
,
max_group_size
=
0
;
float
max_group_mass
=
0
;
double
max_group_mass
=
0
;
ticks
tic
=
getticks
();
ticks
tic
=
getticks
();
char
output_file_name
[
FILENAME_BUFFER_SIZE
];
char
output_file_name
[
FILENAME_BUFFER_SIZE
];
...
@@ -1292,7 +1292,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1292,7 +1292,7 @@ void fof_search_tree(struct space *s) {
error
(
"Failed to allocate list of particle group IDs for FOF search."
);
error
(
"Failed to allocate list of particle group IDs for FOF search."
);
/* Allocate and initialise a group mass array. */
/* Allocate and initialise a group mass array. */
if
(
posix_memalign
((
void
**
)
&
s
->
fof_data
.
group_mass
,
32
,
nr_gparts
*
sizeof
(
float
))
!=
0
)
if
(
posix_memalign
((
void
**
)
&
s
->
fof_data
.
group_mass
,
32
,
nr_gparts
*
sizeof
(
double
))
!=
0
)
error
(
"Failed to allocate list of group masses for FOF search."
);
error
(
"Failed to allocate list of group masses for FOF search."
);
/* Initial group ID is particle offset into array. */
/* Initial group ID is particle offset into array. */
...
@@ -1307,7 +1307,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1307,7 +1307,7 @@ void fof_search_tree(struct space *s) {
message
(
"Rank: %d, Allocated group_index array of size %zu"
,
engine_rank
,
s
->
nr_gparts
);
message
(
"Rank: %d, Allocated group_index array of size %zu"
,
engine_rank
,
s
->
nr_gparts
);
bzero
(
group_size
,
nr_gparts
*
sizeof
(
int
));
bzero
(
group_size
,
nr_gparts
*
sizeof
(
int
));
bzero
(
group_mass
,
nr_gparts
*
sizeof
(
float
));
bzero
(
group_mass
,
nr_gparts
*
sizeof
(
double
));
/* Activate all the regular tasks */
/* Activate all the regular tasks */
threadpool_map
(
&
s
->
e
->
threadpool
,
fof_search_tree_mapper
,
s
->
cells_top
,
threadpool_map
(
&
s
->
e
->
threadpool
,
fof_search_tree_mapper
,
s
->
cells_top
,
...
@@ -1337,7 +1337,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1337,7 +1337,7 @@ void fof_search_tree(struct space *s) {
group_size
,
group_id
,
group_mass
,
min_group_size
);
group_size
,
group_id
,
group_mass
,
min_group_size
);
int
num_groups_local
=
0
,
num_parts_in_groups_local
=
0
,
max_group_size_local
=
0
;
int
num_groups_local
=
0
,
num_parts_in_groups_local
=
0
,
max_group_size_local
=
0
;
float
max_group_mass_local
=
0
;
double
max_group_mass_local
=
0
;
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
...
@@ -1359,7 +1359,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1359,7 +1359,7 @@ void fof_search_tree(struct space *s) {
MPI_Reduce
(
&
num_groups_local
,
&
num_groups
,
1
,
MPI_INT
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
num_groups_local
,
&
num_groups
,
1
,
MPI_INT
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
num_parts_in_groups_local
,
&
num_parts_in_groups
,
1
,
MPI_INT
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
num_parts_in_groups_local
,
&
num_parts_in_groups
,
1
,
MPI_INT
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
max_group_size_local
,
&
max_group_size
,
1
,
MPI_INT
,
MPI_MAX
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
max_group_size_local
,
&
max_group_size
,
1
,
MPI_INT
,
MPI_MAX
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
max_group_mass_local
,
&
max_group_mass
,
1
,
MPI_
FLOAT
,
MPI_MAX
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
&
max_group_mass_local
,
&
max_group_mass
,
1
,
MPI_
DOUBLE
,
MPI_MAX
,
0
,
MPI_COMM_WORLD
);
#else
#else
num_groups
+=
num_groups_local
;
num_groups
+=
num_groups_local
;
num_parts_in_groups
+=
num_parts_in_groups_local
;
num_parts_in_groups
+=
num_parts_in_groups_local
;
...
@@ -1374,7 +1374,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1374,7 +1374,7 @@ void fof_search_tree(struct space *s) {
num_groups
,
num_parts_in_groups
,
s
->
e
->
total_nr_gparts
-
num_parts_in_groups
);
num_groups
,
num_parts_in_groups
,
s
->
e
->
total_nr_gparts
-
num_parts_in_groups
);
message
(
"Largest group by size: %d"
,
max_group_size
);
message
(
"Largest group by size: %d"
,
max_group_size
);
message
(
"Largest group by mass: %
f
"
,
max_group_mass
);
message
(
"Largest group by mass: %
e
"
,
max_group_mass
);
message
(
"FOF search took: %.3f %s."
,
message
(
"FOF search took: %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
...
@@ -1384,7 +1384,7 @@ void fof_search_tree(struct space *s) {
...
@@ -1384,7 +1384,7 @@ void fof_search_tree(struct space *s) {
/* Dump FOF group data. */
/* Dump FOF group data. */
void
fof_dump_group_data
(
char
*
out_file
,
const
size_t
nr_gparts
,
int
*
group_index
,
void
fof_dump_group_data
(
char
*
out_file
,
const
size_t
nr_gparts
,
int
*
group_index
,
int
*
group_size
,
long
long
*
group_id
,
float
*
group_mass
,
const
int
min_group_size
)
{
int
*
group_size
,
long
long
*
group_id
,
double
*
group_mass
,
const
int
min_group_size
)
{
FILE
*
file
=
fopen
(
out_file
,
"w"
);
FILE
*
file
=
fopen
(
out_file
,
"w"
);
fprintf
(
file
,
"# %7s %7s %7s %7s %7s
\n
"
,
"ID"
,
"Root ID"
,
"Group Size"
,
"Group Mass"
,
"Group ID"
);
fprintf
(
file
,
"# %7s %7s %7s %7s %7s
\n
"
,
"ID"
,
"Root ID"
,
"Group Size"
,
"Group Mass"
,
"Group ID"
);
...
...
This diff is collapsed.
Click to expand it.
src/fof.h
+
1
−
1
View file @
092c7de0
...
@@ -52,7 +52,7 @@ void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj);
...
@@ -52,7 +52,7 @@ void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj);
void
fof_search_pair_cells_foreign
(
struct
space
*
s
,
struct
cell
*
ci
,
struct
cell
*
cj
,
size_t
*
link_count
,
struct
fof_mpi
*
part_links
);
void
fof_search_pair_cells_foreign
(
struct
space
*
s
,
struct
cell
*
ci
,
struct
cell
*
cj
,
size_t
*
link_count
,
struct
fof_mpi
*
part_links
);
void
fof_search_tree_serial
(
struct
space
*
s
);
void
fof_search_tree_serial
(
struct
space
*
s
);
void
fof_search_tree
(
struct
space
*
s
);
void
fof_search_tree
(
struct
space
*
s
);
void
fof_dump_group_data
(
char
*
out_file
,
const
size_t
nr_gparts
,
int
*
group_index
,
int
*
num_in_groups
,
long
long
*
group_id
,
float
*
group_mass
,
const
int
min_group_size
);
void
fof_dump_group_data
(
char
*
out_file
,
const
size_t
nr_gparts
,
int
*
group_index
,
int
*
num_in_groups
,
long
long
*
group_id
,
double
*
group_mass
,
const
int
min_group_size
);
#ifdef WITH_MPI
#ifdef WITH_MPI
/* MPI data type for the particle transfers */
/* MPI data type for the particle transfers */
...
...
This diff is collapsed.
Click to expand it.
src/space.h
+
1
−
1
View file @
092c7de0
...
@@ -46,7 +46,7 @@ struct fof {
...
@@ -46,7 +46,7 @@ struct fof {
long
long
*
group_id
;
long
long
*
group_id
;
int
*
group_index
;
int
*
group_index
;
int
*
group_size
;
int
*
group_size
;
float
*
group_mass
;
double
*
group_mass
;
int
min_group_size
;
int
min_group_size
;
char
base_name
[
PARSER_MAX_LINE_SIZE
];
char
base_name
[
PARSER_MAX_LINE_SIZE
];
...
...
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