001 002 /** 003 * Hello World with OpenMP for Java, 004 * @author Heinz Kredel. 005 */ 006 007 import jomp.runtime.*; 008 009 public class HelloJomp { 010 011 012 public static void main(String[] args) { 013 014 int myid = 1; 015 016 // OMP PARALLEL BLOCK BEGINS 017 { 018 __omp_Class0 __omp_Object0 = new __omp_Class0(); 019 // shared variables 020 __omp_Object0.args = args; 021 // firstprivate variables 022 try { 023 jomp.runtime.OMP.doParallel(__omp_Object0); 024 } catch(Throwable __omp_exception) { 025 System.err.println("OMP Warning: Illegal thread exception ignored!"); 026 System.err.println(__omp_exception); 027 } 028 // reduction variables 029 // shared variables 030 args = __omp_Object0.args; 031 } 032 // OMP PARALLEL BLOCK ENDS 033 034 } 035 036 // OMP PARALLEL REGION INNER CLASS DEFINITION BEGINS 037 private static class __omp_Class0 extends jomp.runtime.BusyTask { 038 // shared variables 039 String [ ] args; 040 // firstprivate variables 041 // variables to hold results of reduction 042 043 public void go(int __omp_me) throws Throwable { 044 // firstprivate variables + init 045 // private variables 046 int myid; 047 // reduction variables, init to default 048 // OMP USER CODE BEGINS 049 050 { 051 myid= OMP.getThreadNum(); 052 System.out.println("Hallo Welt von " + myid + "!"); 053 } 054 // OMP USER CODE ENDS 055 // call reducer 056 // output to _rd_ copy 057 if (jomp.runtime.OMP.getThreadNum(__omp_me) == 0) { 058 } 059 } 060 } 061 // OMP PARALLEL REGION INNER CLASS DEFINITION ENDS 062 063 } 064