Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
45be44d9
Commit
45be44d9
authored
Nov 24, 2017
by
Matthieu Schaller
Browse files
More code simplification and clean-up
parent
2e391ba6
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/engine.c
View file @
45be44d9
...
...
@@ -2467,7 +2467,6 @@ void engine_link_gravity_tasks(struct engine *e) {
struct
scheduler
*
sched
=
&
e
->
sched
;
const
int
nodeID
=
e
->
nodeID
;
const
int
nr_tasks
=
sched
->
nr_tasks
;
// const int periodic = e->s->periodic;
for
(
int
k
=
0
;
k
<
nr_tasks
;
k
++
)
{
...
...
@@ -3306,18 +3305,18 @@ void engine_print_task_counts(struct engine *e) {
else
{
counts
[(
int
)
tasks
[
k
].
type
]
+=
1
;
if
(
tasks
[
k
].
type
==
task_type_send
&&
tasks
[
k
].
subtype
==
task_subtype_tend
)
count_send_ti
++
;
if
(
tasks
[
k
].
type
==
task_type_recv
&&
tasks
[
k
].
subtype
==
task_subtype_tend
)
count_recv_ti
++
;
if
(
tasks
[
k
].
type
==
task_type_send
&&
tasks
[
k
].
subtype
==
task_subtype_gpart
)
count_send_gpart
++
;
if
(
tasks
[
k
].
type
==
task_type_recv
&&
tasks
[
k
].
subtype
==
task_subtype_gpart
)
count_recv_gpart
++
;
/*
if (tasks[k].type == task_type_send &&
*/
/*
tasks[k].subtype == task_subtype_tend)
*/
/*
count_send_ti++;
*/
/*
if (tasks[k].type == task_type_recv &&
*/
/*
tasks[k].subtype == task_subtype_tend)
*/
/*
count_recv_ti++;
*/
/*
if (tasks[k].type == task_type_send &&
*/
/*
tasks[k].subtype == task_subtype_gpart)
*/
/*
count_send_gpart++;
*/
/*
if (tasks[k].type == task_type_recv &&
*/
/*
tasks[k].subtype == task_subtype_gpart)
*/
/*
count_recv_gpart++;
*/
}
}
message
(
"Total = %d (per cell = %d)"
,
nr_tasks
,
...
...
@@ -3333,11 +3332,12 @@ void engine_print_task_counts(struct engine *e) {
printf
(
" %s=%i"
,
taskID_names
[
k
],
counts
[
k
]);
printf
(
" skipped=%i ]
\n
"
,
counts
[
task_type_count
]);
fflush
(
stdout
);
// message("nr_parts = %zu.", e->s->nr_parts);
// message("nr_gparts = %zu.", e->s->nr_gparts);
// message("nr_sparts = %zu.", e->s->nr_sparts);
message
(
"send_ti=%d, recv_ti=%d, send_gpart=%d, recv_gpart=%d"
,
count_send_ti
,
count_recv_ti
,
count_send_gpart
,
count_recv_gpart
);
message
(
"nr_parts = %zu."
,
e
->
s
->
nr_parts
);
message
(
"nr_gparts = %zu."
,
e
->
s
->
nr_gparts
);
message
(
"nr_sparts = %zu."
,
e
->
s
->
nr_sparts
);
/* message("send_ti=%d, recv_ti=%d, send_gpart=%d, recv_gpart=%d",
* count_send_ti, */
/* count_recv_ti, count_send_gpart, count_recv_gpart); */
if
(
e
->
verbose
)
message
(
"took %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
...
...
@@ -4184,7 +4184,6 @@ void engine_step(struct engine *e) {
engine_launch
(
e
);
TIMER_TOC
(
timer_runners
);
// error("done");
#ifdef SWIFT_GRAVITY_FORCE_CHECKS
/* Check the accuracy of the gravity calculation */
if
(
e
->
policy
&
engine_policy_self_gravity
)
...
...
@@ -4279,9 +4278,10 @@ void engine_unskip(struct engine *e) {
/* And the top level gravity FFT one when periodicity is on.*/
if
(
e
->
s
->
periodic
&&
(
e
->
policy
&
engine_policy_self_gravity
))
{
/* But only if there are other tasks (i.e. something happens on this node) */
if
(
e
->
sched
.
active_count
>
0
)
/* But only if there are other tasks (i.e. something happens on this node)
*/
if
(
e
->
sched
.
active_count
>
0
)
scheduler_activate
(
&
e
->
sched
,
e
->
s
->
grav_top_level
);
}
...
...
@@ -4450,8 +4450,8 @@ void engine_makeproxies(struct engine *e) {
const
struct
gravity_props
*
props
=
e
->
gravity_properties
;
const
double
theta_crit2
=
props
->
theta_crit2
;
ticks
tic
=
getticks
();
//const int with_hydro = (e->policy & engine_policy_hydro);
//const int with_gravity = (e->policy & engine_policy_self_gravity);
//
const int with_hydro = (e->policy & engine_policy_hydro);
//
const int with_gravity = (e->policy & engine_policy_self_gravity);
/* Prepare the proxies and the proxy index. */
if
(
e
->
proxy_ind
==
NULL
)
...
...
@@ -4473,39 +4473,41 @@ void engine_makeproxies(struct engine *e) {
/* Get the cell ID. */
const
int
cid
=
cell_getid
(
cdim
,
ind
[
0
],
ind
[
1
],
ind
[
2
]);
/* Get ci's multipole */
const
struct
gravity_tensors
*
multi_i
=
cells
[
cid
].
multipole
;
const
double
CoM_i
[
3
]
=
{
multi_i
->
CoM
[
0
],
multi_i
->
CoM
[
1
],
multi_i
->
CoM
[
2
]};
const
double
r_max_i
=
multi_i
->
r_max
;
/* Get ci's multipole */
const
struct
gravity_tensors
*
multi_i
=
cells
[
cid
].
multipole
;
const
double
CoM_i
[
3
]
=
{
multi_i
->
CoM
[
0
],
multi_i
->
CoM
[
1
],
multi_i
->
CoM
[
2
]};
const
double
r_max_i
=
multi_i
->
r_max
;
/* Loop over every other cell */
for
(
int
ii
=
0
;
ii
<
cdim
[
0
];
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
cdim
[
1
];
jj
++
)
{
for
(
int
kk
=
0
;
kk
<
cdim
[
2
];
kk
++
)
{
/* Loop over every other cell */
for
(
int
ii
=
0
;
ii
<
cdim
[
0
];
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
cdim
[
1
];
jj
++
)
{
for
(
int
kk
=
0
;
kk
<
cdim
[
2
];
kk
++
)
{
/* Get the cell ID. */
const
int
cjd
=
cell_getid
(
cdim
,
ii
,
jj
,
kk
);
/* Get cj's multipole */
const
struct
gravity_tensors
*
multi_j
=
cells
[
cjd
].
multipole
;
const
double
CoM_j
[
3
]
=
{
multi_j
->
CoM
[
0
],
multi_j
->
CoM
[
1
],
multi_j
->
CoM
[
2
]};
const
double
r_max_j
=
multi_j
->
r_max
;
/* Let's compute the current distance between the cell pair*/
double
dx
=
CoM_i
[
0
]
-
CoM_j
[
0
];
double
dy
=
CoM_i
[
1
]
-
CoM_j
[
1
];
double
dz
=
CoM_i
[
2
]
-
CoM_j
[
2
];
/* Apply BC */
if
(
periodic
)
{
dx
=
nearest
(
dx
,
dim
[
0
]);
dy
=
nearest
(
dy
,
dim
[
1
]);
dz
=
nearest
(
dz
,
dim
[
2
]);
}
const
double
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
if
(
gravity_M2L_accept
(
r_max_i
,
r_max_j
,
theta_crit2
,
r2
))
continue
;
/* Get cj's multipole */
const
struct
gravity_tensors
*
multi_j
=
cells
[
cjd
].
multipole
;
const
double
CoM_j
[
3
]
=
{
multi_j
->
CoM
[
0
],
multi_j
->
CoM
[
1
],
multi_j
->
CoM
[
2
]};
const
double
r_max_j
=
multi_j
->
r_max
;
/* Let's compute the current distance between the cell pair*/
double
dx
=
CoM_i
[
0
]
-
CoM_j
[
0
];
double
dy
=
CoM_i
[
1
]
-
CoM_j
[
1
];
double
dz
=
CoM_i
[
2
]
-
CoM_j
[
2
];
/* Apply BC */
if
(
periodic
)
{
dx
=
nearest
(
dx
,
dim
[
0
]);
dy
=
nearest
(
dy
,
dim
[
1
]);
dz
=
nearest
(
dz
,
dim
[
2
]);
}
const
double
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
if
(
gravity_M2L_accept
(
r_max_i
,
r_max_j
,
theta_crit2
,
r2
))
continue
;
/* Add to proxies? */
if
(
cells
[
cid
].
nodeID
==
e
->
nodeID
&&
...
...
src/runner_doiact_grav.h
View file @
45be44d9
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
...
...
@@ -44,13 +43,6 @@ void runner_do_grav_down(struct runner *r, struct cell *c, int timer) {
struct
gpart
*
gparts
=
c
->
gparts
;
const
int
gcount
=
c
->
gcount
;
#if (ICHECK != 0)
for
(
int
i
=
0
;
i
<
c
->
gcount
;
++
i
)
if
(
c
->
gparts
[
i
].
id_or_neg_offset
==
ICHECK
)
message
(
"Found gpart depth=%d split=%d m->num_interacted=%lld"
,
c
->
depth
,
c
->
split
,
c
->
multipole
->
pot
.
num_interacted
);
#endif
TIMER_TIC
;
#ifdef SWIFT_DEBUG_CHECKS
...
...
@@ -1145,16 +1137,11 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
const
struct
gravity_props
*
props
=
e
->
gravity_properties
;
const
int
periodic
=
s
->
periodic
;
const
double
cell_width
=
s
->
width
[
0
];
/* const int cdim[3] = {s->cdim[0], s->cdim[1], s->cdim[2]}; */
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
theta_crit2
=
props
->
theta_crit2
;
const
double
max_distance
=
props
->
a_smooth
*
props
->
r_cut_max
*
cell_width
;
const
double
max_distance2
=
max_distance
*
max_distance
;
#ifdef SWIFT_DEBUG_CHECKS
long
long
counter
=
0
;
#endif
TIMER_TIC
;
/* Recover the list of top-level cells */
...
...
@@ -1178,12 +1165,6 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
multi_i
->
CoM_rebuild
[
1
],
multi_i
->
CoM_rebuild
[
2
]};
/* /\* Get the cell index. MATTHIEU *\/ */
/* const int cid = (ci - cells); // / sizeof(struct cell); */
/* const int i = cid / (cdim[1] * cdim[2]); */
/* const int j = (cid / cdim[2]) % cdim[1]; */
/* const int k = cid % cdim[2]; */
/* Loop over all the top-level cells and go for a M-M interaction if
* well-separated */
for
(
int
n
=
0
;
n
<
nr_cells
;
++
n
)
{
...
...
@@ -1195,18 +1176,6 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
/* Avoid self contributions */
if
(
ci
==
cj
)
continue
;
#ifdef SWIFT_DEBUG_CHECKS
counter
+=
multi_j
->
m_pole
.
num_gpart
;
#endif
/* // MATTHIEU */
/* const int cjd = (cj - cells); // / sizeof(struct cell); */
/* const int ii = cjd / (cdim[1] * cdim[2]); */
/* const int jj = (cjd / cdim[2]) % cdim[1]; */
/* const int kk = cjd % cdim[2]; */
/* /\* if(check) message("cid=%d cjd=%d cj->nodeID=%d cj->gcount=%d", *\/ */
/* /\* cid, cjd, cj->nodeID, cj->gcount); *\/ */
/* Get the distance between the CoMs at the last rebuild*/
double
dx_r
=
CoM_rebuild_i
[
0
]
-
multi_j
->
CoM_rebuild
[
0
];
double
dy_r
=
CoM_rebuild_i
[
1
]
-
multi_j
->
CoM_rebuild
[
1
];
...
...
@@ -1223,12 +1192,6 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
/* Are we in charge of this cell pair? */
if
(
gravity_M2L_accept
(
multi_i
->
r_max_rebuild
,
multi_j
->
r_max_rebuild
,
theta_crit2
,
r2_rebuild
))
{
/* if ((abs(i - ii) <= 1 || abs(i - ii - cdim[0]) <= 1 || */
/* abs(i - ii + cdim[0]) <= 1) && */
/* (abs(j - jj) <= 1 || abs(j - jj - cdim[1]) <= 1 || */
/* abs(j - jj + cdim[1]) <= 1) && */
/* (abs(k - kk) <= 1 || abs(k - kk - cdim[2]) <= 1 || */
/* abs(k - kk + cdim[2]) <= 1)) { */
/* Let's compute the current distance between the cell pair*/
double
dx
=
CoM_i
[
0
]
-
multi_j
->
CoM
[
0
];
...
...
@@ -1252,7 +1215,7 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) {
#endif
continue
;
}
/* Check the multipole acceptance criterion */
if
(
gravity_M2L_accept
(
multi_i
->
r_max
,
multi_j
->
r_max
,
theta_crit2
,
r2
))
{
...
...
src/space.c
View file @
45be44d9
...
...
@@ -3164,38 +3164,3 @@ void space_clean(struct space *s) {
free
(
s
->
gparts
);
free
(
s
->
sparts
);
}
void
space_print_cells
(
const
struct
space
*
s
)
{
char
filename
[
200
];
sprintf
(
filename
,
"space_%d_%d.dat"
,
s
->
e
->
step
,
engine_rank
);
FILE
*
file
=
fopen
(
filename
,
"w"
);
fprintf
(
file
,
"ti_current=%lld
\n
"
,
s
->
e
->
ti_current
);
for
(
int
k
=
0
;
k
<
s
->
cdim
[
2
];
++
k
)
{
fprintf
(
file
,
"
\n
-- k=%d --
\n\n
"
,
k
);
for
(
int
j
=
0
;
j
<
s
->
cdim
[
1
];
++
j
)
{
for
(
int
i
=
0
;
i
<
s
->
cdim
[
0
];
++
i
)
{
#ifdef WITH_MPI
const
int
cid
=
cell_getid
(
s
->
cdim
,
i
,
j
,
k
);
const
struct
cell
*
c
=
&
s
->
cells_top
[
cid
];
fprintf
(
file
,
"|(%d-%lld-%d-%d%d-%d)"
,
c
->
nodeID
,
c
->
ti_end_min
,
c
->
gcount
,
(
c
->
recv_grav
!=
NULL
),
(
c
->
recv_grav
!=
NULL
?
c
->
recv_grav
->
skip
==
0
:
0
),
(
c
->
send_grav
!=
NULL
));
#endif
}
fprintf
(
file
,
"|
\n
"
);
}
}
fprintf
(
file
,
" -- --- --
\n
"
);
fclose
(
file
);
}
src/space.h
View file @
45be44d9
...
...
@@ -234,6 +234,5 @@ void space_replicate(struct space *s, int replicate, int verbose);
void
space_reset_task_counters
(
struct
space
*
s
);
void
space_clean
(
struct
space
*
s
);
void
space_free_cells
(
struct
space
*
s
);
void
space_print_cells
(
const
struct
space
*
s
);
#endif
/* SWIFT_SPACE_H */
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment