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
c235205c
Commit
c235205c
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Tighter condition for active particles/cells. Also inline the call to cell_is_drift_needed()
parent
57f6561d
No related branches found
No related tags found
1 merge request
!279
Improve readability of active/inactive condition
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/active.h
+61
-4
61 additions, 4 deletions
src/active.h
src/cell.c
+0
-29
0 additions, 29 deletions
src/cell.c
src/cell.h
+0
-1
0 additions, 1 deletion
src/cell.h
src/runner.c
+8
-6
8 additions, 6 deletions
src/runner.c
src/statistics.c
+1
-1
1 addition, 1 deletion
src/statistics.c
with
70 additions
and
41 deletions
src/active.h
+
61
−
4
View file @
c235205c
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
/* Local includes. */
/* Local includes. */
#include
"cell.h"
#include
"cell.h"
#include
"const.h"
#include
"engine.h"
#include
"engine.h"
#include
"part.h"
#include
"part.h"
...
@@ -36,7 +37,13 @@
...
@@ -36,7 +37,13 @@
__attribute__
((
always_inline
))
INLINE
static
int
cell_is_active
(
__attribute__
((
always_inline
))
INLINE
static
int
cell_is_active
(
const
struct
cell
*
c
,
const
struct
engine
*
e
)
{
const
struct
cell
*
c
,
const
struct
engine
*
e
)
{
return
(
c
->
ti_end_min
<=
e
->
ti_current
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
c
->
ti_end_min
<
e
->
ti_current
)
error
(
"cell in an impossible time-zone! c->ti_end_min=%d e->ti_current=%d"
,
c
->
ti_end_min
,
e
->
ti_current
);
#endif
return
(
c
->
ti_end_min
==
e
->
ti_current
);
}
}
/**
/**
...
@@ -48,9 +55,46 @@ __attribute__((always_inline)) INLINE static int cell_is_active(
...
@@ -48,9 +55,46 @@ __attribute__((always_inline)) INLINE static int cell_is_active(
__attribute__
((
always_inline
))
INLINE
static
int
cell_is_all_active
(
__attribute__
((
always_inline
))
INLINE
static
int
cell_is_all_active
(
const
struct
cell
*
c
,
const
struct
engine
*
e
)
{
const
struct
cell
*
c
,
const
struct
engine
*
e
)
{
return
(
c
->
ti_end_max
<=
e
->
ti_current
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
c
->
ti_end_max
<
e
->
ti_current
)
error
(
"cell in an impossible time-zone! c->ti_end_max=%d e->ti_current=%d"
,
c
->
ti_end_max
,
e
->
ti_current
);
#endif
return
(
c
->
ti_end_max
==
e
->
ti_current
);
}
}
/**
* @brief Checks whether a given cell needs drifting or not.
*
* @param c the #cell.
* @param e The #engine (holding current time information).
*
* @return 1 If the cell needs drifting, 0 otherwise.
*/
INLINE
static
int
cell_is_drift_needed
(
struct
cell
*
c
,
const
struct
engine
*
e
)
{
/* Do we have at least one active particle in the cell ?*/
if
(
cell_is_active
(
c
,
e
))
return
1
;
/* Loop over the pair tasks that involve this cell */
for
(
struct
link
*
l
=
c
->
density
;
l
!=
NULL
;
l
=
l
->
next
)
{
if
(
l
->
t
->
type
!=
task_type_pair
&&
l
->
t
->
type
!=
task_type_sub_pair
)
continue
;
/* Is the other cell in the pair active ? */
if
((
l
->
t
->
ci
==
c
&&
cell_is_active
(
l
->
t
->
cj
,
e
))
||
(
l
->
t
->
cj
==
c
&&
cell_is_active
(
l
->
t
->
ci
,
e
)))
return
1
;
}
/* No neighbouring cell has active particles. Drift not necessary */
return
0
;
}
/**
/**
* @brief Is this particle active ?
* @brief Is this particle active ?
*
*
...
@@ -60,7 +104,13 @@ __attribute__((always_inline)) INLINE static int cell_is_all_active(
...
@@ -60,7 +104,13 @@ __attribute__((always_inline)) INLINE static int cell_is_all_active(
__attribute__
((
always_inline
))
INLINE
static
int
part_is_active
(
__attribute__
((
always_inline
))
INLINE
static
int
part_is_active
(
const
struct
part
*
p
,
const
struct
engine
*
e
)
{
const
struct
part
*
p
,
const
struct
engine
*
e
)
{
return
(
p
->
ti_end
<=
e
->
ti_current
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
p
->
ti_end
<
e
->
ti_current
)
error
(
"particle in an impossible time-zone! p->ti_end=%d e->ti_current=%d"
,
p
->
ti_end
,
e
->
ti_current
);
#endif
return
(
p
->
ti_end
==
e
->
ti_current
);
}
}
/**
/**
...
@@ -72,7 +122,14 @@ __attribute__((always_inline)) INLINE static int part_is_active(
...
@@ -72,7 +122,14 @@ __attribute__((always_inline)) INLINE static int part_is_active(
__attribute__
((
always_inline
))
INLINE
static
int
gpart_is_active
(
__attribute__
((
always_inline
))
INLINE
static
int
gpart_is_active
(
const
struct
gpart
*
gp
,
const
struct
engine
*
e
)
{
const
struct
gpart
*
gp
,
const
struct
engine
*
e
)
{
return
(
gp
->
ti_end
<=
e
->
ti_current
);
#ifdef SWIFT_DEBUG_CHECKS
if
(
gp
->
ti_end
<
e
->
ti_current
)
error
(
"g-particle in an impossible time-zone! gp->ti_end=%d e->ti_current=%d"
,
gp
->
ti_end
,
e
->
ti_current
);
#endif
return
(
gp
->
ti_end
==
e
->
ti_current
);
}
}
#endif
/* SWIFT_ACTIVE_H */
#endif
/* SWIFT_ACTIVE_H */
This diff is collapsed.
Click to expand it.
src/cell.c
+
0
−
29
View file @
c235205c
...
@@ -863,35 +863,6 @@ void cell_clean(struct cell *c) {
...
@@ -863,35 +863,6 @@ void cell_clean(struct cell *c) {
if
(
c
->
progeny
[
k
])
cell_clean
(
c
->
progeny
[
k
]);
if
(
c
->
progeny
[
k
])
cell_clean
(
c
->
progeny
[
k
]);
}
}
/**
* @brief Checks whether a given cell needs drifting or not.
*
* @param c the #cell.
* @param ti_current The current time on the integer time-line.
*
* @return 1 If the cell needs drifting, 0 otherwise.
*/
int
cell_is_drift_needed
(
struct
cell
*
c
,
int
ti_current
)
{
/* Do we have at least one active particle in the cell ?*/
if
(
c
->
ti_end_min
==
ti_current
)
return
1
;
/* Loop over the pair tasks that involve this cell */
for
(
struct
link
*
l
=
c
->
density
;
l
!=
NULL
;
l
=
l
->
next
)
{
if
(
l
->
t
->
type
!=
task_type_pair
&&
l
->
t
->
type
!=
task_type_sub_pair
)
continue
;
/* Does the other cell in the pair have an active particle ? */
if
((
l
->
t
->
ci
==
c
&&
l
->
t
->
cj
->
ti_end_min
==
ti_current
)
||
(
l
->
t
->
cj
==
c
&&
l
->
t
->
ci
->
ti_end_min
==
ti_current
))
return
1
;
}
/* No neighbouring cell has active particles. Drift not necessary */
return
0
;
}
/**
/**
* @brief Un-skips all the tasks associated with a given cell and checks
* @brief Un-skips all the tasks associated with a given cell and checks
* if the space needs to be rebuilt.
* if the space needs to be rebuilt.
...
...
This diff is collapsed.
Click to expand it.
src/cell.h
+
0
−
1
View file @
c235205c
...
@@ -290,7 +290,6 @@ int cell_are_neighbours(const struct cell *restrict ci,
...
@@ -290,7 +290,6 @@ int cell_are_neighbours(const struct cell *restrict ci,
const
struct
cell
*
restrict
cj
);
const
struct
cell
*
restrict
cj
);
void
cell_check_multipole
(
struct
cell
*
c
,
void
*
data
);
void
cell_check_multipole
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean
(
struct
cell
*
c
);
void
cell_clean
(
struct
cell
*
c
);
int
cell_is_drift_needed
(
struct
cell
*
c
,
int
ti_current
);
int
cell_unskip_tasks
(
struct
cell
*
c
,
struct
scheduler
*
s
);
int
cell_unskip_tasks
(
struct
cell
*
c
,
struct
scheduler
*
s
);
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
);
void
cell_set_super
(
struct
cell
*
c
,
struct
cell
*
super
);
...
...
This diff is collapsed.
Click to expand it.
src/runner.c
+
8
−
6
View file @
c235205c
...
@@ -758,20 +758,18 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
...
@@ -758,20 +758,18 @@ void runner_do_ghost(struct runner *r, struct cell *c) {
*/
*/
static
void
runner_do_drift
(
struct
cell
*
c
,
struct
engine
*
e
,
int
drift
)
{
static
void
runner_do_drift
(
struct
cell
*
c
,
struct
engine
*
e
,
int
drift
)
{
const
int
ti_current
=
e
->
ti_current
;
/* Unskip any active tasks. */
/* Unskip any active tasks. */
if
(
c
->
ti_end_min
==
e
->
ti_current
)
{
if
(
c
ell_is_active
(
c
,
e
)
)
{
const
int
forcerebuild
=
cell_unskip_tasks
(
c
,
&
e
->
sched
);
const
int
forcerebuild
=
cell_unskip_tasks
(
c
,
&
e
->
sched
);
if
(
forcerebuild
)
atomic_inc
(
&
e
->
forcerebuild
);
if
(
forcerebuild
)
atomic_inc
(
&
e
->
forcerebuild
);
}
}
/* Do we really need to drift? */
/* Do we really need to drift? */
if
(
drift
)
{
if
(
drift
)
{
if
(
!
e
->
drift_all
&&
!
cell_is_drift_needed
(
c
,
ti_current
))
return
;
if
(
!
e
->
drift_all
&&
!
cell_is_drift_needed
(
c
,
e
))
return
;
}
else
{
}
else
{
/* Not drifting, but may still need to recurse for task skipping. */
/* Not drifting, but may still need to recurse for task
un-
skipping. */
if
(
c
->
split
)
{
if
(
c
->
split
)
{
for
(
int
k
=
0
;
k
<
8
;
k
++
)
{
for
(
int
k
=
0
;
k
<
8
;
k
++
)
{
if
(
c
->
progeny
[
k
]
!=
NULL
)
{
if
(
c
->
progeny
[
k
]
!=
NULL
)
{
...
@@ -783,8 +781,12 @@ static void runner_do_drift(struct cell *c, struct engine *e, int drift) {
...
@@ -783,8 +781,12 @@ static void runner_do_drift(struct cell *c, struct engine *e, int drift) {
return
;
return
;
}
}
/* Now, we can drift */
/* Get some information first */
const
double
timeBase
=
e
->
timeBase
;
const
double
timeBase
=
e
->
timeBase
;
const
int
ti_old
=
c
->
ti_old
;
const
int
ti_old
=
c
->
ti_old
;
const
int
ti_current
=
e
->
ti_current
;
struct
part
*
const
parts
=
c
->
parts
;
struct
part
*
const
parts
=
c
->
parts
;
struct
xpart
*
const
xparts
=
c
->
xparts
;
struct
xpart
*
const
xparts
=
c
->
xparts
;
struct
gpart
*
const
gparts
=
c
->
gparts
;
struct
gpart
*
const
gparts
=
c
->
gparts
;
...
@@ -797,7 +799,7 @@ static void runner_do_drift(struct cell *c, struct engine *e, int drift) {
...
@@ -797,7 +799,7 @@ static void runner_do_drift(struct cell *c, struct engine *e, int drift) {
if
(
!
c
->
split
)
{
if
(
!
c
->
split
)
{
/* Check that we are actually going to move forward. */
/* Check that we are actually going to move forward. */
if
(
ti_current
>
=
ti_old
)
{
if
(
ti_current
>
ti_old
)
{
/* Loop over all the g-particles in the cell */
/* Loop over all the g-particles in the cell */
const
size_t
nr_gparts
=
c
->
gcount
;
const
size_t
nr_gparts
=
c
->
gcount
;
...
...
This diff is collapsed.
Click to expand it.
src/statistics.c
+
1
−
1
View file @
c235205c
...
@@ -157,7 +157,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
...
@@ -157,7 +157,7 @@ void stats_collect_part_mapper(void *map_data, int nr_parts, void *extra_data) {
stats
.
E_pot_self
+=
0
.
f
;
stats
.
E_pot_self
+=
0
.
f
;
if
(
gp
!=
NULL
)
if
(
gp
!=
NULL
)
stats
.
E_pot_ext
+=
stats
.
E_pot_ext
+=
m
*
external_gravity_get_potential_energy
(
potential
,
phys_const
,
gp
);
m
*
external_gravity_get_potential_energy
(
potential
,
phys_const
,
gp
);
stats
.
E_int
+=
m
*
hydro_get_internal_energy
(
p
,
dt
);
stats
.
E_int
+=
m
*
hydro_get_internal_energy
(
p
,
dt
);
stats
.
E_rad
+=
cooling_get_radiated_energy
(
xp
);
stats
.
E_rad
+=
cooling_get_radiated_energy
(
xp
);
...
...
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