OpenFOAM素人がいきなりOpenFOAMの処理速度を計測しようと思ったので、その備忘録。
OpenFOAMをビルドする
ビルド自体は割とすんなりできる。
基本的には公式チュートリアルにある通りやればいい。
OpenFOAMを動かしてみる
公式サンプルとかを動かしてもいいんですが、処理速度を計測したい目的もあって、今回はOpenCAE学会のchannelReTau110ベンチマークを使うことにします。
動かし方は
$ git clone https://github.com/opencae/OpenFOAM-BenchmarkTest.git
$ cd OpenFOAM-BenchmarkTest/channelReTau110/NoBatch-mesh_3M
$ source ~/OpenFOAM/OpenFOAM-dev/etc/bashrc
$ ../bin/benchmark.sh all
# 実行完了まで待機
$ ../bin/table.sh
でそれっぽい感じになる。
gprofでプロファイリングできるように再ビルド
gmon.outを出力するように修正するには、
$ export WM_COMPILE_OPTION=Prof
$ ./Allwmake
すれば良い。
gprofでプロファイリング
で、またさっきと同じように動かしてみようとすると、mpirunとかの壁に阻まれて面倒。
なので、allの先頭を
decomposeParDictArray=(
mpi_0001-method_scotch
)
fvSolutionArray=(
PCG-DIC
)
とか適当に1プロセスでしか動かないようにして再実行。そうすると、どこかにgmon.outが出てくるが、これをgprofにかけようとしてもうまくとれない。というかこれどこをどう実行してるんだ・・・か追うのが面倒だった。
ということで、とりあえずNoBatch-mesh_3Mの下のcases/mpi_0001-method_scotchにそれっぽいのができているので、
$ cd OpenFOAM-BenchmarkTest/channelReTau110/NoBatch-mesh_3M/cases/mpi_0001-method_scotch
$ pimpleFoam
とやると、標準出力に
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : dev-8aac0a1808b4
Exec : pimpleFoam
Date : Apr 18 2017
Time : 16:28:01
Host : "furyx"
PID : 7421
Case : /home/user/OpenFOAM/OpenFOAM-BenchmarkTest/channelReTau110/NoBatch-mesh_3M/cases/mpi_0001-method_scotch
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Create mesh for time = 0
PIMPLE: Operating solver in PISO mode
Reading field p
Reading field U
Reading/calculating face flux field phi
Selecting incompressible transport model Newtonian
Selecting turbulence model type laminar
Selecting laminar stress model Stokes
No MRF models present
Creating finite volume options from "system/fvOptions"
Selecting finite volume options model type vectorSemiImplicitSource
Source: momentumSource
- selecting all cells
- selected 2995200 cell(s) with volume 197.392
Starting time loop
--> FOAM Warning :
From function void Foam::timeControl::read(const Foam::dictionary&)
in file db/functionObjects/timeControl/timeControl.C at line 89
Reading "/home/user/OpenFOAM/OpenFOAM-BenchmarkTest/channelReTau110/NoBatch-mesh_3M/cases/mpi_0001-method_scotch/system/controlDict.functions.fieldAverage1" from line 52 to line 80
Using deprecated 'outputControl'
Please use 'writeControl' with 'writeInterval'
fieldAverage fieldAverage1:
Starting averaging at time 0
Courant Number mean: 0.458366 max: 0.458366
Time = 0.002
PIMPLE: iteration 1
DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 8.22869e-06, No Iterations 4
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 2.30851e-06, No Iterations 5
DILUPBiCG: Solving for Uz, Initial residual = 1, Final residual = 1.78978e-06, No Iterations 5
GAMG: Solving for p, Initial residual = 1, Final residual = 0.0385422, No Iterations 2
time step continuity errors : sum local = 3.36548e-11, global = 1.13897e-21, cumulative = 1.13897e-21
GAMG: Solving for p, Initial residual = 0.806564, Final residual = 8.81214e-07, No Iterations 27
time step continuity errors : sum local = 9.71444e-16, global = -1.45721e-20, cumulative = -1.34331e-20
ExecutionTime = 19.7 s ClockTime = 20 s
Reading/initialising field UMean
Reading/initialising field pMean
Reading/initialising field UPrime2Mean
Reading/initialising field pPrime2Mean
fieldAverage fieldAverage1 write:
Calculating averages
Courant Number mean: 0.45748 max: 0.458428
Time = 0.004
PIMPLE: iteration 1
DILUPBiCG: Solving for Ux, Initial residual = 0.201848, Final residual = 1.56783e-06, No Iterations 4
DILUPBiCG: Solving for Uy, Initial residual = 0.20516, Final residual = 3.14372e-06, No Iterations 5
DILUPBiCG: Solving for Uz, Initial residual = 0.52794, Final residual = 8.94989e-06, No Iterations 5
GAMG: Solving for p, Initial residual = 0.804694, Final residual = 0.0244658, No Iterations 2
time step continuity errors : sum local = 2.64918e-11, global = -9.58137e-21, cumulative = -2.30145e-20
GAMG: Solving for p, Initial residual = 0.799877, Final residual = 8.38605e-07, No Iterations 29
time step continuity errors : sum local = 9.31083e-16, global = -5.38156e-21, cumulative = -2.83961e-20
ExecutionTime = 38.03 s ClockTime = 38 s
fieldAverage fieldAverage1 write:
Calculating averages
Courant Number mean: 0.456704 max: 0.458489
Time = 0.006
とそれっぽく動いてくれている感じに見える。
そして、カレントディレクトリにgmon.outが出てくれるので、これをgprofにかける
$ gprof `which pimpleFoam` gmon.out
と、めでたくプロファイルがとれた。
ように見えるが、中身を見て見るとmainが取得できていない。
実行時間が短すぎるからの可能性があるけれど、gprofのサンプリング間隔を調整するのはとても面倒なのでやめる。
gprofの限界
ということで、(想定していたことではあるけど)gprofでは限界があるので他のツールを試します。
つづく