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
d5e666a9
Commit
d5e666a9
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Made splitting decision functions inline
parent
4d200d36
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!343
Subset sorting
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cell.c
+0
-79
0 additions, 79 deletions
src/cell.c
src/cell.h
+88
-6
88 additions, 6 deletions
src/cell.h
src/space.h
+3
-1
3 additions, 1 deletion
src/space.h
with
91 additions
and
86 deletions
src/cell.c
+
0
−
79
View file @
d5e666a9
...
...
@@ -1316,85 +1316,6 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) {
return
0
;
}
/**
* @brief Can a sub-pair hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
int
cell_can_recurse_in_pair_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* If so, is the cut-off radius plus the max distance the parts have moved */
/* smaller than the sub-cell sizes ? */
/* Note: We use the _old values as these might have been updated by a drift */
return
c
->
split
&&
((
kernel_gamma
*
c
->
h_max_old
+
c
->
dx_max_old
)
<
0
.
5
f
*
c
->
dmin
);
}
/**
* @brief Can a sub-self hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
int
cell_can_recurse_in_self_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* operations will be executed. So no need for the particle to be at exactly
*/
/* the right place. */
return
c
->
split
;
}
/**
* @brief Can a pair task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
int
cell_can_split_pair_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* If so, is the cut-off radius with some leeway smaller than */
/* the sub-cell sizes ? */
/* Note that since tasks are create after a rebuild no need to take */
/* into account any part motion (i.e. dx_max == 0 here) */
return
c
->
split
&&
(
space_stretch
*
kernel_gamma
*
c
->
h_max
<
0
.
5
f
*
c
->
dmin
);
}
/**
* @brief Can a self task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
int
cell_can_split_self_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* tasks will be created. So no need to check for h_max */
return
c
->
split
;
}
/**
* @brief Have particles in a pair of cells moved too much and require a rebuild
* ?
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
int
cell_need_rebuild_for_pair
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
)
{
/* Is the cut-off radius plus the max distance the parts in both cells have */
/* moved larger than the cell size ? */
/* Note ci->dmin == cj->dmin */
return
(
kernel_gamma
*
max
(
ci
->
h_max
,
cj
->
h_max
)
+
ci
->
dx_max_part
+
cj
->
dx_max_part
>
cj
->
dmin
);
}
/**
* @brief Traverse a sub-cell task and activate the sort tasks along the way.
*/
...
...
This diff is collapsed.
Click to expand it.
src/cell.h
+
88
−
6
View file @
d5e666a9
...
...
@@ -31,15 +31,16 @@
/* Local includes. */
#include
"align.h"
#include
"kernel_hydro.h"
#include
"lock.h"
#include
"multipole.h"
#include
"part.h"
#include
"space.h"
#include
"task.h"
#include
"timeline.h"
/* Avoid cyclic inclusions */
struct
engine
;
struct
space
;
struct
scheduler
;
/* Max tag size set to 2^29 to take into account some MPI implementations
...
...
@@ -388,10 +389,91 @@ void cell_check_timesteps(struct cell *c);
void
cell_store_pre_drift_values
(
struct
cell
*
c
);
void
cell_activate_subcell_tasks
(
struct
cell
*
ci
,
struct
cell
*
cj
,
struct
scheduler
*
s
);
int
cell_can_recurse_in_pair_task
(
const
struct
cell
*
c
);
int
cell_can_recurse_in_self_task
(
const
struct
cell
*
c
);
int
cell_can_split_pair_task
(
const
struct
cell
*
c
);
int
cell_can_split_self_task
(
const
struct
cell
*
c
);
int
cell_need_rebuild_for_pair
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
);
/* Inlined functions (for speed). */
/**
* @brief Can a sub-pair hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
int
cell_can_recurse_in_pair_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* If so, is the cut-off radius plus the max distance the parts have moved */
/* smaller than the sub-cell sizes ? */
/* Note: We use the _old values as these might have been updated by a drift */
return
c
->
split
&&
((
kernel_gamma
*
c
->
h_max_old
+
c
->
dx_max_old
)
<
0
.
5
f
*
c
->
dmin
);
}
/**
* @brief Can a sub-self hydro task recurse to a lower level based
* on the status of the particles in the cell.
*
* @param c The #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
int
cell_can_recurse_in_self_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* operations will be executed. So no need for the particle to be at exactly
*/
/* the right place. */
return
c
->
split
;
}
/**
* @brief Can a pair task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
int
cell_can_split_pair_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* If so, is the cut-off radius with some leeway smaller than */
/* the sub-cell sizes ? */
/* Note that since tasks are create after a rebuild no need to take */
/* into account any part motion (i.e. dx_max == 0 here) */
return
c
->
split
&&
(
space_stretch
*
kernel_gamma
*
c
->
h_max
<
0
.
5
f
*
c
->
dmin
);
}
/**
* @brief Can a self task associated with a cell be split into smaller
* sub-tasks.
*
* @param c The #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
int
cell_can_split_self_task
(
const
struct
cell
*
c
)
{
/* Is the cell split ? */
/* Note: No need for more checks here as all the sub-pairs and sub-self */
/* tasks will be created. So no need to check for h_max */
return
c
->
split
;
}
/**
* @brief Have particles in a pair of cells moved too much and require a rebuild
* ?
*
* @param ci The first #cell.
* @param cj The second #cell.
*/
__attribute__
((
always_inline
))
INLINE
static
int
cell_need_rebuild_for_pair
(
const
struct
cell
*
ci
,
const
struct
cell
*
cj
)
{
/* Is the cut-off radius plus the max distance the parts in both cells have */
/* moved larger than the cell size ? */
/* Note ci->dmin == cj->dmin */
return
(
kernel_gamma
*
max
(
ci
->
h_max
,
cj
->
h_max
)
+
ci
->
dx_max_part
+
cj
->
dx_max_part
>
cj
->
dmin
);
}
#endif
/* SWIFT_CELL_H */
This diff is collapsed.
Click to expand it.
src/space.h
+
3
−
1
View file @
d5e666a9
...
...
@@ -30,13 +30,15 @@
#include
<stddef.h>
/* Includes. */
#include
"cell.h"
#include
"hydro_space.h"
#include
"lock.h"
#include
"parser.h"
#include
"part.h"
#include
"space.h"
/* Avoid cyclic inclusions */
struct
cell
;
/* Some constants. */
#define space_cellallocchunk 1000
#define space_splitsize_default 400
...
...
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