Domain-specific languages: flexibility and performance - CFIR

cfir.dk

Domain-specific languages: flexibility and performance - CFIR

Domain-specific languages:

flexibility and performance

Actulus HTF-project

Peter Sestoft

CFIR 2012-12-11

www.itu.dk 1


Actulus Modeling Language,

A domain-specific language

• What

– Notation specially designed for the application area

– Supported by tools: editors, checkers, compilers ...

• A state model: insured is alive or dead

statemodel LifeDeath where

states = alive

| dead

transitions = alive -> dead

• A contract: Pay 10000/year from year n while

insured is alive

contract GF211(n : TimePoint) : LifeDeath where

obligations =

at t pay ¤10000 per year provided(n < t and alive)

www.itu.dk

2


Actulus Modeling Language (AML):

Product, Computation, Administration

Product

design

P, C P, A, C

Administration

Solvency,

etc

AML

P, C P, A

Reporting

www.itu.dk

3


A domain-specific language

• Advantages

– Multiple uses of same artefact

• Administration, accounting, reporting, solvency, ...

– Encourages explicit model or semantics

• Hence precise and complete software documentation

– Supports version control and traceability

– Supports evolution of core system independently of

company-specific adaptations (long-term)

– Reduces technology dependence (long-term)

• Disadvantages

– Maintenance of language and tools (at Edlund)

www.itu.dk

4


AML-P language design story

• Whitepapers, actuarial theory and notation, ...

– Quite foreign to computer science people

– Lots of interaction, help from Mogens and Edlund

– Project wiki essential for notation and development

• David Christiansen proposed AML-P designs

– Lots of feedback

• Edlund people have checked G82 coverage

– Proposed revised syntax

– Implementation under way

• Type system being developed by David

www.itu.dk

5


Efficient computation

• AML admits complex contracts, so ...

• ... the Thiele differential equations for the

reserve do not have closed form solutions

• Hence necessary to solve them numerically

• Some differential equation solvers

– Runge Kutta 4 th order (RK4)

– Runge Kutta Fehlberg 4 th /5 th order (RKF45)

• Use graphics processors, GPU/Nvidia CUDA

www.itu.dk

6


Why GPGPU,

General purpose graphics processor

• A modern CPU, eg Intel Core i7, has

– A few complex cores at 2-3 GHz, each superscalar

– Deep instruction pipeline, out-of-order execution ...

– Good for unpredictable mixed compute loads

– Much "management", little "compute work"

• A GPGPU, eg Nvidia, by contrast, has

– Many (50-500) simple compute cores, at 0.5-1 GHz

– No pipelines, no out-of-order execution, etc

– User-managed memory hierarchy

– Good for predictable data parallel compute loads

– Little "management", much "compute work"

www.itu.dk

7


16/14 SM x 32 cores = 512/448 cores

8


Challenges in using GPU

• Multiple kinds of memory

– On host (CPU):

• RAM, inaccessible to GPU

– On device (GPU):

• Global memory, shared by all blocks (large, slow)

• Constant memory, shared by all blocks, readonly

• Shared memory, shared by threads in block

• Registers, local to thread (small, fast)

– Bottleneck is data transport, not computation

• Thread divergence

– Operations must proceed in lock-step (as in RK4)

– If not, many cores may be idle (adaptive RKF45)

www.itu.dk

9


Preliminary GPU results

• On 448-core Nvidia C2075

– Hardware cost ca. 20,000 DKK

• Solving Thiele for 100,000s of products

– With software-generated Runge Kutta 4 solvers

• Results

– Ca. 1000x speedup over clean C# code on CPU

– Ca. 100x speedup over best C code on CPU

• Plausible to do 1 million policies/hour/GPU

– But yet to be proven ...

• Thanks to great work by ITU students

– now research programmers in Actulus project

www.itu.dk

10


Computation framework in progress

AML-P

Calcspec

ODE AST

optimize

Interpreter

C AST

Delite

Akka

RK4, RKF45

CUDA C,

GPU

C#, cloud,

C, multicore

RK4

RK4, RKF45

www.itu.dk

11


Computer science "technologies"

• Programming languages

– C#: Edlund expertise, my expertise (Ecma)

– F#: functional, program manipulation, expertise

– Scala: functional, embedded DSLs, David expertise

– CUDA C: Nvidia GPUs, mostly generated

• Dependent types

– Very strong static checking of correctness

– Much stronger than with class hierarchies etc

– Catch design and specification errors early

• in state models, risk models, insurance products, ...

www.itu.dk

12


What's in it for us

• Deep case study

– mathematically well-founded, industrially relevant

– for domain-specific languages

– for GPGPU, code generation, performance

• Insight into current industry goals, practices

• Excellent source of student projects

– Good for students and for the company partner

• Some other academic projects

– emphasize language technology over performance

– or emphasize performance over generality

– or remain inconcrete because of concerns about

disclosing information to competitors

www.itu.dk

13

More magazines by this user
Similar magazines