=====""OpenMP""===== ==a==Eigenschaften==a== ● ""OpenMP"" ist nur für Parallelrechner mit gemeinsamem Speicher geeignet. ● Schnittstellen für Fortran und C/C++ ● Industriestandard (V1.0 in 1998, V2.0 in 2002, V2.5 in 2005, V3.0 in 2008) ● Erhältlich auf vielen Plattformen (vergleichbar mit MPI) ● erlaubt eine schrittweise Parallelisierung ● kommerziell und als OpenSource (Sun Studio und GCC) verfügbar ● URL: http://www.openmp.org , Text des Standards auf der Webseite verfügbar. ==a==Informationsmaterial==a== ~-[[http://www.mcs.anl.gov/research/projects/mpich2/ Übungen]] ~~-Introduction to OpenMP ~-http://de.wikipedia.org/wiki/OpenMP ~-erst ab [[http://www.linux-magazin.de/heft_abo/ausgaben/2007/08/schneller_parallel GNU Compiler 4.2]] ==a==Umsetzung im Code==a== %%(c) #pragma omp { } %% ==a==Prinzip==a== ~-Aufteilung eines Bereichs auf verschiedene Threads ~-Bearbeitung mit lokalen Variablen in verschiedenen Threads ==a==Beispiel==a== %%(c) #include int main () { int nthreads, tid; omp_set_num_threads(3); printf("maxthreads=%d\n", omp_get_max_threads()); /* Fork a team of threads giving them their own copies of variables */ #pragma omp parallel private(nthreads, tid) { /* Obtain and print thread id */ tid = omp_get_thread_num(); printf("Hello World from thread = %d\n", tid); /* Only master thread does this */ if (tid == 0) { nthreads = omp_get_num_threads(); printf("Number of threads = %d\n", nthreads); } } /* All threads join master thread and terminate */ return 0; } %% Another example %%(cpp) #pragma omp parallel for for (mcy=0; mcy