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
60e68c9e
Commit
60e68c9e
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Use the threadpool to initialise the FOF properties of particles.
parent
cb549641
No related branches found
No related tags found
1 merge request
!930
Parco 2019 debug
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fof.c
+47
-17
47 additions, 17 deletions
src/fof.c
with
47 additions
and
17 deletions
src/fof.c
+
47
−
17
View file @
60e68c9e
...
...
@@ -178,6 +178,39 @@ void fof_create_mpi_types() {
#endif
}
void
fof_set_initial_group_index_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
)
{
size_t
*
group_index
=
(
size_t
*
)
map_data
;
size_t
*
group_index_start
=
(
size_t
*
)
extra_data
;
const
ptrdiff_t
offset
=
group_index
-
group_index_start
;
for
(
int
i
=
0
;
i
<
num_elements
;
++
i
)
{
group_index
[
i
]
=
i
+
offset
;
}
}
void
fof_set_initial_group_size_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
)
{
size_t
*
group_size
=
(
size_t
*
)
map_data
;
for
(
int
i
=
0
;
i
<
num_elements
;
++
i
)
{
group_size
[
i
]
=
1
;
}
}
void
fof_set_initial_group_id_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
)
{
/* Unpack the information */
struct
gpart
*
gparts
=
(
struct
gpart
*
)
map_data
;
const
size_t
group_id_default
=
*
((
size_t
*
)
extra_data
);
for
(
int
i
=
0
;
i
<
num_elements
;
++
i
)
{
gparts
[
i
].
group_id
=
group_id_default
;
}
}
/**
* @brief Allocate the memory and initialise the arrays for a FOF calculation.
*
...
...
@@ -223,32 +256,29 @@ void fof_allocate(const struct space *s, const long long total_nr_DM_particles,
"check more than one layer of top-level cells for links."
);
#endif
const
size_t
nr_local_gparts
=
s
->
nr_gparts
;
struct
gpart
*
gparts
=
s
->
gparts
;
/* Allocate and initialise a group index array. */
if
(
swift_memalign
(
"fof_group_index"
,
(
void
**
)
&
props
->
group_index
,
64
,
nr_local
_gparts
*
sizeof
(
size_t
))
!=
0
)
s
->
nr
_gparts
*
sizeof
(
size_t
))
!=
0
)
error
(
"Failed to allocate list of particle group indices for FOF search."
);
/* Allocate and initialise a group size array. */
if
(
swift_memalign
(
"fof_group_size"
,
(
void
**
)
&
props
->
group_size
,
64
,
nr_local
_gparts
*
sizeof
(
size_t
))
!=
0
)
s
->
nr
_gparts
*
sizeof
(
size_t
))
!=
0
)
error
(
"Failed to allocate list of group size for FOF search."
);
/* Set initial group ID of the gparts */
const
size_t
group_id_default
=
props
->
group_id_default
;
for
(
size_t
i
=
0
;
i
<
nr_local_gparts
;
i
++
)
{
gparts
[
i
].
group_id
=
group_id_default
;
}
/* S
et
initial
group
index
and group size */
size_t
*
group_index
=
props
->
group_index
;
size_t
*
group_size
=
props
->
group_
size
;
for
(
size_t
i
=
0
;
i
<
nr_local_gparts
;
i
++
)
{
group_index
[
i
]
=
i
;
group_size
[
i
]
=
1
;
}
size_t
group_id_default
=
props
->
group_id_default
;
threadpool_map
(
&
s
->
e
->
threadpool
,
fof_set_initial_group_id_mapper
,
s
->
parts
,
s
->
nr_gparts
,
sizeof
(
struct
gpart
),
0
,
&
group_id_default
)
;
/* Set initial group index */
threadpool_map
(
&
s
->
e
->
threadpool
,
fof_s
et
_
initial
_
group
_
index
_mapper
,
props
->
group_index
,
s
->
nr_gparts
,
sizeof
(
size_t
),
0
,
props
->
group_
index
)
;
/* Set initial group sizes */
threadpool_map
(
&
s
->
e
->
threadpool
,
fof_set_initial_
group_size
_mapper
,
props
->
group_size
,
s
->
nr_gparts
,
sizeof
(
size_t
),
0
,
NULL
);
#ifdef SWIFT_DEBUG_CHECKS
ti_current
=
s
->
e
->
ti_current
;
...
...
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