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
656df9df
Commit
656df9df
authored
Feb 06, 2016
by
Matthieu Schaller
Browse files
Applied formatting rules to all files
parent
f0c9f9ca
Changes
31
Hide whitespace changes
Inline
Side-by-side
examples/main.c
View file @
656df9df
...
...
@@ -56,9 +56,6 @@
#define ENGINE_POLICY engine_policy_none
#endif
/**
* @brief Main routine that loads a few particles and generates some output.
*
...
...
@@ -86,17 +83,19 @@ int main(int argc, char *argv[]) {
FILE
*
file_thread
;
int
with_outputs
=
1
;
/* Choke on FP-exceptions. */
//feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
/* Choke on FP-exceptions. */
//
feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
#ifdef WITH_MPI
/* Start by initializing MPI. */
int
res
,
prov
;
if
((
res
=
MPI_Init_thread
(
&
argc
,
&
argv
,
MPI_THREAD_MULTIPLE
,
&
prov
))
!=
MPI_SUCCESS
)
if
((
res
=
MPI_Init_thread
(
&
argc
,
&
argv
,
MPI_THREAD_MULTIPLE
,
&
prov
))
!=
MPI_SUCCESS
)
error
(
"Call to MPI_Init failed with error %i."
,
res
);
if
(
prov
!=
MPI_THREAD_MULTIPLE
)
error
(
"MPI does not provide the level of threading required "
"(MPI_THREAD_MULTIPLE)."
);
error
(
"MPI does not provide the level of threading required "
"(MPI_THREAD_MULTIPLE)."
);
if
((
res
=
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
nr_nodes
))
!=
MPI_SUCCESS
)
error
(
"MPI_Comm_size failed with error %i."
,
res
);
if
((
res
=
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
myrank
))
!=
MPI_SUCCESS
)
...
...
@@ -146,7 +145,8 @@ int main(int argc, char *argv[]) {
fflush
(
stdout
);
break
;
case
'c'
:
if
(
sscanf
(
optarg
,
"%lf"
,
&
time_end
)
!=
1
)
error
(
"Error parsing final time."
);
if
(
sscanf
(
optarg
,
"%lf"
,
&
time_end
)
!=
1
)
error
(
"Error parsing final time."
);
if
(
myrank
==
0
)
message
(
"time_end set to %.3e."
,
time_end
);
fflush
(
stdout
);
break
;
...
...
@@ -198,7 +198,7 @@ int main(int argc, char *argv[]) {
if
(
myrank
==
0
)
message
(
"sub size set to %i."
,
space_subsize
);
break
;
case
'y'
:
if
(
sscanf
(
optarg
,
"%d"
,
&
dump_tasks
)
!=
1
)
if
(
sscanf
(
optarg
,
"%d"
,
&
dump_tasks
)
!=
1
)
error
(
"Error parsing dump_tasks (-y)"
);
break
;
case
'z'
:
...
...
@@ -218,7 +218,7 @@ int main(int argc, char *argv[]) {
if
(
nr_nodes
==
1
)
{
message
(
"WARNING: you are running with one MPI rank."
);
message
(
"WARNING: you should use the non-MPI version of this program."
);
message
(
"WARNING: you should use the non-MPI version of this program."
);
}
fflush
(
stdout
);
}
...
...
@@ -229,7 +229,8 @@ int main(int argc, char *argv[]) {
/* How large are the parts? */
if
(
myrank
==
0
)
{
message
(
"sizeof(struct part) is %li bytes."
,
(
long
int
)
sizeof
(
struct
part
));
message
(
"sizeof(struct xpart) is %li bytes."
,
(
long
int
)
sizeof
(
struct
xpart
));
message
(
"sizeof(struct xpart) is %li bytes."
,
(
long
int
)
sizeof
(
struct
xpart
));
message
(
"sizeof(struct gpart) is %li bytes."
,
(
long
int
)
sizeof
(
struct
gpart
));
}
...
...
@@ -251,9 +252,9 @@ int main(int argc, char *argv[]) {
}
/* Check we have sensible time step bounds */
if
(
dt_min
>
dt_max
)
if
(
dt_min
>
dt_max
)
error
(
"Minimal time step size must be large than maximal time step size "
);
/* Check whether an IC file has been provided */
if
(
strcmp
(
ICfileName
,
""
)
==
0
)
error
(
"An IC file name must be provided via the option -f"
);
...
...
@@ -334,7 +335,6 @@ int main(int argc, char *argv[]) {
message
(
"nr of cells at depth %i is %i."
,
data
[
0
],
data
[
1
]);
}
/* Initialize the engine with this space. */
tic
=
getticks
();
if
(
myrank
==
0
)
message
(
"nr_nodes is %i."
,
nr_nodes
);
...
...
@@ -379,19 +379,21 @@ int main(int argc, char *argv[]) {
if
(
myrank
==
0
)
{
message
(
"Running on %lld particles until t=%.3e with %i threads and %i "
"queues (dt_min=%.3e, dt_max=%.3e)..."
,
N_total
,
time_end
,
e
.
nr_threads
,
e
.
sched
.
nr_queues
,
e
.
dt_min
,
e
.
dt_max
);
"Running on %lld particles until t=%.3e with %i threads and %i "
"queues (dt_min=%.3e, dt_max=%.3e)..."
,
N_total
,
time_end
,
e
.
nr_threads
,
e
.
sched
.
nr_queues
,
e
.
dt_min
,
e
.
dt_max
);
fflush
(
stdout
);
}
/* Initialise the particles */
engine_init_particles
(
&
e
);
/* Legend */
if
(
myrank
==
0
)
printf
(
"# Step Time time-step Number of updates CPU Wall-clock time [ms]
\n
"
);
printf
(
"# Step Time time-step Number of updates CPU Wall-clock time "
"[ms]
\n
"
);
/* Let loose a runner on the space. */
for
(
j
=
0
;
e
.
time
<
time_end
;
j
++
)
{
...
...
@@ -423,15 +425,15 @@ int main(int argc, char *argv[]) {
#endif
}
/* Dump the task data using the given frequency. */
/* Dump the task data using the given frequency. */
if
(
dump_tasks
&&
(
dump_tasks
==
1
||
j
%
dump_tasks
==
1
))
{
#ifdef WITH_MPI
/* Make sure output file is empty, only on one rank. */
sprintf
(
dumpfile
,
"thread_info_MPI-step%d.dat"
,
j
);
if
(
myrank
==
0
)
{
file_thread
=
fopen
(
dumpfile
,
"w"
);
fclose
(
file_thread
);
file_thread
=
fopen
(
dumpfile
,
"w"
);
fclose
(
file_thread
);
}
MPI_Barrier
(
MPI_COMM_WORLD
);
...
...
@@ -451,14 +453,15 @@ int main(int argc, char *argv[]) {
int
count
=
0
;
for
(
int
l
=
0
;
l
<
e
.
sched
.
nr_tasks
;
l
++
)
if
(
!
e
.
sched
.
tasks
[
l
].
skip
&&
!
e
.
sched
.
tasks
[
l
].
implicit
)
{
fprintf
(
file_thread
,
" %03i %i %i %i %i %lli %lli %i %i %i
\n
"
,
myrank
,
e
.
sched
.
tasks
[
l
].
rid
,
e
.
sched
.
tasks
[
l
].
type
,
e
.
sched
.
tasks
[
l
].
subtype
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
),
e
.
sched
.
tasks
[
l
].
tic
,
e
.
sched
.
tasks
[
l
].
toc
,
(
e
.
sched
.
tasks
[
l
].
ci
!=
NULL
)
?
e
.
sched
.
tasks
[
l
].
ci
->
count
:
0
,
(
e
.
sched
.
tasks
[
l
].
cj
!=
NULL
)
?
e
.
sched
.
tasks
[
l
].
cj
->
count
:
0
,
e
.
sched
.
tasks
[
l
].
flags
);
fprintf
(
file_thread
,
" %03i %i %i %i %i %lli %lli %i %i %i
\n
"
,
myrank
,
e
.
sched
.
tasks
[
l
].
rid
,
e
.
sched
.
tasks
[
l
].
type
,
e
.
sched
.
tasks
[
l
].
subtype
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
),
e
.
sched
.
tasks
[
l
].
tic
,
e
.
sched
.
tasks
[
l
].
toc
,
(
e
.
sched
.
tasks
[
l
].
ci
!=
NULL
)
?
e
.
sched
.
tasks
[
l
].
ci
->
count
:
0
,
(
e
.
sched
.
tasks
[
l
].
cj
!=
NULL
)
?
e
.
sched
.
tasks
[
l
].
cj
->
count
:
0
,
e
.
sched
.
tasks
[
l
].
flags
);
fflush
(
stdout
);
count
++
;
}
...
...
@@ -476,12 +479,13 @@ int main(int argc, char *argv[]) {
file_thread
=
fopen
(
dumpfile
,
"w"
);
for
(
int
l
=
0
;
l
<
e
.
sched
.
nr_tasks
;
l
++
)
if
(
!
e
.
sched
.
tasks
[
l
].
skip
&&
!
e
.
sched
.
tasks
[
l
].
implicit
)
fprintf
(
file_thread
,
" %i %i %i %i %lli %lli %i %i
\n
"
,
e
.
sched
.
tasks
[
l
].
rid
,
e
.
sched
.
tasks
[
l
].
type
,
e
.
sched
.
tasks
[
l
].
subtype
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
),
e
.
sched
.
tasks
[
l
].
tic
,
e
.
sched
.
tasks
[
l
].
toc
,
(
e
.
sched
.
tasks
[
l
].
ci
==
NULL
)
?
0
:
e
.
sched
.
tasks
[
l
].
ci
->
count
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
)
?
0
:
e
.
sched
.
tasks
[
l
].
cj
->
count
);
fprintf
(
file_thread
,
" %i %i %i %i %lli %lli %i %i
\n
"
,
e
.
sched
.
tasks
[
l
].
rid
,
e
.
sched
.
tasks
[
l
].
type
,
e
.
sched
.
tasks
[
l
].
subtype
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
),
e
.
sched
.
tasks
[
l
].
tic
,
e
.
sched
.
tasks
[
l
].
toc
,
(
e
.
sched
.
tasks
[
l
].
ci
==
NULL
)
?
0
:
e
.
sched
.
tasks
[
l
].
ci
->
count
,
(
e
.
sched
.
tasks
[
l
].
cj
==
NULL
)
?
0
:
e
.
sched
.
tasks
[
l
].
cj
->
count
);
fclose
(
file_thread
);
#endif
}
...
...
@@ -499,7 +503,6 @@ int main(int argc, char *argv[]) {
/* fflush(stdout); */
/* } */
/* if (myrank == 0) { */
/* printf("%i %e", j, e.time); */
/* printf(" %.3f", ((double)timers[timer_count - 1]) / CPU_TPS * 1000); */
...
...
@@ -519,7 +522,6 @@ int main(int argc, char *argv[]) {
(
double
)
runner_hist_bins
[
k
]);
#endif
if
(
with_outputs
)
{
/* Write final output. */
#if defined(WITH_MPI)
...
...
src/cell.c
View file @
656df9df
...
...
@@ -557,8 +557,8 @@ void cell_init_parts(struct cell *c, void *data) {
struct
part
*
p
=
c
->
parts
;
struct
xpart
*
xp
=
c
->
xparts
;
for
(
int
i
=
0
;
i
<
c
->
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
c
->
count
;
++
i
)
{
p
[
i
].
t_begin
=
0
.;
p
[
i
].
t_end
=
0
.;
xp
[
i
].
v_full
[
0
]
=
p
[
i
].
v
[
0
];
...
...
@@ -571,7 +571,8 @@ void cell_init_parts(struct cell *c, void *data) {
}
/**
* @brief Converts hydro quantities to a valid state after the initial density calculation
* @brief Converts hydro quantities to a valid state after the initial density
*calculation
*
* @param c Cell to act upon
* @param data Unused parameter
...
...
@@ -579,24 +580,22 @@ void cell_init_parts(struct cell *c, void *data) {
void
cell_convert_hydro
(
struct
cell
*
c
,
void
*
data
)
{
struct
part
*
p
=
c
->
parts
;
for
(
int
i
=
0
;
i
<
c
->
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
c
->
count
;
++
i
)
{
hydro_convert_quantities
(
&
p
[
i
]);
}
}
/**
* @brief Cleans the links in a given cell.
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
)
{
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
)
{
c
->
density
=
NULL
;
c
->
nr_density
=
0
;
c
->
force
=
NULL
;
c
->
nr_force
=
0
;
}
src/cell.h
View file @
656df9df
...
...
@@ -27,9 +27,9 @@
/* Forward declaration of space, needed for cell_unpack. */
struct
space
;
/* Max tag size set to 2^29 to take into account some MPI implementations
* that use 2^31 as the upper bound on MPI tags and the fact that
* cell_next_tag is multiplied by 2 when passed to an MPI function.
/* Max tag size set to 2^29 to take into account some MPI implementations
* that use 2^31 as the upper bound on MPI tags and the fact that
* cell_next_tag is multiplied by 2 when passed to an MPI function.
* The maximum was lowered by a further factor of 2 to be on the safe side.*/
#define cell_max_tag (1 << 29)
...
...
@@ -161,12 +161,10 @@ struct cell {
}
__attribute__
((
aligned
(
64
)));
/* Convert cell location to ID. */
#define cell_getid(cdim, i, j, k) \
((int)(k) + (cdim)[2] * ((int)(j) + (cdim)[1] * (int)(i)))
/* Function prototypes. */
void
cell_split
(
struct
cell
*
c
);
int
cell_locktree
(
struct
cell
*
c
);
...
...
@@ -179,6 +177,6 @@ int cell_getsize(struct cell *c);
int
cell_link
(
struct
cell
*
c
,
struct
part
*
parts
);
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
);
void
cell_convert_hydro
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
);
#endif
/* SWIFT_CELL_H */
src/common_io.c
View file @
656df9df
...
...
@@ -364,8 +364,8 @@ void writeCodeDescription(hid_t h_file) {
#ifdef WITH_MPI
writeAttribute_s
(
h_grpcode
,
"MPI library"
,
mpi_version
());
#ifdef HAVE_METIS
writeAttribute_s
(
h_grpcode
,
"METIS library version"
,
metis_version
());
#endif
writeAttribute_s
(
h_grpcode
,
"METIS library version"
,
metis_version
());
#endif
#else
writeAttribute_s
(
h_grpcode
,
"MPI library"
,
"Non-MPI version of SWIFT"
);
#endif
...
...
src/debug.c
View file @
656df9df
...
...
@@ -38,7 +38,8 @@
* (Should be used for debugging only as it runs in O(N).)
*/
void
printParticle
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
long
long
int
id
,
int
N
)
{
void
printParticle
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
long
long
int
id
,
int
N
)
{
int
i
,
found
=
0
;
...
...
@@ -47,28 +48,21 @@ void printParticle(struct part *parts, struct xpart *xparts, long long int id, i
if
(
parts
[
i
].
id
==
id
)
{
printf
(
"## Particle[%d]:
\n
id=%lld, x=[%.3e,%.3e,%.3e], "
"v=[%.3e,%.3e,%.3e],v_full=[%.3e,%.3e,%.3e]
\n
a=[%.3e,%.3e,%.3e],
\n
h=%.3e, "
"wcount=%d, m=%.3e, dh_drho=%.3e, rho=%.3e, P=%.3e, S=%.3e, dS/dt=%.3e,
\n
"
"divV=%.3e, curlV=%.3e, rotV=[%.3e,%.3e,%.3e]
\n
"
"v_sig=%e t_begin=%.3e, t_end=%.3e
\n
"
,
"v=[%.3e,%.3e,%.3e],v_full=[%.3e,%.3e,%.3e]
\n
a=[%.3e,%.3e,%.3e],
\n
"
"h=%.3e, "
"wcount=%d, m=%.3e, dh_drho=%.3e, rho=%.3e, P=%.3e, S=%.3e, "
"dS/dt=%.3e,
\n
"
"divV=%.3e, curlV=%.3e, rotV=[%.3e,%.3e,%.3e]
\n
"
"v_sig=%e t_begin=%.3e, t_end=%.3e
\n
"
,
i
,
parts
[
i
].
id
,
parts
[
i
].
x
[
0
],
parts
[
i
].
x
[
1
],
parts
[
i
].
x
[
2
],
parts
[
i
].
v
[
0
],
parts
[
i
].
v
[
1
],
parts
[
i
].
v
[
2
],
xparts
[
i
].
v_full
[
0
],
xparts
[
i
].
v_full
[
1
],
xparts
[
i
].
v_full
[
2
],
parts
[
i
].
a
[
0
],
parts
[
i
].
a
[
1
],
parts
[
i
].
a
[
2
],
2
.
*
parts
[
i
].
h
,
(
int
)
parts
[
i
].
density
.
wcount
,
parts
[
i
].
mass
,
parts
[
i
].
rho_dh
,
parts
[
i
].
rho
,
parts
[
i
].
pressure
,
parts
[
i
].
entropy
,
parts
[
i
].
entropy_dt
,
parts
[
i
].
div_v
,
parts
[
i
].
curl_v
,
parts
[
i
].
rot_v
[
0
],
parts
[
i
].
rot_v
[
1
],
parts
[
i
].
rot_v
[
2
],
parts
[
i
].
v_sig
,
parts
[
i
].
t_begin
,
parts
[
i
].
t_end
);
parts
[
i
].
v
[
0
],
parts
[
i
].
v
[
1
],
parts
[
i
].
v
[
2
],
xparts
[
i
].
v_full
[
0
],
xparts
[
i
].
v_full
[
1
],
xparts
[
i
].
v_full
[
2
],
parts
[
i
].
a
[
0
],
parts
[
i
].
a
[
1
],
parts
[
i
].
a
[
2
],
2
.
*
parts
[
i
].
h
,
(
int
)
parts
[
i
].
density
.
wcount
,
parts
[
i
].
mass
,
parts
[
i
].
rho_dh
,
parts
[
i
].
rho
,
parts
[
i
].
pressure
,
parts
[
i
].
entropy
,
parts
[
i
].
entropy_dt
,
parts
[
i
].
div_v
,
parts
[
i
].
curl_v
,
parts
[
i
].
rot_v
[
0
],
parts
[
i
].
rot_v
[
1
],
parts
[
i
].
rot_v
[
2
],
parts
[
i
].
v_sig
,
parts
[
i
].
t_begin
,
parts
[
i
].
t_end
);
found
=
1
;
}
...
...
@@ -86,10 +80,10 @@ void printgParticle(struct gpart *parts, long long int id, int N) {
"## gParticle[%d]: id=%lld, x=[%.16e,%.16e,%.16e], "
"v=[%.3e,%.3e,%.3e], a=[%.3e,%.3e,%.3e], m=%.3e, t_begin=%.3e, "
"t_end=%.3e
\n
"
,
i
,
parts
[
i
].
part
->
id
,
parts
[
i
].
x
[
0
],
parts
[
i
].
x
[
1
],
parts
[
i
].
x
[
2
],
parts
[
i
].
v
[
0
],
parts
[
i
].
v
[
1
],
parts
[
i
].
v
[
2
],
parts
[
i
].
a
[
0
]
,
parts
[
i
].
a
[
1
]
,
parts
[
i
].
a
[
2
],
parts
[
i
].
mass
,
parts
[
i
].
t_begin
,
parts
[
i
].
t_end
);
i
,
parts
[
i
].
part
->
id
,
parts
[
i
].
x
[
0
],
parts
[
i
].
x
[
1
],
parts
[
i
].
x
[
2
],
parts
[
i
].
v
[
0
],
parts
[
i
].
v
[
1
],
parts
[
i
].
v
[
2
],
parts
[
i
].
a
[
0
],
parts
[
i
].
a
[
1
],
parts
[
i
].
a
[
2
],
parts
[
i
].
mass
,
parts
[
i
].
t_begin
,
parts
[
i
].
t_end
);
found
=
1
;
}
...
...
@@ -107,11 +101,15 @@ void printParticle_single(struct part *p) {
/* printf( */
/* "## Particle: id=%lld, x=[%e,%e,%e], v=[%.3e,%.3e,%.3e], " */
/* "a=[%.3e,%.3e,%.3e], h=%.3e, h_dt=%.3e, wcount=%.3e, m=%.3e, rho=%.3e, " */
/* "rho_dh=%.3e, div_v=%.3e, u=%.3e, dudt=%.3e, bals=%.3e, POrho2=%.3e, " */
/* "a=[%.3e,%.3e,%.3e], h=%.3e, h_dt=%.3e, wcount=%.3e, m=%.3e, rho=%.3e,
* " */
/* "rho_dh=%.3e, div_v=%.3e, u=%.3e, dudt=%.3e, bals=%.3e, POrho2=%.3e, "
*/
/* "v_sig=%.3e, t_begin=%.3e, t_end=%.3e\n", */
/* p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->a[0], */
/* p->a[1], p->a[2], p->h, p->force.h_dt, p->density.wcount, p->mass, p->rho, */
/* p->id, p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], p->a[0],
*/
/* p->a[1], p->a[2], p->h, p->force.h_dt, p->density.wcount, p->mass,
* p->rho, */
/* p->rho_dh, p->density.div_v, p->u, p->force.u_dt, p->force.balsara, */
/* p->force.POrho2, p->force.v_sig, p->t_begin, p->t_end); */
...
...
@@ -130,7 +128,8 @@ void printParticle_single(struct part *p) {
* minus the cell connectivity.
*
* The output filenames are generated from the prefix and the sequence number
* of calls. So the first is called {prefix}_std_001.dat, {prefix}_simple_001.dat,
* of calls. So the first is called {prefix}_std_001.dat,
*{prefix}_simple_001.dat,
* {prefix}_weights_001.dat, etc.
*
* @param prefix base output filename
...
...
@@ -143,7 +142,7 @@ void printParticle_single(struct part *p) {
* @param edgeweights weights of edges
*/
void
dumpMETISGraph
(
const
char
*
prefix
,
idx_t
nvertices
,
idx_t
nvertexweights
,
idx_t
*
cellconruns
,
idx_t
*
cellcon
,
idx_t
*
vertexweights
,
idx_t
*
cellconruns
,
idx_t
*
cellcon
,
idx_t
*
vertexweights
,
idx_t
*
vertexsizes
,
idx_t
*
edgeweights
)
{
FILE
*
stdfile
=
NULL
;
FILE
*
simplefile
=
NULL
;
...
...
@@ -186,24 +185,28 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights,
/* Open output files. */
sprintf
(
fname
,
"%s_std_%03d.dat"
,
prefix
,
nseq
);
stdfile
=
fopen
(
fname
,
"w"
);
stdfile
=
fopen
(
fname
,
"w"
);
sprintf
(
fname
,
"%s_simple_%03d.dat"
,
prefix
,
nseq
);
simplefile
=
fopen
(
fname
,
"w"
);
simplefile
=
fopen
(
fname
,
"w"
);
if
(
havevertexweight
||
havevertexsize
||
haveedgeweight
)
{
sprintf
(
fname
,
"%s_weights_%03d.dat"
,
prefix
,
nseq
);
weightfile
=
fopen
(
fname
,
"w"
);
weightfile
=
fopen
(
fname
,
"w"
);
}
/* Write the header lines. */
fprintf
(
stdfile
,
"%"
PRIDX
" %"
PRIDX
,
nvertices
,
cellconruns
[
nvertices
]
/
2
);
fprintf
(
simplefile
,
"%"
PRIDX
" %"
PRIDX
,
nvertices
,
cellconruns
[
nvertices
]
/
2
);
fprintf
(
simplefile
,
"%"
PRIDX
" %"
PRIDX
,
nvertices
,
cellconruns
[
nvertices
]
/
2
);
if
(
havevertexweight
||
havevertexsize
||
haveedgeweight
)
{
fprintf
(
weightfile
,
"%"
PRIDX
" %"
PRIDX
,
nvertices
,
cellconruns
[
nvertices
]
/
2
);
fprintf
(
weightfile
,
"%"
PRIDX
" %"
PRIDX
,
nvertices
,
cellconruns
[
nvertices
]
/
2
);
fprintf
(
stdfile
,
" %d%d%d"
,
havevertexsize
,
havevertexweight
,
haveedgeweight
);
fprintf
(
weightfile
,
" %d%d%d"
,
havevertexsize
,
havevertexweight
,
haveedgeweight
);
fprintf
(
stdfile
,
" %d%d%d"
,
havevertexsize
,
havevertexweight
,
haveedgeweight
);
fprintf
(
weightfile
,
" %d%d%d"
,
havevertexsize
,
havevertexweight
,
haveedgeweight
);
if
(
havevertexweight
)
{
fprintf
(
stdfile
,
" %d"
,
(
int
)
nvertexweights
);
...
...
@@ -216,7 +219,7 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights,
fprintf
(
stdfile
,
"
\n
"
);
fprintf
(
simplefile
,
"
\n
"
);
if
(
weightfile
!=
NULL
)
{
fprintf
(
weightfile
,
"
\n
"
);
fprintf
(
weightfile
,
"
\n
"
);
}
if
(
havevertexsize
)
{
...
...
@@ -243,7 +246,7 @@ void dumpMETISGraph(const char *prefix, idx_t nvertices, idx_t nvertexweights,
fprintf
(
stdfile
,
"
\n
"
);
fprintf
(
simplefile
,
"
\n
"
);
if
(
weightfile
!=
NULL
)
{
fprintf
(
weightfile
,
"
\n
"
);
fprintf
(
weightfile
,
"
\n
"
);
}
fclose
(
stdfile
);
...
...
src/debug.h
View file @
656df9df
...
...
@@ -23,15 +23,15 @@
#include
"cell.h"
#include
"part.h"
void
printParticle
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
long
long
int
i
,
int
N
);
void
printParticle
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
long
long
int
i
,
int
N
);
void
printgParticle
(
struct
gpart
*
parts
,
long
long
int
i
,
int
N
);
void
printParticle_single
(
struct
part
*
p
);
#ifdef HAVE_METIS
#include
"metis.h"
void
dumpMETISGraph
(
const
char
*
prefix
,
idx_t
nvtxs
,
idx_t
ncon
,
idx_t
*
xadj
,
idx_t
*
adjncy
,
idx_t
*
vwgt
,
idx_t
*
vsize
,
idx_t
*
adjwgt
);
void
dumpMETISGraph
(
const
char
*
prefix
,
idx_t
nvtxs
,
idx_t
ncon
,
idx_t
*
xadj
,
idx_t
*
adjncy
,
idx_t
*
vwgt
,
idx_t
*
vsize
,
idx_t
*
adjwgt
);
#endif
#endif
/* SWIFT_DEBUG_H */
src/engine.c
View file @
656df9df
...
...
@@ -55,9 +55,9 @@
#include
"part.h"
#include
"timers.h"
const
char
*
engine_policy_names
[
10
]
=
{
"none"
,
"rand"
,
"steal"
,
"keep"
,
"block"
,
"fix_dt"
,
"cpu_tight"
,
"mpi"
,
"numa_affinity"
};
const
char
*
engine_policy_names
[
10
]
=
{
"none"
,
"rand"
,
"steal"
,
"keep"
,
"block"
,
"fix_dt"
,
"cpu_tight"
,
"mpi"
,
"numa_affinity"
};
/** The rank of the engine as a global variable (for messages). */
int
engine_rank
;
...
...
@@ -1429,8 +1429,8 @@ int engine_marktasks(struct engine *e) {
/* Init? */
else
if
(
t
->
type
==
task_type_init
)
{
/* Set this task's skip. */
t
->
skip
=
(
t
->
ci
->
t_end_min
>
t_end
);
/* Set this task's skip. */
t
->
skip
=
(
t
->
ci
->
t_end_min
>
t_end
);
}
/* None? */
...
...
@@ -1667,7 +1667,8 @@ void engine_collect_kick(struct cell *c) {
* @param submask The sub-task mask to launch.
*/
void
engine_launch
(
struct
engine
*
e
,
int
nr_runners
,
unsigned
int
mask
,
unsigned
int
submask
)
{
void
engine_launch
(
struct
engine
*
e
,
int
nr_runners
,
unsigned
int
mask
,
unsigned
int
submask
)
{
/* Prepare the scheduler. */
atomic_inc
(
&
e
->
sched
.
waiting
);
...
...
@@ -1677,7 +1678,7 @@ void engine_collect_kick(struct cell *c) {
e
->
barrier_launchcount
=
nr_runners
;
if
(
pthread_cond_broadcast
(
&
e
->
barrier_cond
)
!=
0
)
error
(
"Failed to broadcast barrier open condition."
);
/* Load the tasks. */
pthread_mutex_unlock
(
&
e
->
barrier_mutex
);
scheduler_start
(
&
e
->
sched
,
mask
,
submask
);
...
...
@@ -1714,29 +1715,29 @@ void engine_init_particles(struct engine *e) {
message
(
"Initialising particles"
);
space_map_cells_pre
(
s
,
1
,
cell_init_parts
,
NULL
);
//printParticle(e->s->parts, 1000, e->s->nr_parts);
//printParticle(e->s->parts, 515050, e->s->nr_parts);
// printParticle(e->s->parts, 1000, e->s->nr_parts);
// printParticle(e->s->parts, 515050, e->s->nr_parts);
// message("\n0th DENSITY CALC\n");
//message("\n0th DENSITY CALC\n");
/* Now do a density calculation */
TIMER_TIC
;
engine_launch
(
e
,
e
->
nr_threads
,
(
1
<<
task_type_sort
)
|
(
1
<<
task_type_self
)
|
(
1
<<
task_type_pair
)
|
(
1
<<
task_type_sub
)
|
(
1
<<
task_type_init
)
|
(
1
<<
task_type_ghost
)
|
(
1
<<
task_type_send
)
|
(
1
<<
task_type_recv
),
1
<<
task_subtype_density
);
(
1
<<
task_type_pair
)
|
(
1
<<
task_type_sub
)
|
(
1
<<
task_type_init
)
|
(
1
<<
task_type_ghost
)
|
(
1
<<
task_type_send
)
|
(
1
<<
task_type_recv
),
1
<<
task_subtype_density
);
TIMER_TOC
(
timer_runners
);
//message("\n0th ENTROPY CONVERSION\n");
//
message("\n0th ENTROPY CONVERSION\n");
space_map_cells_pre
(
s
,
1
,
cell_convert_hydro
,
NULL
);
//printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
//printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
//
printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
//
printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
/* Ready to go */
e
->
step
=
-
1
;
}
...
...
@@ -1807,25 +1808,24 @@ if ( e->nodeID == 0 )
message( "nr_parts=%i." , nr_parts ); */
#endif
//message("\nDRIFT\n");
//
message("\nDRIFT\n");
/* Move forward in time */
e
->
timeOld
=
e
->
time
;
e
->
time
=
t_end_min
;
e
->
step
+=
1
;
e
->
timeStep
=
e
->
time
-
e
->
timeOld
;
/* Drift everybody */
engine_launch
(
e
,
e
->
nr_threads
,
1
<<
task_type_drift
,
0
);
//printParticle(e->s->parts, e->s->xparts, 1000, e->s->nr_parts);
//printParticle(e->s->parts, e->s->xparts, 515050, e->s->nr_parts);
// printParticle(e->s->parts, e->s->xparts, 1000, e->s->nr_parts);
// printParticle(e->s->parts, e->s->xparts, 515050, e->s->nr_parts);
// if(e->step == 2) exit(0);
// message("\nACCELERATION AND KICK\n");
//if(e->step == 2) exit(0);
//message("\nACCELERATION AND KICK\n");
/* Re-distribute the particles amongst the nodes? */
if
(
e
->
forcerepart
)
engine_repartition
(
e
);
...
...
@@ -1836,23 +1836,22 @@ if ( e->nodeID == 0 )
TIMER_TIC
;
engine_launch
(
e
,
e
->
nr_threads
,
(
1
<<
task_type_sort
)
|
(
1
<<
task_type_self
)
|
(
1
<<
task_type_pair
)
|
(
1
<<
task_type_sub
)
|
(
1
<<
task_type_init
)
|
(
1
<<
task_type_ghost
)
|
(
1
<<
task_type_kick
)
|
(
1
<<
task_type_send
)
|
(
1
<<
task_type_recv
),
(
1
<<
task_subtype_density
)
|
(
1
<<
task_subtype_force
));
(
1
<<
task_type_pair
)
|
(
1
<<
task_type_sub
)
|
(
1
<<
task_type_init
)
|
(
1
<<
task_type_ghost
)
|
(
1
<<
task_type_kick
)
|
(
1
<<
task_type_send
)
|
(
1
<<
task_type_recv
),
(
1
<<
task_subtype_density
)
|
(
1
<<
task_subtype_force
));
TIMER_TOC
(
timer_runners
);
TIMER_TOC2
(
timer_step
);
printf
(
"%d %f %f %d %.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
updates
,
((
double
)
timers
[
timer_count
-
1
])
/
CPU_TPS
*
1000
);
printf
(
"%d %f %f %d %.3f
\n
"
,
e
->
step
,
e
->
time
,
e
->
timeStep
,
updates
,
((
double
)
timers
[
timer_count
-
1
])
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
//printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
//printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
// printParticle(e->s->parts, e->s->xparts,1000, e->s->nr_parts);
// printParticle(e->s->parts, e->s->xparts,515050, e->s->nr_parts);
}