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
3f8a4cfe
Commit
3f8a4cfe
authored
Dec 02, 2012
by
Pedro Gonnet
Browse files
call engine_prepare before each step.
Former-commit-id: db6de0b4654111f68fb0fd87a88858c671edbefe
parent
d40765a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/Makefile.am
View file @
3f8a4cfe
# This file is part of GadgetSMP.
# Coypright (c) 2012 pedro.gonnet@durham.ac.uk.
# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# Matthieu Schaller (matthieu.schaller@durham.ac.uk).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
...
...
@@ -21,7 +22,7 @@ AUTOMAKE_OPTIONS=gnu
# Add the source directory and debug to CFLAGS
AM_CFLAGS
=
-g
-Wall
-Werror
-I
../src
$(OPENMP_CFLAGS)
-DCPU_TPS
=
2.67e9
AM_LDFLAGS
=
$(HDF5_LDFLAGS)
AM_LDFLAGS
=
# Set-up the library
bin_PROGRAMS
=
test
...
...
@@ -29,5 +30,5 @@ bin_PROGRAMS = test
# Sources for test
test_SOURCES
=
test.c
test_CFLAGS
=
-DCOUNTER
-DTIMER
$(AM_CFLAGS)
test_LDADD
=
../src/.libs/libgadgetsmp.a
test_LDADD
=
../src/.libs/libgadgetsmp.a
$(HDF5_LDFLAGS)
examples/test.c
View file @
3f8a4cfe
/*******************************************************************************
* This file is part of GadgetSMP.
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
...
...
@@ -352,7 +353,7 @@ void read_id ( char *fname , struct part *parts , int N ) {
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%li"
,
&
parts
[
k
].
id
)
!=
1
)
{
if
(
sscanf
(
buff
,
"%
l
li"
,
&
parts
[
k
].
id
)
!=
1
)
{
printf
(
"read_id: failed to parse %ith entry.
\n
"
,
k
);
error
(
"Error parsing id file."
);
}
...
...
@@ -406,7 +407,7 @@ void read_dt ( char *fname , struct part *parts , int N ) {
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%
i
"
,
&
parts
[
k
].
dt
)
!=
1
)
if
(
sscanf
(
buff
,
"%
f
"
,
&
parts
[
k
].
dt
)
!=
1
)
error
(
"Error parsing dt file."
);
}
...
...
@@ -532,7 +533,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
if
(
r2
<
p
->
h
*
p
->
h
)
{
runner_iact_density
(
r2
,
NULL
,
p
->
h
,
parts
[
k
].
h
,
p
,
&
parts
[
k
]
);
printf
(
"runner_dopair: interacting particles %i [%i,%i,%i] and %li [%i,%i,%i].
\n
"
,
printf
(
"runner_dopair: interacting particles %i [%i,%i,%i] and %
l
li [%i,%i,%i].
\n
"
,
pid
,
(
int
)(
parts
[
pid
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
2
]
*
ih
)
,
parts
[
k
].
id
,
(
int
)(
parts
[
k
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
2
]
*
ih
)
);
parts
[
k
].
rho
=
0
.
0
;
...
...
@@ -542,7 +543,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
}
/* Dump the result. */
printf
(
"pairs_single: wcount of part %li (h=%e) is %.3f (nr. pairs %i).
\n
"
,
p
->
id
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
printf
(
"pairs_single: wcount of part %
l
li (h=%e) is %.3f (nr. pairs %i).
\n
"
,
p
->
id
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
fflush
(
stdout
);
p
->
rho
=
0
.
0
;
...
...
@@ -590,7 +591,7 @@ void pairs_single_old ( double *dim , struct part *__restrict__ parts , int N ,
}
r
=
sqrt
(
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
]
);
if
(
r
<
th
)
printf
(
"pairs_single: %i %li [%e,%e,%e] %e
\n
"
,
printf
(
"pairs_single: %i %
l
li [%e,%e,%e] %e
\n
"
,
tid
,
parts
[
k
].
id
,
dx
[
0
]
,
dx
[
1
]
,
dx
[
2
]
,
r
);
}
...
...
@@ -633,25 +634,31 @@ int main ( int argc , char *argv[] ) {
struct
space
s
;
struct
engine
e
;
char
ICfileName
[
200
];
float
dt
=
1
.
0
f
;
ticks
tic
;
/* Init the space. */
bzero
(
&
s
,
sizeof
(
struct
space
)
);
/* Parse the options */
while
(
(
c
=
getopt
(
argc
,
argv
,
"
f:a
:m:s:t:q:r:z:"
)
)
!=
-
1
)
while
(
(
c
=
getopt
(
argc
,
argv
,
"
a:d:f
:m:s:t:q:r:z:"
)
)
!=
-
1
)
switch
(
c
)
{
case
'f'
:
if
(
!
strcpy
(
ICfileName
,
optarg
))
error
(
"Error parsing IC file name."
);
printf
(
"main: IC to be read from file '%s'
\n
"
,
ICfileName
);
break
;
case
'a'
:
if
(
sscanf
(
optarg
,
"%lf"
,
&
scaling
)
!=
1
)
error
(
"Error parsing cutoff scaling."
);
printf
(
"main: scaling cutoff by %.3f.
\n
"
,
scaling
);
fflush
(
stdout
);
break
;
case
'd'
:
if
(
sscanf
(
optarg
,
"%f"
,
&
dt
)
!=
1
)
error
(
"Error parsing timestep."
);
printf
(
"main: dt set to %.3f.
\n
"
,
dt
);
fflush
(
stdout
);
break
;
case
'f'
:
if
(
!
strcpy
(
ICfileName
,
optarg
))
error
(
"Error parsing IC file name."
);
printf
(
"main: IC to be read from file '%s'
\n
"
,
ICfileName
);
break
;
case
'm'
:
if
(
sscanf
(
optarg
,
"%lf"
,
&
h_max
)
!=
1
)
error
(
"Error parsing h_max."
);
...
...
@@ -816,6 +823,10 @@ int main ( int argc , char *argv[] ) {
space_init
(
&
s
,
dim
,
parts
,
N
,
periodic
,
h_max
);
printf
(
"main: space_init took %.3f ms.
\n
"
,
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
/* Set the default time step to 1.0f. */
s
.
dt
=
dt
;
printf
(
"main: space dt is %f.
\n
"
,
s
.
dt
);
/* Say a few nice things about the space we just created. */
printf
(
"main: space dimensions are [ %.3f %.3f %.3f ].
\n
"
,
s
.
dim
[
0
]
,
s
.
dim
[
1
]
,
s
.
dim
[
2
]
);
printf
(
"main: space %s periodic.
\n
"
,
s
.
periodic
?
"is"
:
"isn't"
);
...
...
@@ -856,7 +867,6 @@ int main ( int argc , char *argv[] ) {
/* Let loose a runner on the space. */
for
(
j
=
0
;
j
<
runs
;
j
++
)
{
printf
(
"main: starting run %i/%i with %i threads and %i queues...
\n
"
,
j
+
1
,
runs
,
e
.
nr_threads
,
e
.
nr_queues
);
fflush
(
stdout
);
tic
=
getticks
();
#ifdef TIMER
for
(
k
=
0
;
k
<
runner_timer_count
;
k
++
)
runner_timer
[
k
]
=
0
;
...
...
@@ -869,6 +879,10 @@ int main ( int argc , char *argv[] ) {
for
(
k
=
0
;
k
<
runner_counter_count
;
k
++
)
runner_counter
[
k
]
=
0
;
#endif
tic
=
getticks
();
engine_prepare
(
&
e
,
0
);
printf
(
"main: engine_prepare took %.3f ms.
\n
"
,
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
tic
=
getticks
();
engine_run
(
&
e
,
0
);
#ifdef TIMER
printf
(
"main: runner timers are [ %.3f"
,
runner_timer
[
0
]
/
CPU_TPS
*
1000
);
...
...
@@ -921,7 +935,7 @@ int main ( int argc , char *argv[] ) {
/* Get the particle with the lowest wcount. */
p
=
&
s
.
parts
[
0
];
space_map_parts
(
&
s
,
&
map_wcount_min
,
&
p
);
printf
(
"main: particle %li/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).
\n
"
,
printf
(
"main: particle %
l
li/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).
\n
"
,
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
/* Loop over all the tasks and dump the ones containing p. */
...
...
@@ -960,7 +974,7 @@ int main ( int argc , char *argv[] ) {
/* Get the particle with the highest wcount. */
p
=
&
s
.
parts
[
0
];
space_map_parts
(
&
s
,
&
map_wcount_max
,
&
p
);
printf
(
"main: particle %li/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).
\n
"
,
printf
(
"main: particle %
l
li/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).
\n
"
,
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
/* Get the average interactions per particle. */
...
...
@@ -969,7 +983,7 @@ int main ( int argc , char *argv[] ) {
printf
(
"main: average neighbours per particle is %.3f.
\n
"
,
(
double
)
icount
/
s
.
nr_parts
);
/* Dump the acceleration of the first particle. */
printf
(
"main: parts[%li].a is [ %.16e %.16e %.16e ].
\n
"
,
s
.
parts
[
6178
].
id
,
s
.
parts
[
6178
].
a
[
0
]
,
s
.
parts
[
6178
].
a
[
1
]
,
s
.
parts
[
6178
].
a
[
2
]
);
printf
(
"main: parts[%
l
li].a is [ %.16e %.16e %.16e ].
\n
"
,
s
.
parts
[
6178
].
id
,
s
.
parts
[
6178
].
a
[
0
]
,
s
.
parts
[
6178
].
a
[
1
]
,
s
.
parts
[
6178
].
a
[
2
]
);
/* Get all the cells of a certain depth. */
// icount = 1;
...
...
examples/test_mc.sh
View file @
3f8a4cfe
...
...
@@ -23,10 +23,10 @@ do
export
OMP_THREAD_LIMIT
=
$cpu
export
OMP_PROC_BIND
=
TRUE
./test
-r
1000
-t
$cpu
-b
"1400 1400 1400"
-N
74240
-c
small/Coordinates.txt.gz
-s
"700 700 700"
-p
0
-h
small/SmoothingLength.txt.gz
-m
470
-z
200
>
small_
${
cpu
}
.dump
#
./test -r 1000 -t $cpu -b "1400 1400 1400" -N 74240 -c small/Coordinates.txt.gz -s "700 700 700" -p 0 -h small/SmoothingLength.txt.gz -m 470 -z 200 > small_${cpu}.dump
./test
-r
100
-t
$cpu
-b
"100 100 100"
-N
3558892
-c
snap_C09/Coordinates.txt.gz
-s
"50 50 50"
-p
0
-h
snap_C09/SmoothingLength.txt.gz
-m
6.138
>
snap_C09_
${
cpu
}
.dump
#
./test -r 100 -t $cpu -b "100 100 100" -N 3558892 -c snap_C09/Coordinates.txt.gz -s "50 50 50" -p 0 -h snap_C09/SmoothingLength.txt.gz -m 6.138 > snap_C09_${cpu}.dump
./test
-r
100
-t
$cpu
-
b
"6.25 6.25 6.25"
-N
1841127
-c
scaling/Coordinates.txt.gz
-p
1
-h
scaling/SmoothingLength.txt.gz
-m
0.5
-z
200
>
scaling_
${
cpu
}
.dump
./test
-r
100
-t
$cpu
-
f
scaling/snap_023_z000p503.hdf5
-m
0.5
-z
200
>
scaling_
${
cpu
}
.dump
done
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