alfonso senatore

19
A NEW LIBRARY FOR COMPUTATIONAL SCIENCE ON PARALLEL COMPUTERS BASED ON THE CELLULAR AUTOMATA PARADIGM Workshop on coupled hydrological modeling 23-24 September 2015 Centre of Hydrology “Dino Tonini”, University of Padua, Italy Donato D’Ambrosio, William Spataro Dept. of Mathematics and Computer Science, University of Calabria Giuseppe Mendicino, Alfonso Senatore Dept. of Environmental and Chemical Engineering, University of Calabria OpenCAL

Upload: coupledhydrologicalmodeling

Post on 15-Jan-2017

133 views

Category:

Science


0 download

TRANSCRIPT

Page 1: Alfonso Senatore

A NEW LIBRARY FOR COMPUTATIONAL SCIENCE ON PARALLEL COMPUTERS BASED ON THE CELLULAR AUTOMATA PARADIGM

Workshop on coupled hydrological modeling 23-24 September 2015 Centre of Hydrology “Dino Tonini”, University of Padua, Italy

Donato D’Ambrosio, William Spataro Dept. of Mathematics and Computer Science, University of Calabria Giuseppe Mendicino, Alfonso Senatore Dept. of Environmental and Chemical Engineering, University of Calabria

OpenCAL

Page 2: Alfonso Senatore
Page 3: Alfonso Senatore

What is OpenCAL?

q  OpenCAL (Open Cellular Automata Library) is a new Open Source parallel software library for Complex Cellular Automata (CCA), designed and developed at the Department of Mathematics and Computer Science at UniCAL

q  Provides data structures, functions and algorithms both for 2D/3D CCA

q  Parallelism is quasi-transparent to the user, i.e. the user does not require in depth knowledge of Parallel Computing

q  Different versions for different computing devices have been implemented: ¤  OpenCAL, for serial execution on CPUs ¤  OpenCAL-OMP, based on OpenMP, for parallel execution on CPUs ¤  OpenCAL-CL, based on OpenCL, for parallel execution on GPUs ¤  OpenCAL-GL, based on OpenGL compatibility profile, for interactive

2D/3D visualization

Page 4: Alfonso Senatore

OpenCAL serial and OMP developing model

OpenCAL is written in the C programming language and is cross-platform E.g.: the user can develop the application under Windows using Visual Studio, also exploiting its debug facilities, and run it under Linux

Page 5: Alfonso Senatore

Cellular Automata (CA)

q  Cellular Automata are discrete parallel computational models, widely utilized for modeling and simulating complex systems

q  CA are composed of a n-dimensional grid of simple computing units called cells

q  At time t = 0 cells’ states define the initial condition of the CA

q  Cells change state simultaneously (i.e. in parallel) at discrete time steps by means of the cell state transition function

q  State transition function takes as input the states of the cell’s neighborhood

Page 6: Alfonso Senatore

Complex Cellular Automata (CCA)

A = (Ed, X, Q, P, σ)

•  Ed set of cells where the phenomenon evolves •  X neighborood •  Q cartesian product of the set of the values of the substates, e.g. •  P CA global parameters (e.g. cell dimension, time step), can also vary in time •  σ Qn → Q transition function, split in p elementary processes. E.g. σ1 – K, θ updating through charac- teristic equations θ = θ (ψ), K = K(ψ)

σ2 – h, ψ updating through the unsaturated soil flux equation

h KQ Q Q Q Q Qψ θ ∂= × × × ×

Mendicino et al., 2006, WRR, for further details

Page 7: Alfonso Senatore

Complex Cellular Automata (CCA)

Mendicino et al., 2006, WRR, for further details

q  The discrete formulation of any field equation can be modeled through the CA (CCA) paradigm

q  The Computing Space hypothesis: “The physical behavior of the entire universe is being computed on a basic level, possibly on CA, by the universe itself” (K. Zuse)

1c cc

c

m Stα

α

ΔΦ + =∑

ρ Δc c

c cm vt t

θρ

Δ Δ=

Δ Δc c c c

cc

h hCt h t tθ θΔ Δ Δ Δ

= =Δ Δ Δ Δ

c cc ch hK A K i Al

αα α α α α α

α

⎛ ⎞−Φ = − = −⎜ ⎟

⎝ ⎠

Discrete 3D mass balance equation

Unsaturated soil flux equation

( ) c cc c c c c

h h hK A v C Sl t

αα α

α α

ψ⎛ ⎞− Δ

− + =∑ ⎜ ⎟Δ⎝ ⎠

Page 8: Alfonso Senatore

OpenCAL serial and OMP developing model

In order to define the CCA, the user needs to: q  Define a CA object and initialize its parameters

q  Cellular space dimensions q  Type of neighborhood q  Cellular space boundary conditions q  Type of optimization (if any)

q  Define a simulation object and initialize its parameters q  The cellular automaton to use q  The initial and final computational steps

q  Define CCA substates q  Define transition function’s elementary processes q  Optionally, the user can define some global functions

q  initialization function q  Steering function (operations over the CA space or given sub-

regions)

Page 9: Alfonso Senatore

OpenCAL example

3D test based on Smyth et al. (1989) benchmark, involving transient, two-dimensional infiltration of water into an extremely dry heterogeneous soil, structured by four soil types with different hydraulic properties

