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
d891c77f
Commit
d891c77f
authored
Sep 22, 2016
by
Matthieu Schaller
Browse files
Merge branch 'master' into mark_tasks_in_drift
parents
08d5d289
58d36dd4
Changes
64
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
d891c77f
...
...
@@ -155,6 +155,21 @@ LT_INIT
AC_PROG_CC_C99
AC_C_INLINE
# If debugging try to show inlined functions.
if test "x$enable_debug" = "xyes"; then
# Show inlined functions.
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
# Would like to use -gdwarf and let the compiler pick a good version
# but that doesn't always work.
AX_CHECK_COMPILE_FLAG([-gdwarf -fvar-tracking-assignments],
[inline_EXTRA_FLAGS="-gdwarf -fvar-tracking-assignments"],
[inline_EXTRA_FLAGS="-gdwarf-2 -fvar-tracking-assignments"])
CFLAGS="$CFLAGS $inline_EXTRA_FLAGS"
elif test "$ax_cv_c_compiler_vendor" = "intel"; then
CFLAGS="$CFLAGS -debug inline-debug-info"
fi
fi
# Define HAVE_POSIX_MEMALIGN if it works.
AX_FUNC_POSIX_MEMALIGN
...
...
@@ -451,7 +466,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(
AC_MSG_RESULT($rtc_ok)
# Add warning flags by default, if these can be used. Option =error adds
# -Werror to GCC, clang and Intel. Note do this last as compiler tests may
# -Werror to GCC, clang and Intel. Note do this last as compiler tests may
# become errors, if that's an issue don't use CFLAGS for these, use an AC_SUBST().
AC_ARG_ENABLE([compiler-warnings],
[AS_HELP_STRING([--enable-compiler-warnings],
...
...
@@ -461,7 +476,7 @@ AC_ARG_ENABLE([compiler-warnings],
[enable_warn="error"]
)
if test "$enable_warn" != "no"; then
# AX_CFLAGS_WARN_ALL does not give good warning flags for the Intel compiler
# We will do this by hand instead and only default to the macro for unknown compilers
case "$ax_cv_c_compiler_vendor" in
...
...
@@ -475,7 +490,7 @@ if test "$enable_warn" != "no"; then
AX_CFLAGS_WARN_ALL
;;
esac
# Add a "choke on warning" flag if it exists
if test "$enable_warn" = "error"; then
case "$ax_cv_c_compiler_vendor" in
...
...
examples/DiscPatch/HydroStatic/dynamic.pro
View file @
d891c77f
...
...
@@ -8,7 +8,8 @@ iplot = 1 ; if iplot = 1, make plot of E/Lz conservation, else, simply compare f
@
physunits
indir
=
'./'
basefile
=
'Disk-Patch-dynamic_'
;
basefile
=
'Disc-Patch-dynamic_'
basefile
=
'Disc-Patch_'
;
set
properties
of
potential
uL
=
phys
.
pc
;
unit
of
length
...
...
@@ -16,18 +17,27 @@ uM = phys.msun ; unit of mass
uV
=
1
d5
;
unit
of
velocity
;
properties
of
patch
surface_density
=
10
.
surface_density
=
10
0
.
;
surface
density
of
all
mass
,
which
generates
the
gravitational
potential
scale_height
=
100
.
z_disk
=
200
.;
z_disk
=
200
.
;
fgas
=
0.1
;
gas
fraction
gamma
=
5
.
/
3
.
;
derived
units
constG
=
10
.
^
(
alog10
(
phys
.
g
)
+
alog10
(
uM
)
-
2
d0
*
alog10
(
uV
)
-
alog10
(
uL
))
;
pcentre
=
[
0
.,
0
.,
z_disk
]
*
pc
/
uL
utherm
=
!
pi
*
constG
*
surface_density
*
scale_height
/
(
gamma
-
1
.)
temp
=
(
utherm
*
uV
^
2
)
*
phys
.
m_h
/
phys
.
kb
soundspeed
=
sqrt
(
gamma
*
(
gamma
-
1
.)
*
utherm
)
t_dyn
=
sqrt
(
scale_height
/
(
constG
*
surface_density
))
rho0
=
fgas
*
(
surface_density
)
/
(
2
.
*
scale_height
)
print
,
' dynamical time = '
,
t_dyn
,
' = '
,
t_dyn
*
UL
/
uV
/
(
1
d6
*
phys
.
yr
),
' Myr'
print
,
' thermal energy per unit mass = '
,
utherm
print
,
' central density = '
,
rho0
,
' = '
,
rho0
*
uM
/
uL
^
3
/
m_h
,
' particles/cm^3'
print
,
' central temperature = '
,
temp
lambda
=
2
*
!
pi
*
phys
.
G
^
1.5
*
(
scale_height
*
uL
)
^
1.5
*
(
surface_density
*
uM
/
uL
^
2
)
^
0.5
*
phys
.
m_h
^
2
/
(
gamma
-
1
)
/
fgas
print
,
' lambda = '
,
lambda
stop
;
infile
=
indir
+
basefile
+
'*'
spawn
,
'ls -1 '
+
infile
,
res
...
...
examples/DiscPatch/HydroStatic/makeIC.py
View file @
d891c77f
...
...
@@ -56,9 +56,10 @@ print "UnitVelocity_in_cgs: ", const_unit_velocity_in_cgs
# parameters of potential
surface_density
=
10
.
surface_density
=
10
0.
# surface density of all mass, which generates the gravitational potential
scale_height
=
100.
gamma
=
5.
/
3.
fgas
=
0.1
# gas fraction
# derived units
const_unit_time_in_cgs
=
(
const_unit_length_in_cgs
/
const_unit_velocity_in_cgs
)
...
...
@@ -131,7 +132,7 @@ h = glass_h[0:numGas]
numGas
=
numpy
.
shape
(
pos
)[
0
]
# compute furthe properties of ICs
column_density
=
surface_density
*
numpy
.
tanh
(
boxSize
/
2.
/
scale_height
)
column_density
=
fgas
*
surface_density
*
numpy
.
tanh
(
boxSize
/
2.
/
scale_height
)
enclosed_mass
=
column_density
*
boxSize
*
boxSize
pmass
=
enclosed_mass
/
numGas
meanrho
=
enclosed_mass
/
boxSize
**
3
...
...
examples/EAGLE_25/README
View file @
d891c77f
...
...
@@ -13,4 +13,4 @@ The particle load of the main EAGLE simulation can be reproduced by
running these ICs on 64 cores.
MD5 checksum of the ICs:
ada2c728db2bd2d77a20c4eef52dfaf1
EAGLE_ICs_25.hdf5
02cd1c353b86230af047b5d4ab22afcf
EAGLE_ICs_25.hdf5
examples/Feedback/feedback.pro
0 → 100644
View file @
d891c77f
base
=
'Feedback'
inf
=
'Feedback_005.hdf5'
blast
=
[
5.650488
e
-
01
,
5.004371
e
-
01
,
5.010494
e
-
01
]
;
location
of
blast
pos
=
h5rd
(
inf
,
'PartType0/Coordinates'
)
vel
=
h5rd
(
inf
,
'PartType0/Velocities'
)
rho
=
h5rd
(
inf
,
'PartType0/Density'
)
utherm
=
h5rd
(
inf
,
'PartType0/InternalEnergy'
)
;
shift
to
centre
for
ic
=
0
,
2
do
pos
[
ic
,
*
]
=
pos
[
ic
,
*
]
-
blast
[
ic
]
;;
distance
from
centre
dist
=
fltarr
(
n_elements
(
rho
))
for
ic
=
0
,
2
do
dist
=
dist
+
pos
[
ic
,
*
]
^
2
dist
=
sqrt
(
dist
)
;
radial
velocity
vr
=
fltarr
(
n_elements
(
rho
))
for
ic
=
0
,
2
do
vr
=
vr
+
pos
[
ic
,
*
]
*
vel
[
ic
,
*
]
vr
=
vr
/
dist
;
end
examples/Feedback/feedback.yml
0 → 100644
View file @
d891c77f
# Define the system of units to use internally.
InternalUnitSystem
:
UnitMass_in_cgs
:
1
# Grams
UnitLength_in_cgs
:
1
# Centimeters
UnitVelocity_in_cgs
:
1
# Centimeters per second
UnitCurrent_in_cgs
:
1
# Amperes
UnitTemp_in_cgs
:
1
# Kelvin
# Parameters governing the time integration
TimeIntegration
:
time_begin
:
0.
# The starting time of the simulation (in internal units).
time_end
:
5e-2
# The end time of the simulation (in internal units).
dt_min
:
1e-7
# The minimal time-step size of the simulation (in internal units).
dt_max
:
1e-4
# The maximal time-step size of the simulation (in internal units).
# Parameters governing the snapshots
Snapshots
:
basename
:
Feedback
# Common part of the name of output files
time_first
:
0.
# Time of the first output (in internal units)
delta_time
:
1e-2
# Time difference between consecutive outputs (in internal units)
# Parameters governing the conserved quantities statistics
Statistics
:
delta_time
:
1e-3
# Time between statistics output
# Parameters for the hydrodynamics scheme
SPH
:
resolution_eta
:
1.2348
# Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
delta_neighbours
:
0.1
# The tolerance for the targetted number of neighbours.
max_smoothing_length
:
0.1
# Maximal smoothing length allowed (in internal units).
CFL_condition
:
0.1
# Courant-Friedrich-Levy condition for time integration.
# Parameters related to the initial conditions
InitialConditions
:
file_name
:
./Feedback.hdf5
# The file to read
# Parameters for feedback
SN
:
time
:
0.001
# time the SN explodes (internal units)
energy
:
1.0
# energy of the explosion (internal units)
x
:
0.5
# x-position of explostion (internal units)
y
:
0.5
# y-position of explostion (internal units)
z
:
0.5
# z-position of explostion (internal units)
examples/Feedback/makeIC.py
0 → 100644
View file @
d891c77f
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# Matthieu Schaller (matthieu.schaller@durham.ac.uk)
# 2016 Tom Theuns (tom.theuns@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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import
h5py
import
sys
from
numpy
import
*
# Generates a swift IC file containing a cartesian distribution of particles
# at a constant density and pressure in a cubic box
# Parameters
periodic
=
1
# 1 For periodic box
boxSize
=
1.
L
=
int
(
sys
.
argv
[
1
])
# Number of particles along one axis
rho
=
1.
# Density
P
=
1.e-6
# Pressure
gamma
=
5.
/
3.
# Gas adiabatic index
eta
=
1.2349
# 48 ngbs with cubic spline kernel
fileName
=
"Feedback.hdf5"
#---------------------------------------------------
numPart
=
L
**
3
mass
=
boxSize
**
3
*
rho
/
numPart
internalEnergy
=
P
/
((
gamma
-
1.
)
*
rho
)
#--------------------------------------------------
#File
file
=
h5py
.
File
(
fileName
,
'w'
)
# Header
grp
=
file
.
create_group
(
"/Header"
)
grp
.
attrs
[
"BoxSize"
]
=
boxSize
grp
.
attrs
[
"NumPart_Total"
]
=
[
numPart
,
0
,
0
,
0
,
0
,
0
]
grp
.
attrs
[
"NumPart_Total_HighWord"
]
=
[
0
,
0
,
0
,
0
,
0
,
0
]
grp
.
attrs
[
"NumPart_ThisFile"
]
=
[
numPart
,
0
,
0
,
0
,
0
,
0
]
grp
.
attrs
[
"Time"
]
=
0.0
grp
.
attrs
[
"NumFilesPerSnapshot"
]
=
1
grp
.
attrs
[
"MassTable"
]
=
[
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
]
grp
.
attrs
[
"Flag_Entropy_ICs"
]
=
0
#Runtime parameters
grp
=
file
.
create_group
(
"/RuntimePars"
)
grp
.
attrs
[
"PeriodicBoundariesOn"
]
=
periodic
#Units
grp
=
file
.
create_group
(
"/Units"
)
grp
.
attrs
[
"Unit length in cgs (U_L)"
]
=
1.
grp
.
attrs
[
"Unit mass in cgs (U_M)"
]
=
1.
grp
.
attrs
[
"Unit time in cgs (U_t)"
]
=
1.
grp
.
attrs
[
"Unit current in cgs (U_I)"
]
=
1.
grp
.
attrs
[
"Unit temperature in cgs (U_T)"
]
=
1.
#Particle group
grp
=
file
.
create_group
(
"/PartType0"
)
v
=
zeros
((
numPart
,
3
))
ds
=
grp
.
create_dataset
(
'Velocities'
,
(
numPart
,
3
),
'f'
)
ds
[()]
=
v
v
=
zeros
(
1
)
m
=
full
((
numPart
,
1
),
mass
)
ds
=
grp
.
create_dataset
(
'Masses'
,
(
numPart
,
1
),
'f'
)
ds
[()]
=
m
m
=
zeros
(
1
)
h
=
full
((
numPart
,
1
),
eta
*
boxSize
/
L
)
ds
=
grp
.
create_dataset
(
'SmoothingLength'
,
(
numPart
,
1
),
'f'
)
ds
[()]
=
h
h
=
zeros
(
1
)
u
=
full
((
numPart
,
1
),
internalEnergy
)
ds
=
grp
.
create_dataset
(
'InternalEnergy'
,
(
numPart
,
1
),
'f'
)
ds
[()]
=
u
u
=
zeros
(
1
)
ids
=
linspace
(
0
,
numPart
,
numPart
,
endpoint
=
False
).
reshape
((
numPart
,
1
))
ds
=
grp
.
create_dataset
(
'ParticleIDs'
,
(
numPart
,
1
),
'L'
)
ds
[()]
=
ids
+
1
x
=
ids
%
L
;
y
=
((
ids
-
x
)
/
L
)
%
L
;
z
=
(
ids
-
x
-
L
*
y
)
/
L
**
2
;
coords
=
zeros
((
numPart
,
3
))
coords
[:,
0
]
=
z
[:,
0
]
*
boxSize
/
L
+
boxSize
/
(
2
*
L
)
coords
[:,
1
]
=
y
[:,
0
]
*
boxSize
/
L
+
boxSize
/
(
2
*
L
)
coords
[:,
2
]
=
x
[:,
0
]
*
boxSize
/
L
+
boxSize
/
(
2
*
L
)
ds
=
grp
.
create_dataset
(
'Coordinates'
,
(
numPart
,
3
),
'd'
)
ds
[()]
=
coords
file
.
close
()
examples/SedovBlast_1D/sedov.yml
View file @
d891c77f
...
...
@@ -21,7 +21,7 @@ Snapshots:
# Parameters governing the conserved quantities statistics
Statistics
:
delta_time
:
1e-
3
# Time between statistics output
delta_time
:
1e-
5
# Time between statistics output
# Parameters for the hydrodynamics scheme
SPH
:
...
...
examples/main.c
View file @
d891c77f
...
...
@@ -76,6 +76,7 @@ void print_help_message() {
"Overwrite the CPU frequency (Hz) to be used for time measurements"
);
printf
(
" %2s %8s %s
\n
"
,
"-g"
,
""
,
"Run with an external gravitational potential"
);
printf
(
" %2s %8s %s
\n
"
,
"-F"
,
""
,
"Run with feedback "
);
printf
(
" %2s %8s %s
\n
"
,
"-G"
,
""
,
"Run with self-gravity"
);
printf
(
" %2s %8s %s
\n
"
,
"-n"
,
"{int}"
,
"Execute a fixed number of time steps. When unset use the time_end "
...
...
@@ -147,6 +148,7 @@ int main(int argc, char *argv[]) {
int
nsteps
=
-
2
;
int
with_cosmology
=
0
;
int
with_external_gravity
=
0
;
int
with_sourceterms
=
0
;
int
with_cooling
=
0
;
int
with_self_gravity
=
0
;
int
with_hydro
=
0
;
...
...
@@ -159,7 +161,7 @@ int main(int argc, char *argv[]) {
/* Parse the parameters */
int
c
;
while
((
c
=
getopt
(
argc
,
argv
,
"acCdDef:gGhn:st:v:y:"
))
!=
-
1
)
switch
(
c
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"acCdDef:
F
gGhn:st:v:y:"
))
!=
-
1
)
switch
(
c
)
{
case
'a'
:
with_aff
=
1
;
break
;
...
...
@@ -185,6 +187,9 @@ int main(int argc, char *argv[]) {
return
1
;
}
break
;
case
'F'
:
with_sourceterms
=
1
;
break
;
case
'g'
:
with_external_gravity
=
1
;
break
;
...
...
@@ -444,6 +449,11 @@ int main(int argc, char *argv[]) {
if
(
with_cooling
)
cooling_init
(
params
,
&
us
,
&
prog_const
,
&
cooling_func
);
if
(
with_cooling
&&
myrank
==
0
)
cooling_print
(
&
cooling_func
);
/* Initialise the feedback properties */
struct
sourceterms
sourceterms
;
if
(
with_sourceterms
)
sourceterms_init
(
params
,
&
us
,
&
sourceterms
);
if
(
with_sourceterms
&&
myrank
==
0
)
sourceterms_print
(
&
sourceterms
);
/* Construct the engine policy */
int
engine_policies
=
ENGINE_POLICY
|
engine_policy_steal
;
if
(
with_drift_all
)
engine_policies
|=
engine_policy_drift_all
;
...
...
@@ -452,13 +462,14 @@ int main(int argc, char *argv[]) {
if
(
with_external_gravity
)
engine_policies
|=
engine_policy_external_gravity
;
if
(
with_cosmology
)
engine_policies
|=
engine_policy_cosmology
;
if
(
with_cooling
)
engine_policies
|=
engine_policy_cooling
;
if
(
with_sourceterms
)
engine_policies
|=
engine_policy_sourceterms
;
/* Initialize the engine with the space and policies. */
if
(
myrank
==
0
)
clocks_gettime
(
&
tic
);
struct
engine
e
;
engine_init
(
&
e
,
&
s
,
params
,
nr_nodes
,
myrank
,
nr_threads
,
with_aff
,
engine_policies
,
talking
,
&
us
,
&
prog_const
,
&
hydro_properties
,
&
potential
,
&
cooling_func
);
&
potential
,
&
cooling_func
,
&
sourceterms
);
if
(
myrank
==
0
)
{
clocks_gettime
(
&
toc
);
message
(
"engine_init took %.3f %s."
,
clocks_diff
(
&
tic
,
&
toc
),
...
...
examples/parameter_example.yml
View file @
d891c77f
...
...
@@ -12,6 +12,7 @@ Scheduler:
cell_max_size
:
8000000
# (Optional) Maximal number of interactions per task if we force the split (this is the default value).
cell_sub_size
:
64000000
# (Optional) Maximal number of interactions per sub-task (this is the default value).
cell_split_size
:
400
# (Optional) Maximal number of particles per cell (this is the default value).
cell_max_count
:
10000
# (Optional) Maximal number of particles per cell allowed before triggering a sanitizing (this is the default value).
# Parameters governing the time integration
TimeIntegration
:
...
...
examples/plot_scaling_results.py
View file @
d891c77f
...
...
@@ -131,8 +131,10 @@ def parse_files():
file_list
=
[
file_list
[
j
]
for
j
in
sorted_indices
]
parse_header
(
file_list
[
0
])
branch
[
i
]
=
branch
[
i
].
replace
(
"_"
,
"
\\
_"
)
version
.
append
(
branch
[
i
]
+
" "
+
revision
[
i
]
+
"
\n
"
+
hydro_scheme
[
i
]
+
version
.
append
(
"$
\\
textrm{%s}$"
%
str
(
branch
[
i
]
)
+
" "
+
revision
[
i
]
+
"
\n
"
+
hydro_scheme
[
i
]
+
"
\n
"
+
hydro_kernel
[
i
]
+
r
", $N_{ngb}=%d$"
%
float
(
hydro_neighbours
[
i
])
+
r
", $\eta=%.3f$"
%
float
(
hydro_eta
[
i
]))
times
.
append
([])
...
...
@@ -215,14 +217,21 @@ def plot_results(times,totalTime,speedUp,parallelEff):
pts
=
[
1
,
10
**
np
.
floor
(
np
.
log10
(
threadList
[
i
][
-
1
])
+
1
)]
totalTimePlot
.
loglog
(
pts
,
totalTime
[
i
][
0
]
/
pts
,
'k--'
,
lw
=
1.
,
color
=
'0.2'
)
totalTimePlot
.
loglog
(
threadList
[
i
],
totalTime
[
i
],
linestyle
[
i
],
label
=
version
[
i
])
y_min
=
10
**
np
.
floor
(
np
.
log10
(
np
.
min
(
totalTime
[:][
-
1
])
*
0.6
))
y_max
=
1.2
*
10
**
np
.
floor
(
np
.
log10
(
np
.
max
(
totalTime
[:][
0
])
*
1.5
)
+
1
)
totalTimePlot
.
set_xscale
(
'log'
)
totalTimePlot
.
set_xlabel
(
"${
\\
rm Threads}$"
,
labelpad
=
0.
)
totalTimePlot
.
set_ylabel
(
"${
\\
rm Time~to~solution}~[{
\\
rm ms}]$"
,
labelpad
=
0.
)
totalTimePlot
.
set_xlim
([
0.9
,
10
**
(
np
.
floor
(
np
.
log10
(
threadList
[
i
][
-
1
]))
+
0.5
)])
totalTimePlot
.
set_ylim
([
10
**
np
.
floor
(
np
.
log10
(
np
.
min
(
totalTime
)
*
0.6
)),
1.2
*
10
**
np
.
floor
(
np
.
log10
(
np
.
max
(
totalTime
)
*
1.5
)
+
1
)])
totalTimePlot
.
set_ylim
(
y_min
,
y_max
)
ax2
=
totalTimePlot
.
twinx
()
ax2
.
set_yscale
(
'log'
)
ax2
.
set_ylabel
(
"${
\\
rm Time~to~solution}~[{
\\
rm hr}]$"
,
labelpad
=
0.
)
ax2
.
set_ylim
(
y_min
/
3.6e6
,
y_max
/
3.6e6
)
totalTimePlot
.
legend
(
bbox_to_anchor
=
(
1.1
4
,
0.97
),
loc
=
2
,
borderaxespad
=
0.
,
prop
=
{
'size'
:
12
},
frameon
=
False
)
totalTimePlot
.
legend
(
bbox_to_anchor
=
(
1.
2
1
,
0.97
),
loc
=
2
,
borderaxespad
=
0.
,
prop
=
{
'size'
:
12
},
frameon
=
False
)
emptyPlot
.
axis
(
'off'
)
for
i
,
txt
in
enumerate
(
threadList
[
0
]):
...
...
examples/plot_tasks.py
View file @
d891c77f
...
...
@@ -56,8 +56,9 @@ pl.rcParams.update(PLOT_PARAMS)
# Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES
=
[
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub_self"
,
"sub_pair"
,
"init"
,
"ghost"
,
"kick"
,
"kick_fixdt"
,
"send"
,
"recv"
,
"grav_gather_m"
,
"grav_fft"
,
"grav_mm"
,
"grav_up"
,
"grav_external"
,
"count"
]
"extra_ghost"
,
"kick"
,
"kick_fixdt"
,
"send"
,
"recv"
,
"grav_gather_m"
,
"grav_fft"
,
"grav_mm"
,
"grav_up"
,
"grav_external"
,
"cooling"
,
"count"
]
TASKCOLOURS
=
{
"none"
:
"black"
,
"sort"
:
"lightblue"
,
...
...
@@ -67,6 +68,7 @@ TASKCOLOURS = {"none": "black",
"sub_pair"
:
"navy"
,
"init"
:
"indigo"
,
"ghost"
:
"cyan"
,
"extra_ghost"
:
"cyan"
,
"kick"
:
"green"
,
"kick_fixdt"
:
"green"
,
"send"
:
"yellow"
,
...
...
@@ -76,6 +78,7 @@ TASKCOLOURS = {"none": "black",
"grav_mm"
:
"mediumturquoise"
,
"grav_up"
:
"mediumvioletred"
,
"grav_external"
:
"darkred"
,
"cooling"
:
"darkblue"
,
"count"
:
"powerblue"
}
SUBTYPES
=
[
"none"
,
"density"
,
"gradient"
,
"force"
,
"grav"
,
"tend"
,
"count"
]
...
...
@@ -118,7 +121,7 @@ toc_step = int(full_step[5])
CPU_CLOCK
=
float
(
full_step
[
-
1
])
data
=
data
[
1
:,:]
print
"CPU frequency:"
,
CPU_CLOCK
/
1.e9
print
"CPU frequency:"
,
CPU_CLOCK
# Avoid start and end times of zero.
data
=
data
[
data
[:,
4
]
!=
0
]
...
...
@@ -130,6 +133,7 @@ if delta_t == 0:
dt
=
max
(
data
[:,
5
])
-
min
(
data
[:,
4
])
if
dt
>
delta_t
:
delta_t
=
dt
print
"Data range: "
,
delta_t
/
CPU_CLOCK
*
1000
,
"ms"
# Once more doing the real gather and plots this time.
start_t
=
tic_step
...
...
examples/plot_tasks_MPI.py
View file @
d891c77f
...
...
@@ -2,7 +2,7 @@
"""
Usage:
plot_tasks_MPI.py input.dat png-output-prefix [time-range-ms]
where input.dat is a thread info file for a step of an MPI run. Use the '-y
interval' flag of the swift MPI commands to create these. The output plots
will be called 'png-output-prefix<mpi-rank>.png', i.e. one each for all the
...
...
@@ -40,6 +40,8 @@ matplotlib.use("Agg")
import
pylab
as
pl
import
numpy
as
np
import
sys
#import warnings
#warnings.simplefilter("error")
# Basic plot configuration.
PLOT_PARAMS
=
{
"axes.labelsize"
:
10
,
...
...
@@ -61,9 +63,10 @@ PLOT_PARAMS = {"axes.labelsize": 10,
pl
.
rcParams
.
update
(
PLOT_PARAMS
)
# Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES
=
[
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub_self"
,
"sub_pair"
,
"init"
,
"ghost"
,
"kick"
,
"kick_fixdt"
,
"send"
,
"recv"
,
"grav_gather_m"
,
"grav_fft"
,
"grav_mm"
,
"grav_up"
,
"grav_external"
,
"count"
]
TASKTYPES
=
[
"none"
,
"sort"
,
"self"
,
"pair"
,
"sub_self"
,
"sub_pair"
,
"init"
,
"ghost"
,
"extra_ghost"
,
"kick"
,
"kick_fixdt"
,
"send"
,
"recv"
,
"grav_gather_m"
,
"grav_fft"
,
"grav_mm"
,
"grav_up"
,
"grav_external"
,
"cooling"
,
"count"
]
TASKCOLOURS
=
{
"none"
:
"black"
,
"sort"
:
"lightblue"
,
...
...
@@ -73,6 +76,7 @@ TASKCOLOURS = {"none": "black",
"sub_pair"
:
"navy"
,
"init"
:
"indigo"
,
"ghost"
:
"cyan"
,
"extra_ghost"
:
"cyan"
,
"kick"
:
"green"
,
"kick_fixdt"
:
"green"
,
"send"
:
"yellow"
,
...
...
@@ -82,6 +86,7 @@ TASKCOLOURS = {"none": "black",
"grav_mm"
:
"mediumturquoise"
,
"grav_up"
:
"mediumvioletred"
,
"grav_external"
:
"darkred"
,
"cooling"
:
"darkblue"
,
"count"
:
"powerblue"
}
SUBTYPES
=
[
"none"
,
"density"
,
"gradient"
,
"force"
,
"grav"
,
"tend"
,
"count"
]
...
...
@@ -111,7 +116,7 @@ outbase = sys.argv[2]
delta_t
=
0
if
len
(
sys
.
argv
)
==
4
:
delta_t
=
int
(
sys
.
argv
[
3
])
# Read input.
data
=
pl
.
loadtxt
(
infile
)
...
...
@@ -121,7 +126,7 @@ tic_step = int(full_step[5])
toc_step
=
int
(
full_step
[
6
])
CPU_CLOCK
=
float
(
full_step
[
-
1
])
print
"CPU frequency:"
,
CPU_CLOCK
/
1.e9
print
"CPU frequency:"
,
CPU_CLOCK
nranks
=
int
(
max
(
data
[:,
0
]))
+
1
...
...
@@ -143,6 +148,8 @@ if delta_t == 0:
dt
=
max
(
data
[:,
6
])
-
min
(
data
[:,
5
])
if
dt
>
delta_t
:
delta_t
=
dt
print
"Data range: "
,
delta_t
/
CPU_CLOCK
*
1000
,
"ms"
# Once more doing the real gather and plots this time.
for
rank
in
range
(
nranks
):
...
...
@@ -152,93 +159,107 @@ for rank in range(nranks):
tic_step
=
int
(
full_step
[
5
])
toc_step
=
int
(
full_step
[
6
])
data
=
data
[
1
:,:]
typesseen
=
[]
start_t
=
tic_step
data
[:,
5
]
-=
start_t
data
[:,
6
]
-=
start_t
end_t
=
(
toc_step
-
start_t
)
/
CPU_CLOCK
*
1000
tasks
=
{}
tasks
[
-
1
]
=
[]
for
i
in
range
(
nthread
):
tasks
[
i
]
=
[]
num_lines
=
pl
.
shape
(
data
)[
0
]
for
line
in
range
(
num_lines
):
thread
=
int
(
data
[
line
,
1
])
tasks
[
thread
].
append
({})
tasks
[
thread
][
-
1
][
"type"
]
=
TASKTYPES
[
int
(
data
[
line
,
2
])]
tasks
[
thread
][
-
1
][
"subtype"
]
=
SUBTYPES
[
int
(
data
[
line
,
3
])]
tic
=
int
(
data
[
line
,
5
])
/
CPU_CLOCK
*
1000
toc
=
int
(
data
[
line
,
6
])
/
CPU_CLOCK
*
1000
tasks
[
thread
][
-
1
][
"tic"
]
=
tic
tasks
[
thread
][
-
1
][
"toc"
]
=
toc
tasks
[
thread
][
-
1
][
"t"
]
=
(
toc
+
tic
)
/
2
combtasks
=
{}
combtasks
[
-
1
]
=
[]
for
i
in
range
(
nthread
):
combtasks
[
i
]
=
[]
for
thread
in
range
(
nthread
):
tasks
[
thread
]
=
sorted
(
tasks
[
thread
],
key
=
lambda
l
:
l
[
"t"
])
lasttype
=
""
types
=
[]
for
task
in
tasks
[
thread
]:
if
task
[
"type"
]
not
in
types
:
types
.
append
(
task
[
"type"
])
if
lasttype
==
""
or
not
lasttype
==
task
[
"type"
]:
combtasks
[
thread
].
append
({})
combtasks
[
thread
][
-
1
][
"type"
]
=
task
[
"type"
]
combtasks
[
thread
][
-
1
][
"subtype"
]
=
task
[
"subtype"
]
combtasks
[
thread
][
-
1
][
"tic"
]
=
task
[
"tic"
]
combtasks
[
thread
][
-
1
][
"toc"
]
=
task
[
"toc"
]
if
task
[
"type"
]
==
"self"
or
task
[
"type"
]
==
"pair"
or
task
[
"type"
]
==
"sub"
:
combtasks
[
thread
][
-
1
][
"colour"
]
=
SUBCOLOURS
[
task
[
"subtype"
]]
# Dummy image for ranks that have no tasks.
if
data
.
size
==
0
:
print
"rank "
,
rank
,
" has no tasks"
fig
=
pl
.
figure
()
ax
=
fig
.
add_subplot
(
1
,
1
,
1
)
ax
.
set_xlim
(
-
delta_t
*
0.03
*
1000
/
CPU_CLOCK
,
delta_t
*
1.03
*
1000
/
CPU_CLOCK
)
ax
.
set_ylim
(
0
,
nthread
)
start_t
=
tic_step
end_t
=
(
toc_step
-
start_t
)
/
CPU_CLOCK
*
1000
else
:
start_t
=
tic_step
data
[:,
5
]
-=
start_t
data
[:,
6
]
-=
start_t
end_t
=
(
toc_step
-
start_t
)
/
CPU_CLOCK
*
1000
tasks
=
{}
tasks
[
-
1
]
=
[]
for
i
in
range
(
nthread
):
tasks
[
i
]
=
[]
num_lines
=
pl
.
shape
(
data
)[
0
]
for
line
in
range
(
num_lines
):
thread
=
int
(
data
[
line
,
1
])
tasks
[
thread
].
append
({})
tasks