Contenu connexe
Plus de Russel Winder (20)
Why Go is an important programming language
- 1. Why Go is an
Important Language
Prof Russel Winder
email: russel@winder.org.uk
xmpp: russel@winder.org.uk
twitter: russel_winder
Copyright © 2013 Russel Winder 1
- 3. controversial
adjective
of, pertaining to, or characteristic of controversy;
polemical
Copyright © 2013 Russel Winder 3
- 4. controversy
noun
dispute, argument, or debate, especially one
concerning a matter about which there is
strong disagreement
Copyright © 2013 Russel Winder 4
- 5. polemic
noun
a strong verbal or written attack on
someone or something
Copyright © 2013 Russel Winder 5
- 11. Aware of DVCS repositories.
Copyright © 2013 Russel Winder 11
- 15. Concurrency is a tool for structuring execution where a
single processor is used by multiple computations.
Parallelism is about making a computation complete
faster than using a single processor.
Copyright © 2013 Russel Winder 15
- 17. People should tremble in fear
at the prospect of using
mutable
shared-memory
multithreading.
Copyright © 2013 Russel Winder 17
- 18. Locks deny parallelism.
The whole purpose of a lock is to
prevent parallelism.
Copyright © 2013 Russel Winder 18
- 19. Locks are needed only if
there is mutable shared state.
Copyright © 2013 Russel Winder 19
- 22. It's all easier if processes
are single threaded.
Copyright © 2013 Russel Winder 22
- 23. Applications and tools programmers
need computational models with
integrated synchronization.
Copyright © 2013 Russel Winder 23
- 24. Actors Dataflow
Independent processes Operators connected by
communicating via channels with activity
asynchronous exchange triggered by arrival of
of messages data on the channels.
CSP Data Parallelism
Sequential processes
Transform a sequence to
connected by channels
another sequence where all
using synchronous message
individual actions happen
exchange (rendezvous).
at the same time.
Copyright © 2013 Russel Winder 24
- 25. Data Parallelism
Transform a sequence to
another sequence where all
individual actions happen
at the same time.
Copyright © 2013 Russel Winder 25
- 26. Actors
Independent processes
communicating via
asynchronous exchange
of messages
Copyright © 2013 Russel Winder 26
- 27. Dataflow
Operators connected by
channels with activity
triggered by arrival of
data on the channels.
Copyright © 2013 Russel Winder 27
- 28. CSP
Sequential processes
connected by channels
using synchronous message
exchange (rendezvous).
Copyright © 2013 Russel Winder 28
- 29. Actors Dataflow
Independent processes Operators connected by
communicating via channels with activity
asynchronous exchange triggered by arrival of
of messages data on the channels.
CSP Data Parallelism
Sequential processes
Transform a sequence to
connected by channels
another sequence where all
using synchronous message
individual actions happen
exchange (rendezvous).
at the same time.
Copyright © 2013 Russel Winder 29
- 30. Agents
A wrapper for some
Active Objects shared mutable state.
An object that is actually
an actor but looks like a
full service object.
Fork/Join
An toolkit for tree structured
concurrency and parallelism.
Software Transactional Memory
Wrappers for mutable values that uses transactions
rather than locks.
Copyright © 2013 Russel Winder 30
- 33. What is the Value of ?
Easy, it's known exactly.
It's .
Obviously.
Copyright © 2013 Russel Winder 33
- 34. It's simples
Александр Орлов 2009
Copyright © 2013 Russel Winder 34
- 35. Approximating
● What is it's value represented as a floating point
number?
● We can only obtain an approximation.
● A plethora of possible algorithms to choose from, a
popular one is to employ the following integral
equation.
1 1
=∫0 dx
4 1x 2
Copyright © 2013 Russel Winder 35
- 36. One Possible Algorithm
● Use quadrature to estimate the value of the integral
– which is the area under the curve.
4 n 1
= ∑i=1
n i−0.5 2
Embarrassingly 1
parallel. n
With n = 3 not much to do,
but potentially lots of error.
Use n = 107 or n = 109?
Copyright © 2013 Russel Winder 36
- 37. Because addition is commutative and
associative, expression can be
decomposed into sums of partial sums.
Copyright © 2013 Russel Winder 37
- 38. a+b+c+d+e+f
=
(a+b)+(c+d)+(e+f)
Copyright © 2013 Russel Winder 38
- 41. If you want the code, clone the Git repository:
http://www.russel.org.uk/Git/Pi_Quadrature.git
Copyright © 2013 Russel Winder 41
- 42. Or if you just want to browse:
http://www.russel.org.uk/gitweb
Copyright © 2013 Russel Winder 42
- 46. Actors, CSP, Dataflow, and
Data parallelism
are the future of
applications structure.
Copyright © 2013 Russel Winder 46
- 49. Goroutines
and
channels
Copyright © 2013 Russel Winder 49
- 51. Why Go is an
Important Language
Prof Russel Winder
email: russel@winder.org.uk
xmpp: russel@winder.org.uk
twitter: russel_winder
Copyright © 2013 Russel Winder 51