Folino et al., 2006, Parallel Computing

Page 10: Alfonso Senatore

OpenCAL example

#include <cal3D.h> //snip struct mymodelSubstates {

struct CALSubstate3Dr *teta; struct CALSubstate3Dr *moist_cont; struct CALSubstate3Dr *psi; struct CALSubstate3Dr *k; struct CALSubstate3Dr *h; struct CALSubstate3Dr *dqdh;

} Q; int main ( ) { struct CALModel3D* mymodel; mymodel = calCADef3D (ROWS, COLS, LAYERS, CAL_VON_NEUMANN_NEIGHBORHOOD_3D,

CAL_SPACE_TOROIDAL, CAL_NO_OPT);

OpenCAL library

Defining the CA object and initializing its parameters

Page 11: Alfonso Senatore

OpenCAL example

Q.teta = calAddSubstate3Dr(mymodel); Q.moist_cont = calAddSubstate3Dr(mymodel); Q.psi = calAddSubstate3Dr(mymodel); Q.k = calAddSubstate3Dr(mymodel); Q.h = calAddSubstate3Dr(mymodel); Q.dqdh = calAddSubstate3Dr(mymodel); struct CALRun3D* mymodelSimulation; mymodelSimulation = calRunDef3D(mymodel, 1, CAL_RUN_LOOP,

CAL_UPDATE_IMPLICIT); calAddElementaryProcess3D(mymodel, mymodelTransitionFunction); calRunAddInitFunc3D(mymodelSimulation, mymodelSimulationInit); calRunAddSteeringFunc3D(mymodelSimulation, mymodelSimulationSteering); calRunAddStopConditionFunc3D(mymodelSimulation,

mymodelSimulationStopCondition); //snip }

Defining CA substates

Defining the simulation object and initializing its parameters

Calling transition function

Global functions

Page 12: Alfonso Senatore

OpenCAL example

void mymodelTransitionFunction(struct CALModel3D* ca, int _i, int _j, int _k) { //snip h = calGet3Dr(ca, Q.h, _i, _j, _k); //-------------------------------- Unsaturated soil flux equation for (i=0;i<mymodel->sizeof_X;i++) { Delta_h = h-calGetX3Dr(mbusu, Q.h, _i, _j, _k, i); temp_value = ((calGet3Dr(mymodel, Q.k, _i, _j, _k) + calGetX3Dr (mymodel,

Q.k, _i, _j, _k, i)) / 2.0) * calGet3Dr(mymodel, Q.dqdh, _i, _j, _k); h=h-((Delta_h/(lato*lato))*delta_t*temp_value); } psi=h-z;

//--------------------------- Characteristic equations //snip //---Update calSet3Dr(mymodel, Q.h, _i, _j, _k, h); calSet3Dr(mymodel, Q.psi, _i, _j, _k, psi); calSet3Dr(mymodel, Q.k, _i, _j, _k, k); //snip }

Ready-to-use parallel code

Page 13: Alfonso Senatore

OpenCAL example

¨  One day simulation, preliminary tests on Intel Core i7-4702HQ CPU and nVidia GTX 680 GPU

Version Time (s)

Serial 695

OpenMP 162 4+4 cores

OpenCL 68 1536 CUDA cores

Page 14: Alfonso Senatore

Active cells optimization and stream compaction

In order to speed-up the simulation, computation can be restricted to a subset of the computational domain (quantization)

Page 15: Alfonso Senatore

Another example: SciddicaT for debris flow simulation

Parallel runs Quantization Preliminary tests on Intel Core i7-4702HQ CPU and nVidia Quadro 1100M GPU

Preliminary tests on Intel Core i7-4702HQ CPU

Version Time (s)

Serial 170

OpenMP 109

OpenCL 5

Version Time (s)

No opt 170

Active cells 20

Avolio et al., 2000, International Journal of Applied Earth Observation and Geoinformation

384 CUDA cores

4+4 cores

Page 16: Alfonso Senatore

OpenCAL development state

q OpenCAL version 1.0 is going to be released within this year; source code is already freely available at the URL https://github.com/OpenCALTeam/opencal

Page 17: Alfonso Senatore

OpenCAL development state

q  Currently we are migrating a CA-based eco-hydrological model from CAMELot (the previous CCA software, no longer supported) to OpenCAL

Mendicino et al., 2015, Commun Nonlinear Sci Numer Simulat

Page 18: Alfonso Senatore

OpenCAL development state

q Huge potential with GPU parallelization (OpenCL)!!!

Several optimization steps performed over a single test case

– Biosphere 2 LEO hillslope – Vegetation cover 15% – height of depression storage 0.0 cm – Cumulated rain of 56.8 mm in 4.5 h

Final results

Speedup trend over CA dimension using single precision variable, number of steps fixed at 2000 and workgroup fixed at (5x5x5)

Page 19: Alfonso Senatore

OpenCAL future developments

q OpenCAL-cuda parallel GPGPU version q OpenCAL-MPI parallel message passing version q  Bindings for Fortran, Python and other languages q  Packages for most popular Linux distributions (Debian,

Ubuntu, Mint, OpenSuse, Fedora, etc)

[email protected]