Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Parallel Programming OpenMP und JOMP

Ähnliche Präsentationen


Präsentation zum Thema: "Parallel Programming OpenMP und JOMP"—  Präsentation transkript:

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

2 Übersicht 1. Nachbesprechung der Übung 9 2. OpenMP und JOMP

3 1. NACHBESPRECHUNG ÜBUNG 9

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

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

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

7 Game of Life: der Code

8 2. OPENMP UND JOMP

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

10 OpenMP in Java = JOMP //omp parallel for [additional directives] for(int i = START; i < END; i += INC){ //the code } 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 int sum = 0; int temp; //omp parallel for private(temp) shared(sum) for(int i = 0; i < 500; i++){ temp = i*5; //omp critical { sum += temp; }

12 JOMP verwenden 1. jomp 1.0 b. jar zum CLASSPATH hinzufügen 2. JOMP - Compiler aufrufen via java jomp.compiler.Jomp NameOfFile 3. Java - Compiler aufrufen via javac *.java 4. Programm ausführen via java “-Djomp.threads=N” NameOfFile

13 WTF is “CLASSPATH”? Umgebungsvariable  Analog zu PATH unter Unix / Windows  Zuweisen in cmd. exe set CLASSPATH = jomp 1.0 b. jar ;.  Zuweisen in Psh $env : CLASSPATH = “jomp 1.0 b. jar ;. ”  Zuweisen in bash ihr wisst das besser als ich :- P Enthält ‘;’- getrennte Liste 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(int i = 0; i < a.length; i++){ a[i] = b++; } System.out.println(b);

16 FRAGEN?


Herunterladen ppt "Parallel Programming OpenMP und JOMP"

Ähnliche Präsentationen


Google-Anzeigen