Skip to content
Snippets Groups Projects
Commit ad64b9be authored by Pierre Augier's avatar Pierre Augier
Browse files

FourierFlows benchmarking and profiling.

parent 676e5b77
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,9 @@
bench/oar_launcher_*
bench/OAR.fluidsim_bench*
bench/FourierFlows/statprof/*
**/OAR.*.stdout
**/OAR.*.stderr
**/oar_launcher_*
......
# FourierFlows benchmarking and profiling
See https://github.com/FourierFlows/FourierFlows.jl
- Install Julia: https://julialang.org/downloads/
- In the Julia interpreter:
```
Pkg.add("FourierFlows")
Pkg.add("StatProfilerHTML")
```
- Run:
```
export OMP_NUM_THREADS=1
julia benchtestFourierFlows.jl
julia profilingFourierFlows.jl
```
## About the profiling
"From what I understand the code spends ~59% of it’s time doing FFT’s (that’s what
A_mul_B! is called for) and 21% doing in-place array multiplications (that’s what
broadcast.jl is called for)."
\ No newline at end of file
# benchmarkfourierflows.jl
# This script integrates the 2D Navier-Stokes equation for nsteps time-steps
# with a 4th-order Runge Kutta time-stepping method and a pseudospectral
# method for performing spatial derivatives, using the FourierFlows.jl
# package.
using FourierFlows
import FourierFlows.TwoDTurb
# Numerical parameters
n = 512*2 # 2D resolution = n^2
stepper = "RK4" # timestepper
nsteps = 10 # number of timesteps
nthreads = 1 # number of FFTW threads (choose Sys.CPU_CORES for the maximum on system)
# FFTW planning effort
effort = FFTW.MEASURE
# effort = FFTW.PATIENT
# Physical parameters
L = 2π # domain size
dt = 5e-3 # timestep
nu = 1e-5 # (hyper)diffusion coefficient
nnu = 1 # (hyper)diffusion order (0 = linear drag, 1 = Laplacian viscosity)
mu = 0.0 # hypodiffusion coefficient
nmu = 2 # hypodiffusion order
# Initialize problem
g = TwoDGrid(n, L; nthreads=nthreads, effort=effort)
p = TwoDTurb.Params(nu, nnu, mu, nmu)
v = TwoDTurb.Vars(g)
eq = TwoDTurb.Equation(p, g)
println("ts = FourierFlows.autoconstructtimestepper('RK4', dt, eq.LC, g)")
ts = FourierFlows.autoconstructtimestepper("RK4", dt, eq.LC, g)
println("prob = FourierFlows.Problem(g, v, p, eq, ts)")
prob = FourierFlows.Problem(g, v, p, eq, ts)
# Set initial condition
TwoDTurb.set_q!(prob, rand(n, n))
println("# Compile step")
stepforward!(prob)
println("Stepping forward $nsteps steps with $nthreads threads and $n^2 resolution:")
# Measure performance for nsteps
@time stepforward!(prob, nsteps)
# profilingFourierFlows.jl
# This script integrates the 2D Navier-Stokes equation for nsteps time-steps
# with a 4th-order Runge Kutta time-stepping method and a pseudospectral
# method for performing spatial derivatives, using the FourierFlows.jl
# package.
using FourierFlows
using StatProfilerHTML
import FourierFlows.TwoDTurb
# Numerical parameters
n = 512*2 # 2D resolution = n^2
stepper = "RK4" # timestepper
nsteps = 10 # number of timesteps
nthreads = 1 # number of FFTW threads (choose Sys.CPU_CORES for the maximum on system)
effort = FFTW.MEASURE # FFTW planning effort
# Physical parameters
L = 2π # domain size
dt = 5e-3 # timestep
nu = 1e-5 # (hyper)diffusion coefficient
nnu = 1 # (hyper)diffusion order (0 = linear drag, 1 = Laplacian viscosity)
mu = 0.0 # hypodiffusion coefficient
nmu = 2 # hypodiffusion order
# Initialize problem
g = TwoDGrid(n, L; nthreads=nthreads, effort=effort)
p = TwoDTurb.Params(nu, nnu, mu, nmu)
v = TwoDTurb.Vars(g)
eq = TwoDTurb.Equation(p, g)
ts = FourierFlows.autoconstructtimestepper(stepper, dt, eq.LC, g)
prob = FourierFlows.Problem(g, v, p, eq, ts)
# Set initial condition
TwoDTurb.set_q!(prob, rand(n, n))
# Compile step
stepforward!(prob)
println("Profiling for $nsteps steps with $nthreads threads and $n^2 resolution:")
Profile.clear()
@profile stepforward!(prob, nsteps)
Profile.print(format=:tree, mincount=20)
statprofilehtml()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment