www.inl.gov measurements of version 3.0 (beta) relap5-3d relap5-3d international users seminar 2010...
TRANSCRIPT
ww
w.in
l.gov
Measurements of Version 3.0 (Beta) RELAP5-3D
RELAP5-3D International Users Seminar 2010
[insert optional photo(s) here]
Sep 20-23, 2010
Outline
• Static Measures• Improvements to the 3D capability in RELAP5-3D• Dynamic Measures
2
Static and Dynamic Measures• Dynamic Measures
– Metrics that are obtained when the code is run– Coverage analysis, profiling, run speed, etc
• Static measures– Metrics that apply to the code when it is not running– Code structure, features, user problems, etc.
3
Feature Comparison 2.4 and Beta (3.0)
Category Version 2.4.3 (Pre-F95) Beta (Post-F95)
Direct Access Restart-Plot File
Available Eliminated
Pre-run GUI RGUI Launch Station, SNAP
RGUI Limited Launch Station, SNAP
Runtime GUI RGUI Plant Image Not converted
RGUI Replay Available Eliminated
SCDAP Available Not converted
Compilers Many, but older, compilers Only Intel 9.1, 10.1
•Downgrades
•Upgrades
* These are reported in another presentation
Feature Comparison 2.4 and Beta (3.0)
Category Version 2.4.1.2 (Pre-F95) Beta (Post-F95)
Database Linear, index-pointers F95 Modules, derived types
Memory Upper-limited Expands to fit user’s model
Coding Extended F66, F77, F90 and compiler extensions
F95
Modularity Unstructured Structured (strongly modular)
Dead Code Many unused subroutines 162 unused files removed
Feature Comparison 2.4 and Beta (3.0)
Category Version 2.4.1.2 (Pre-F95) Beta (Post-F95)
Platforms Windows, Unix Linux, Windows, Unix
Restart-file form Combined restart-plot file Separate restart and plot files
Portability O/S specific bit-, time-, and location-intrinsics
Fully portable F95 intrinsic library
Ordinary Binarymachine dependent rstplt
XDR binary machine independent files
Fluids Base 2.4.1.2 Base + additions*
Physical models Base 2.4.1.2 Base + additions*
•Upgrades
Spaghetti Code to Structured Code• Spaghetti Code is code that is hard to read because
– Tangled (interwoven) logic paths. Symptom: go-to’s and line labels– Knots (backward jumps). Symptom: backward go to.– Obscure coding (multiple-return, assign-stmt, computed go to, etc.)– Lacks consistent indentation and other helpful programming style
• Spaghetti code is considered bad practice – Prone to experience errors, – Cause of errors are difficult to locate
7
Improvement: Restructured Code• Computer Science solution – Apply structured programming• Commercial restructuring package applied (between 2.4 and 3.0)
– Workaround for pre-compiler directives was created• Restructurer actions
– Eliminate go-to statements– Pull sections of code together– Enforce consistent style– Eliminate dead code w/in subroutines
8
05-GA
Static Measure: Readability measures
Go to statements 2.4 % Beta % 2.4/Beta
File w/ 0 GO TOs 255 46 420 67 0.66
File w/ 10+ GO TOs 132 24 65 10 2.03
File w/ 51+ GO TOs 41 7.4 4 .63 10.25
File w/ 86+ GO TOs 14 2.5 1 .16 14.00
Total GO TOs 6707 3 2209 .79 3.04
Computed GO TOs 100 .04 7 .003 14.29
Backward GO TOs
** Spaghetti **822 .3 45 .016 18.27
• Reduction of GOTO statements• Lines of code: 249400 (2.4.1.2), 278100 (3.0.0)• Source code files: 554 (2.4.1.2), 630 (3.0.0)
05-GA
Static Measure: Line Label Reduction
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
0 labels 100 ormorelabels
Totallabels
Labelsof
formats
Non-formatlabels
Reduction in Labels
Af ter
Before
Static Measure (Spaghetti) – McCabe Index
Complexity 2.4.1.2 BetaMaximum cyclomatic number 982 460Files with cyclomatic number >= 100 68 13
• McCabe Cyclomatic index = industry-standard, code-complexity measure.
• Number of independent linear paths through code• Indicates the number of branches within it. • Higher indices => more branches => harder to maintain.
• Cyclomatic index of 100 or less is generally considered low complexity and good programming
• Only input processing subroutines have 100+ index
Static Measures: Nesting and Documentation
Measurement Category 2.4.1.2 BetaMaximum Nesting (levels deep) 20 15 Best comments to code ratio 6.64 32.2Files w/ comments to code ratio >= 0.3 390 954
• Nesting is containment of one programming structure (loop, select, or sequence) within another
• Nesting level is the number of such structures containing a block of code• Less nesting is generally easier read and maintain
• Internal documentation (comments) improves readability• Documentation was added. Guidelines were applied.
Static Measure: User Problems Solved
Year Reports ResolvedFixed after
2.4.1.2Conversion to
F95 fixed it1998 85 31 1 11999 75 50 1 12000 92 47 2 22001 86 67 3 32002 86 72 0 02003 61 44 2 22004 62 39 7 72005 55 32 30 22006 71 36 35 12007 51 27 23 42008 47 23 18 52009 42 10 10 0Total 813 478 132 28
Dynamic Measure: Coverage Analysis
CategoryPre-F95
Version 2.4.1.2F95
Beta VersionTest Cases 188 3130
Product Release 188 221
PVM Dt Tests 0 2856
DA 0 53
Coverage Analysis Files Stmts Files Stmts
Relap Directory 63.87 44.72 80.37 61.51
Envrl Directory 35.46 38.91 54.24 51.91
• Beta code is much more heavily tested• Beta code’s test suite covers a much higher percentage of files and
statements– Reduces the likelihood of error
Improvements to 3D Capability of RELAP5-3D• Viscosity terms for Cartesian and Cylindrical Coordinates, SI
– Beta Version 3.0.0: Liquid momentum equations, 2009– Version 3.0.1: Gas momentum equations, 2010– Version 3.0.1: Simple turbulence term, 2010
• Would like more grid cells for good turbulence modeling• Want more 3D volumes for many modeling purposes• Version 2.4 had many 3D restrictions
– Could receive message:“Too many parallel connections”• E.G. Code stops with that message on a 6x6x6 region.
– 2400 junctions upper limit– 999 volumes upper limit
15
Improvements to 3D of RELAP5-3D (cont.)• Eliminated 3D Limits in Beta and post-Beta
– Beta Version 3.0.0: “Parallel connections” overcome by allocation– Version 3.0.1: 2400 junction limit overcome by allocating– Version 3.0.1: 999 (artificial) volume limit removed
• Up to 9x99x99 volumes possible • Enough for many modeling needs
• Version 2.4 solvers too limited for these large regions– Ver. 2.4 Original default solver, MA-18, too slow– PGMRES is faster but had its own hard-coded size limits– Ver. 2.4 default solver, BPLU, limited by size of FA array
• Version 3.0.0 removes hard-coded and FA size restrictions
16
Dynamic Measure: R5-3D Times on 3D-Region SI• Cylindrical 3D region from Loft L2-5 Test• 100 Advancements with Semi Implicit Method
– Full multi-D (cross derivative terms included)• Whole code transient CPU time with solvers PGMRES
and BPLU• Platform: Sun AMD Opteron, Open Suse 11.2, ifort 10.1
17
MA18 Times8x8x5 2233.78x8x8 17529.8x8x10 47527.8x8x13 85430.Too slow!
0 500 1000 1500 2000 2500 3000 3500 40000
5
10
15
20
25
30
35
40
45
50
Semi-Implicit, 6x6xN
BPLU
PGMRES
N = 6, 12, 24,48, 96
0 500 1000 1500 2000 2500 3000 3500 4000 45000
10
20
30
40
50
60
Semi-Implicit, 8x8xN
BPLU
PGMRES
Dynamic Measure: R5-3D 3D-Regions Times - NI
18
0 2000 4000 6000 8000 10000 120000
5000
10000
15000
20000
R5-3D 8x8xN Nearly
BPLU
PGMRES
Number of Variables
N = 5, 8, 13, 16, 32, 64
010
0020
0030
0040
0050
0060
0070
0080
0090
00
1000
00
100020003000400050006000700080009000
R5-3D Nearly Runtime
BPLU
PGMRES
CP
U T
ime
(sec
)
6x6xN region, N=6, 12, 24, 48, 96
Number of variables
1000 10000100
1000
10000
100000
Log-Log R5-3D Nearly
BPLU
PGMRES
Linear
O(n^2)C
PU
Tim
e (s
ec)
Number of variables
8x8xN region, N=5, 8, 13, 16, 32, 64
100 1000 1000010
100
1000
10000
Log-Log R5-3D Nearly
BPLU
PGMRES
Linear
O(n**2)
6x6xN region, N=6, 12, 24, 48, 96
Dynamic Measures: Grind time• Grind time is average time taken for one advancement.
19
BPLU PGMRES
Semi Nearly Semi Nearly
6x6x6 0.0198s 0.199s 0.0221s 0.190s
6x6x24 0.054s 0.82s 0.064s 3.77s
6x6x96 0.363s 3.64s 0.437s 76.82s
8x8x8 0.033s 2.44s 0.0387s 1.46s
8x8x16 0.072s 5.96s 0.11s 7.97s
8x8x64 0.47s 26.4s 0.56s 161.s
• Non-solver RELAP5-3D operations could obscure the solver times.
Dynamic Measure: R5-3D Solver Clock Cycles NI• BPLU time is O(n), PGMRES time is O(n2) as n increases.
20100 1000 10000
1.0E+4
1.0E+5
1.0E+6
1.0E+7
1.0E+8
1.0E+9
1.0E+10
Log-Log Solver 6x6xN NI
BPLUPGMRESLinearQuadratic
1000 10000100000000
1000000000
10000000000
100000000000
Log-Log Solver 8x8xN NI
BPLU
PGMRES
Linear
O(n^2)
0 2000 4000 6000 8000 10000 120000
1000000000
2000000000
3000000000
4000000000
5000000000
6000000000
7000000000
8000000000
Solver 6x6xN NI Cycles
BPLU
PGMRES
0 2000 4000 6000 8000 10000 12000 140000
2000000000400000000060000000008000000000
1000000000012000000000140000000001600000000018000000000
Solver 8x8xN NI Cycles
BPLU
PGMRES
Conclusions
Upside of Beta version vs. version 2.4• Beta version 3.0 has many new features.• Beta version expands memory to fit user’s model.• Beta version has virtually no spaghetti coding• Beta version of RELAP5-3D has much improved 3D capability• Beta version has very efficient solvers for 3D regions
Downside• RGUI mostly unavailable• Support fewer compilers
21