1 / 16

Parallel Programming

Parallel Programming. OpenMP und JOMP. http://n.ethz.ch/~klauserc/FS10/PP/. Übersicht. Nachbesprechung der Übung 9 OpenMP und JOMP. 1. Nachbesprechung Übung 9. Game of Life MVC. Wieso funktioniert das so nicht?. Application.java. Model.java. getState. state. oldState. newState.

cody
Download Presentation

Parallel Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parallel Programming OpenMP und JOMP http://n.ethz.ch/~klauserc/FS10/PP/

  2. Übersicht • NachbesprechungderÜbung 9 • OpenMP und JOMP

  3. 1. NachbesprechungÜbung 9

  4. Game of Life MVC Wieso funktioniert das so nicht? Application.java Model.java getState state oldState newState setState Model Field.java View/Controller

  5. Game of Life MVC GUI aktualisieren Application.java Model.java state oldState SwingUtilities.invoke* setState newState Model Field.java View/Controller

  6. Game of Life MVC Modell aktualisieren Application.java Model.java oldState copyState SwingUtilities.invoke* newState state‘ Model oldState Field.java View/Controller

  7. Game of Life: der Code

  8. 2. OpenMP und Jomp

  9. Fork-Join Sequential code for { Parallel code } Sequential code for { Parallel code } Sequential code

  10. OpenMP in Java = JOMP • //omp parallel for [additional directives] • for(int i = START; i < END; i += INC){ • //thecode • } • START, END und INC müssen Loop-Invariant sein • Variablen, die innerhalb des loops deklariert werden, sind automatisch private. • Variablen, die ausserhalb von //omp parallel deklariert werden sind automatisch shared.

  11. JOMP: private/shared; critical • intsum = 0; • inttemp; • //omp parallel for private(temp) shared(sum) • for(int i = 0; i < 500; i++){ • temp = i*5; • //ompcritical • { • sum += temp; • } • }

  12. JOMP verwenden • jomp1.0b.jar zum CLASSPATH hinzufügen • JOMP-Compiler aufrufen via java jomp.compiler.JompNameOfFile • Java-Compiler aufrufen via javac *.java • Programmausführen via java “-Djomp.threads=N” NameOfFile

  13. WTF is “CLASSPATH”? • Umgebungsvariable • Analog zu PATH unter Unix/Windows • Zuweisen in cmd.exe • set CLASSPATH=jomp1.0b.jar;. • Zuweisen in Psh • $env:CLASSPATH = “jomp1.0b.jar;.” • Zuweisen in bash • ihrwisst das besseralsich :-P • Enthält ‘;’-getrennteListe von Verzeichnissen und *.jar-Dateien, die Java durchsucht

  14. OMG?!  Kurzes Beispiel

  15. So in Ordnung? • int[] a = new int[50]; • int b; • //omg parallel for lastprivate(b) • for(inti = 0; i < a.length; i++){ • a[i] = b++; • } • System.out.println(b);

  16. Fragen?

More Related