Rsm Refactor April 2011

12
RSM Refactor (Phase 1) Refactor - Code refactoring is "a disciplined way to restructure code", [1] undertaken in order to improve some of the nonfunctional attributes of the software. – Wikipedia.com Project goals Clean up the code Restructure into stronger object oriented model Change No Functionality

description

This is a presentation on the recent changes to the code of the Regional Simulation Model.

Transcript of Rsm Refactor April 2011

Page 1: Rsm Refactor April 2011

RSM Refactor (Phase 1)

• Refactor - Code refactoring is "a disciplined way to restructure code",[1] undertaken in order to improve some of the nonfunctional attributes of the software. – Wikipedia.com

• Project goals– Clean up the code– Restructure into stronger object oriented

model– Change No Functionality

Page 2: Rsm Refactor April 2011

Team• Project lead – Joseph Park• Core Developers

– Fahmida Khatun– Charles Haynes– Randy Vanzee

• Additional development and consulting staff– Veera Karri– Raul Novoa– Eric Flaig– Wasantha Lal– Ruben Arteaga– Clay Brown– Sharika Senarath– Michael Martin (USACE)

Page 3: Rsm Refactor April 2011

Exception handlingConsole loggingBasin WBBugzillaTrigger ModuleAssessorMSE NetworkWCU Assessors

8/96

hseFORTRAN – C++

1996

PETSCSparse MatrixPurifyC++ standaloneDocumentation

1997

ENP ModelParallelizationDSS I/OVertical SolnSCCS

1998

CanalAlgorithm

+ 2.3 Yrs

1999

Canal-MeshIntegrationBenchmarksC++ Standardgcc justificationWaterBody/WaterMover class

+ 3.2 Yrs

2000

XMLCVS

+ 4

2002

2003 2004 2005 2006

+6

2007

Alpha controllerRulecurvesPID controller

Fuzzy controlpseudocell hub WM controlMSEUser controllerGLPK

+7.7 HPMsSpecial AssessIterationsWMM AssessWCU Profiler

2001

pseudocells

2008

ORM refactorCanal decouple

.dtd versionstage based

STA WQ

RSM Past

2009

Basins EAALinked Basins/WMM Assessors

2010

LGMRES

Page 4: Rsm Refactor April 2011

April 2009 Proposed RSM Developments

Lessons Learned

Model Objective

Exception handlingConsole loggingBasin WBBugzillaTrigger ModuleAssessorMSE NetworkWCU Assessors

8/96

hseFORTRAN – C++

1996

PETSCSparse MatrixPurifyC++ standaloneDocumentation

1997

ENP ModelParallelizationDSS I/OVertical SolnSCCS

1998

CanalAlgorithm

+ 2.3 Yrs

1999

Canal-MeshIntegrationBenchmarksC++ Standardgcc justificationWaterBody/WaterMover class

+ 3.2 Yrs

2000

XMLCVS

+ 4

2002 2003 2004 2005 2006

+6

2007

Alpha controllerRulecurvesPID controller

Fuzzy controlpsuedocell hub WM control [0,1]MSEUser controllerGLPK

+7.7 HPMsSpecial AssessIterationsWMM AssessWCU Profiler

2001

psuedocells

2008

ORM refactorCanal decouple

.dtd versionstage based

STA WQ

LO

A B

C

F E

D

+

RSM Enhancement Program

• Architecture review and design

• Domain-specific attention

• Improvement of model functions

• Incorporation of new technologies

C++ Coding StandardRSM Refactor

Page 5: Rsm Refactor April 2011

HSE Kernel†

1. Investigate replacement of PETSC with internal GMRES solver. (IML++ solver was fully integrated & tested with GladesLECSA model in 2010. See next slide.)

2. Evaluation and enhancement of watermover Jacobians (Current).

† This does not directly address or design a solution for overland flow (2D) stability, or reformulation of the diffusion framework with the addition of inertia.

July 2009 Proposed RSM Developments (& Status)

Page 6: Rsm Refactor April 2011

Implementation & testing of IML++ found that in comparison to PETSC, runtimes were slower and waterbudget residuals higher for GladesLECSA models.

IML++ Analysis - LGMRES

However: it led to a better understanding of the LGMRES algorithm and through exhaustive testing resulted in the adoption of PETSC LGMRES with Kyrlov subspace restart parameterisations that:

1. Significantly reduced model runtimes2. Give modelers control over solution tolerance / runtime tradeoff

Page 7: Rsm Refactor April 2011

RSM Refactor

1. Assess current code-base and class hierarchy. (2010)

2. Get Modeler input to identify needed and superfluous waterbodies, watermovers and functions. (2010)

3. Develop RSM Coding Standard. (2010)

4. Implement code cleanup based on Modeler criteria. (2011)

5. Assess code adherence to RSM coding standards. (2010)

6. Code refactor to correct deviations from RSM coding standards. (2011)

7. Assess functional integration of modules (HPMs, Trigger… etc.) (Future)

8. Refactor identified modules to uniform HSE/MSE integration standards. (Future)

July 2009 Proposed RSM Developments (& Status)

Page 8: Rsm Refactor April 2011

Bugzilla 2173 – RSM Refactor

A holistic cleanup and review of the RSM/HSE code base has not been conducted. There are varying styles and formats across the code-base which present barriers to assimilation by new developers and support by maintainers. There also exist sections of dead code, unnecessary header file dependencies and defunct benchmarks.

The Model Development Leads recommend:

1. Unifying the code-base with a coherent set of standards

2. Cleaning up dead code and benchmarks

3. Reducing header file dependencies

Project Goals

1. Code-base will be unified with a common look-and-feel

2. Source image will be reduced in size and complexity as header dependencies are removed

3. The pool of RSM developers will be expanded

4. No functional changes to model I/O, behavior or performance

Page 9: Rsm Refactor April 2011

The Coding Standard emphasized consistency, adherence to C++ standards and the reduction of header file dependencies.

RSM Centric C++ Coding Standard

Version 1.1

February 24, 2011

Technical Committee

Joseph Park

Randy van Zee

Charles Haynes

Page 10: Rsm Refactor April 2011

RSM Refactor Project Documentation

SVN: svn://dcluster1/rsm/RSM-Refactor-Docs

Web: http://dcluster2/viewvc/rsm/RSM-Refactor-Docs

RSM-Refactor-Docs/

acceptanceTesting/ - Model Implementation Validation

analysis/ - Code Analysis Tools and Results

codeReviews/ - Peer Review Comments

designData/ - Model Functional Design Criteria

designGuide/ - Coding Standard & Rules

status/ - Peer Review Spreadsheet & Changes

Page 11: Rsm Refactor April 2011

122 Files Removed

600+ Files Edited & Reviewed

Header File Dependencies Significantly Reduced (makefile dependencies reduced by a factor of ~2.5)

Consistent Code Format & Comments

Doxygen Comment Strings

No Change in Model Implementation Performance

4 Benchmarks Reactivated

7 Benchmarks Depracated

Multi-process builds now supported at the top level directory

RSM Refactor Results

Page 12: Rsm Refactor April 2011

What’s next?• Development tasks

– Upgrading the C++ compiler to the latest GNU compiler suite– Further conversion of coding constructs towards object oriented design

and methods– Reduce redundant code– Multi-process the benchmarks– Create application unit testing environment– Parallelize the code in a cluster friendly way– Explore coherent shared memory solutions– Create an API (Application Programmers Interface)

• Technical/Scientific tasks– Upgrade the solver– Parallelize functionality within the solver

• ILU preconditioner switch to JACOBI (ILU will not work in parallel)?