Top Banner
Parallel Computing (with GPars) NOV 2011
23

Parallel computing with GPars

Jun 20, 2015

Download

Technology

Pablo Molnar

This slides are for the Parallel Computing talk. You can read the repo samples of the talk @ https://github.com/pablomolnar/gpars_samples

@pmolnar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Parallel computing with GPars

Parallel Computing(with GPars)

NOV 2011

Page 2: Parallel computing with GPars

Evolution

● Old Days ○ threads○ synchronize○ locks○ wait-notify

Page 3: Parallel computing with GPars

Evolution

● Recent enhancements ○ java.util.concurrent.*○ Future task○ Executor Pools○ Blocking Queues○ ConcurrentMap

Page 4: Parallel computing with GPars

Evolution

● Emerging Technologies○ Map-Reduce○ API's (Google Collections, JSR-166)○ Non-blocking I/O ○ Parallel Friendly Languages (Scala, Clojure, Groovy)

Page 5: Parallel computing with GPars

Groovy Parallel Systems

High level abstractions for writing concurrent code!

● Code-level Helpers○ Parallel Collections○ Asynchronous Processing○ Fork/Join - Map/Reduce

● Architecture-level Concepts○ Dataflows ○ Actors

● Protecting Shared Mutable State ○ Agents

Page 6: Parallel computing with GPars

Groovy Parallel Systems

High level abstractions for writing concurrent code!

● Code-level Helpers○ Parallel Collections○ Asynchronous Processing○ Fork/Join - Map/Reduce

● Architecture-level Concepts○ Dataflows ○ Actors (For next time...)

● Protecting Shared Mutable State ○ Agents (For next time...)

Page 7: Parallel computing with GPars

DEMO 1 (Parallel encryption)

Page 8: Parallel computing with GPars

Optimal Thread Pool Size

Pool size = ???

Page 9: Parallel computing with GPars

Optimal Thread Pool Size

Pool size = Ncores

Page 10: Parallel computing with GPars

Optimal Thread Pool Size

Pool size = Ncores + 1

Page 11: Parallel computing with GPars

Optimal Thread Pool Size

Pool size = Ncores + Block. Op. Ratio

Page 12: Parallel computing with GPars

Optimal Thread Pool Size

Pool size = Ncores + wait time cpu time

Page 13: Parallel computing with GPars

DEMO 2

"Dado un rango obtener la cantidad de nr. primos agrupados por él ultimo digito"

Page 14: Parallel computing with GPars

Don't mess up with mutable shared data!

Danger

Page 15: Parallel computing with GPars

DEMO 3 (Facebook Search)

Page 16: Parallel computing with GPars

Collections● eachParallel()● eachWithIndexParallel()● collectParallel()● findAllParallel()● findAnyParallel● findParallel()● everyParallel()● anyParallel()● grepParallel()● groupByParallel()● foldParallel()● minParallel()● maxParallel()● sumParallel()● splitParallel()● countParallel()● foldParallel()

Page 17: Parallel computing with GPars

DEMO 4 (Facebook Singles)

Page 18: Parallel computing with GPars

Fork-Join

Map-Reduce

Page 19: Parallel computing with GPars

DEMO 5 (API Calls)

Page 20: Parallel computing with GPars

DEMO 6 (Multiget)

Page 21: Parallel computing with GPars

Multiget

Page 22: Parallel computing with GPars

+ Info● http://gpars.org/0.12/guide/guide/single.html● http://www.slideshare.net/paulk_asert/concurrency-with-

gpars● http://gee.cs.oswego.edu/dl/papers/fj.pdf● http://static.googleusercontent.

com/external_content/untrusted_dlcp/labs.google.com/en/us/papers/mapreduce-osdi04.pdf

● Java Concurrency in Practice (ISBN-0321349601)

Pics Credits● Stone age: http://tinyurl.com/bvnlv74● Steam train: http://tinyurl.com/6lp3krq● Speed train: http://tinyurl.com/7jjc3v5● CPU: http://www.flickr.com/photos/olivander/149865626/

Page 23: Parallel computing with GPars

@pmolnar

https://github.com/pablomolnar/gpars_samples