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
68d962bc
Commit
68d962bc
authored
5 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Better function signatures in part.[ch]
parent
cc284833
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1001
Use the threadpool to parallelize operations in the particle-splitting code
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/engine_split_particles.c
+1
-1
1 addition, 1 deletion
src/engine_split_particles.c
src/part.c
+13
-11
13 additions, 11 deletions
src/part.c
src/part.h
+15
-13
15 additions, 13 deletions
src/part.h
src/swift.h
+1
-0
1 addition, 0 deletions
src/swift.h
with
30 additions
and
25 deletions
src/engine_split_particles.c
+
1
−
1
View file @
68d962bc
...
@@ -351,7 +351,7 @@ void engine_split_gas_particles(struct engine *e) {
...
@@ -351,7 +351,7 @@ void engine_split_gas_particles(struct engine *e) {
/* We now need to correct all the pointers of the other particle arrays */
/* We now need to correct all the pointers of the other particle arrays */
part_relink_all_parts_to_gparts
(
gparts_new
,
s
->
nr_gparts
,
s
->
parts
,
part_relink_all_parts_to_gparts
(
gparts_new
,
s
->
nr_gparts
,
s
->
parts
,
s
->
sparts
,
s
->
bparts
);
s
->
sparts
,
s
->
bparts
,
&
e
->
threadpool
);
s
->
gparts
=
gparts_new
;
s
->
gparts
=
gparts_new
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/part.c
+
13
−
11
View file @
68d962bc
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include
"error.h"
#include
"error.h"
#include
"hydro.h"
#include
"hydro.h"
#include
"part.h"
#include
"part.h"
#include
"threadpool.h"
/**
/**
* @brief Re-link the #gpart%s associated with the list of #part%s.
* @brief Re-link the #gpart%s associated with the list of #part%s.
...
@@ -40,8 +41,8 @@
...
@@ -40,8 +41,8 @@
* @param N The number of particles to re-link;
* @param N The number of particles to re-link;
* @param offset The offset of #part%s relative to the global parts list.
* @param offset The offset of #part%s relative to the global parts list.
*/
*/
void
part_relink_gparts_to_parts
(
struct
part
*
parts
,
size_t
N
,
void
part_relink_gparts_to_parts
(
struct
part
*
parts
,
const
size_t
N
,
ptrdiff_t
offset
)
{
const
ptrdiff_t
offset
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
parts
[
k
].
gpart
)
{
if
(
parts
[
k
].
gpart
)
{
parts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
parts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
...
@@ -56,8 +57,8 @@ void part_relink_gparts_to_parts(struct part *parts, size_t N,
...
@@ -56,8 +57,8 @@ void part_relink_gparts_to_parts(struct part *parts, size_t N,
* @param N The number of s-particles to re-link;
* @param N The number of s-particles to re-link;
* @param offset The offset of #spart%s relative to the global sparts list.
* @param offset The offset of #spart%s relative to the global sparts list.
*/
*/
void
part_relink_gparts_to_sparts
(
struct
spart
*
sparts
,
size_t
N
,
void
part_relink_gparts_to_sparts
(
struct
spart
*
sparts
,
const
size_t
N
,
ptrdiff_t
offset
)
{
const
ptrdiff_t
offset
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
sparts
[
k
].
gpart
)
{
if
(
sparts
[
k
].
gpart
)
{
sparts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
sparts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
...
@@ -72,8 +73,8 @@ void part_relink_gparts_to_sparts(struct spart *sparts, size_t N,
...
@@ -72,8 +73,8 @@ void part_relink_gparts_to_sparts(struct spart *sparts, size_t N,
* @param N The number of s-particles to re-link;
* @param N The number of s-particles to re-link;
* @param offset The offset of #bpart%s relative to the global bparts list.
* @param offset The offset of #bpart%s relative to the global bparts list.
*/
*/
void
part_relink_gparts_to_bparts
(
struct
bpart
*
bparts
,
size_t
N
,
void
part_relink_gparts_to_bparts
(
struct
bpart
*
bparts
,
const
size_t
N
,
ptrdiff_t
offset
)
{
const
ptrdiff_t
offset
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
bparts
[
k
].
gpart
)
{
if
(
bparts
[
k
].
gpart
)
{
bparts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
bparts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
offset
);
...
@@ -88,7 +89,7 @@ void part_relink_gparts_to_bparts(struct bpart *bparts, size_t N,
...
@@ -88,7 +89,7 @@ void part_relink_gparts_to_bparts(struct bpart *bparts, size_t N,
* @param N The number of particles to re-link;
* @param N The number of particles to re-link;
* @param parts The global #part array in which to find the #gpart offsets.
* @param parts The global #part array in which to find the #gpart offsets.
*/
*/
void
part_relink_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_parts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
part
*
parts
)
{
struct
part
*
parts
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
...
@@ -104,7 +105,7 @@ void part_relink_parts_to_gparts(struct gpart *gparts, size_t N,
...
@@ -104,7 +105,7 @@ void part_relink_parts_to_gparts(struct gpart *gparts, size_t N,
* @param N The number of particles to re-link;
* @param N The number of particles to re-link;
* @param sparts The global #spart array in which to find the #gpart offsets.
* @param sparts The global #spart array in which to find the #gpart offsets.
*/
*/
void
part_relink_sparts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_sparts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
spart
*
sparts
)
{
struct
spart
*
sparts
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gparts
[
k
].
type
==
swift_type_stars
)
{
if
(
gparts
[
k
].
type
==
swift_type_stars
)
{
...
@@ -120,7 +121,7 @@ void part_relink_sparts_to_gparts(struct gpart *gparts, size_t N,
...
@@ -120,7 +121,7 @@ void part_relink_sparts_to_gparts(struct gpart *gparts, size_t N,
* @param N The number of particles to re-link;
* @param N The number of particles to re-link;
* @param bparts The global #bpart array in which to find the #gpart offsets.
* @param bparts The global #bpart array in which to find the #gpart offsets.
*/
*/
void
part_relink_bparts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_bparts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
bpart
*
bparts
)
{
struct
bpart
*
bparts
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gparts
[
k
].
type
==
swift_type_black_hole
)
{
if
(
gparts
[
k
].
type
==
swift_type_black_hole
)
{
...
@@ -139,9 +140,10 @@ void part_relink_bparts_to_gparts(struct gpart *gparts, size_t N,
...
@@ -139,9 +140,10 @@ void part_relink_bparts_to_gparts(struct gpart *gparts, size_t N,
* @param sparts The global #spart array in which to find the #gpart offsets.
* @param sparts The global #spart array in which to find the #gpart offsets.
* @param bparts The global #bpart array in which to find the #gpart offsets.
* @param bparts The global #bpart array in which to find the #gpart offsets.
*/
*/
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
part
*
parts
,
struct
spart
*
sparts
,
struct
part
*
parts
,
struct
spart
*
sparts
,
struct
bpart
*
bparts
)
{
struct
bpart
*
bparts
,
struct
threadpool
*
tp
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
parts
[
-
gparts
[
k
].
id_or_neg_offset
].
gpart
=
&
gparts
[
k
];
parts
[
-
gparts
[
k
].
id_or_neg_offset
].
gpart
=
&
gparts
[
k
];
...
...
This diff is collapsed.
Click to expand it.
src/part.h
+
15
−
13
View file @
68d962bc
...
@@ -32,9 +32,10 @@
...
@@ -32,9 +32,10 @@
/* Local headers. */
/* Local headers. */
#include
"align.h"
#include
"align.h"
#include
"fof.h"
#include
"part_type.h"
#include
"part_type.h"
#include
"timeline.h"
/* Pre-declarations */
struct
threadpool
;
/* Some constants. */
/* Some constants. */
#define part_align 128
#define part_align 128
...
@@ -119,21 +120,22 @@
...
@@ -119,21 +120,22 @@
#error "Invalid choice of black hole particle"
#error "Invalid choice of black hole particle"
#endif
#endif
void
part_relink_gparts_to_parts
(
struct
part
*
parts
,
size_t
N
,
void
part_relink_gparts_to_parts
(
struct
part
*
parts
,
const
size_t
N
,
ptrdiff_t
offset
);
const
ptrdiff_t
offset
);
void
part_relink_gparts_to_sparts
(
struct
spart
*
sparts
,
size_t
N
,
void
part_relink_gparts_to_sparts
(
struct
spart
*
sparts
,
const
size_t
N
,
ptrdiff_t
offset
);
const
ptrdiff_t
offset
);
void
part_relink_gparts_to_bparts
(
struct
bpart
*
bparts
,
size_t
N
,
void
part_relink_gparts_to_bparts
(
struct
bpart
*
bparts
,
const
size_t
N
,
ptrdiff_t
offset
);
const
ptrdiff_t
offset
);
void
part_relink_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_parts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
part
*
parts
);
struct
part
*
parts
);
void
part_relink_sparts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_sparts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
spart
*
sparts
);
struct
spart
*
sparts
);
void
part_relink_bparts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_bparts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
bpart
*
bparts
);
struct
bpart
*
bparts
);
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
const
size_t
N
,
struct
part
*
parts
,
struct
spart
*
sparts
,
struct
part
*
parts
,
struct
spart
*
sparts
,
struct
bpart
*
bparts
);
struct
bpart
*
bparts
,
struct
threadpool
*
tp
);
void
part_verify_links
(
struct
part
*
parts
,
struct
gpart
*
gparts
,
void
part_verify_links
(
struct
part
*
parts
,
struct
gpart
*
gparts
,
struct
spart
*
sparts
,
struct
bpart
*
bparts
,
struct
spart
*
sparts
,
struct
bpart
*
bparts
,
size_t
nr_parts
,
size_t
nr_gparts
,
size_t
nr_sparts
,
size_t
nr_parts
,
size_t
nr_gparts
,
size_t
nr_sparts
,
...
...
This diff is collapsed.
Click to expand it.
src/swift.h
+
1
−
0
View file @
68d962bc
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include
"error.h"
#include
"error.h"
#include
"feedback.h"
#include
"feedback.h"
#include
"feedback_properties.h"
#include
"feedback_properties.h"
#include
"fof.h"
#include
"gravity.h"
#include
"gravity.h"
#include
"gravity_derivatives.h"
#include
"gravity_derivatives.h"
#include
"gravity_properties.h"
#include
"gravity_properties.h"
...
...
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