the open source ecosystem for technical computing alan edelman mathematics computer science & ai...

30
The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

Upload: emma-goodner

Post on 02-Apr-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

The open source ecosystemfor

technical computing

Alan EdelmanMathematics

Computer Science & AI LaboratoriesMay 15, 2014

Page 2: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

2/30

How should

Move technical computing forward?A vision of the future

octave

Page 3: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

3/30

The obvious…• High level technical computing languages traditionally

• Consist of libraries of functionality• Packaged for user convenience

• Open source or proprietary

• We could all compete, or we could benefit from each other’s great work!

Page 4: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

4/30

Some Examples

Page 5: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

5/30

We used to talk about “consumer reports”• For numerical software• Especially optimization•

Page 6: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

6/30

Ipython is wonderful!And not only just for python

Page 7: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

7/30

From the Python World:MATPLOTLIB

Page 8: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

8/30

Scilab calling Python

Page 9: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

9/30

Moving Technical Computing Forward

Goal: Bring Computer Science and Computational Science Together

Stereotypes:Computer Scientists don’t take derivatives

but computer scientists are great at abstractions Computational Scientists can’t declare types

but computational scientists are great at simulations

We want to bridge the gap between computer science and computationalscience

Page 10: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

10/30

Living the life as a Computer Scientist, Computational Scientist, and Mathematician

Page 11: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

11/30Page 11

Page 12: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

12/30Page 12

Page 13: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

13/30Page 13

Page 14: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

14/30Page 14

Page 15: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

15

methods objects

Object-oriented programming with classes

What can I do with/to a thing?

top uppay fare

lose

buy

top uppay fare

lose

buy

pay farelose

buy

class-based OO

classes are morefundamentalthan methods

Page 16: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

16

Object-oriented programming with multi-methods

What can I do with/to a thing?

top up

pay fare

lose

buy

genericfunction

objectsmethods

multimethods

relationships betweenobjects and functions

Page 17: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

17

Multi-methods with type hierarchy

top up

pay fare

lose

buy

genericfunction

objectsmethods

rechargeablesubwaypass

single-usesubwayticket

is a subtype of

subwayticket

abstract object

Page 18: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

18

genericfunction

objectsmethods

rechargeablesubwaypass

single-usesubwayticket

is a subtype of

subwayticket

top up

pay fare

lose

buy

abstract object

Multi-methods with type hierarchy

Page 19: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

19

Multi-methods for linear algebra

What can I do with/to a thing?

find eigenvalues and eigenvectors

find singular values

find singular values and vectors

find eigenvalues

genericfunction

objectsmethods

general matrix

symmetric tridiagonal matrix

bidiagonal matrix

Methods can take advantage of special matrix structures

eigvals

eigfact

svdvals

svdfact

Matrix

SymTridiagonal

Bidiagonal

Page 20: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

20

So how does this help us with linear algebra?

Page 21: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

21/30

“Disconnected” Technical Computing World

Desktop Productivity Supercomputer PowerCloud Potential

21/32

Page 22: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

22/30

“Disconnected” Technical Computing World

Desktop Productivity Supercomputer PowerCloud Potential

Easy on HumansNon-Expert UsersInterface to vast librariesDesktop PerformanceDeep Chasm to cross

The VillageThe MarketThe Availability

The Raw Power

Hard on Humans Software

22/32

Page 23: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

23/30

The “Two Language” Problem• As long as the developers’ language is harder than

the users language, technical computing will always be hindered

Page 24: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

24/30

Looking for Abstractions

Page 25: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

25/30

Parallel Prefix1,2,3,4,5,… 1,3,6,10,15,…

Page 26: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

26

Iterative algorithms as iterators

for item in iterable #bodyend

#is equivalent to

state = start(iterable) while !done(iterable, state) item, state = next(iterable, state) # bodyend

Page 27: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

27

Conjugate gradients (Hestenes-Stiefel)

http://en.wikipedia.org/wiki/Conjugate_gradient_method

Can we write this as an iterator?

state = start(iterable)

done(iterable, state)

Page 28: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

28

Conjugate gradients (Hestenes-Stiefel)

http://en.wikipedia.org/wiki/Conjugate_gradient_method

state = start(iterable)

done(iterable, state)

state, dx = next(iterable, state)

Page 29: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

29

immutable cg_hs #iterative solver K :: KrylovSpace #wraps A, v0, k t :: Terminator #termination criteriaend immutable cg_hs_state r :: Vector #residual p :: Vector #search direction rnormsq :: Float64 #Squared norm of previous residual iter :: Int #iteration countend start(a::cg_hs) = cg_hs_state(a.K.v0, zeros(size(a.K.v0,1)), Inf, 0) function next(a::cg_hs, s::cg_hs_state) rnormsq = dot(s.r, s.r) p = s.r + (rnormsq/s.rnormsq)*s.p Ap = a.K.A*p α = rnormsq / dot(p, Ap) α*p, cg_hs_state(s.r-α*Ap, p, rnormsq, s.iter+1)end done(a::cg_hs, s::cg_hs_state) = done(a.t, s)

K = method(KrylovSpace(A, b, k), Terminator())x += reduce(+, K) # for dx in K; x += dx; end

Hestenes-Stiefel CG

Abstracts out termination check and solution update steps

Page 30: The open source ecosystem for technical computing Alan Edelman Mathematics Computer Science & AI Laboratories May 15, 2014

30/30

Conclusions…• Open source computing allows us to benefit from each other’s work• But Even More importantly

• allows us to grow the very design base