October, 2011
OpenMP Tutorial – Critical, Atomic and Reduction
More important constructs are the “atomic” and “critical” constructs critical: the enclosed code block will be executed by only one thread at a time, and not simultaneously executed by multiple threads. It is often used to protect shared data fromrace conditions. atomic: the memory update (write, or read-modify-write) in the next instruction will be performed [...]
Posted in OpenMP | No Comments »
OpenMP Parallel For
The parallel directive #pragma omp parallel makes the code parallel, that is, it forks the master thread into a number of parallel threads, but it doesn’t actually share out the work. To illustrate, consider the following piece of code: #include #include #include int main(void){ int i; #pragma omp parallel { for(i=0; i printf(“Hello World %d\n”,i); [...]
Posted in OpenMP | No Comments »
Parallel Programming in C with OpenMP
OpenMP – Open Specifications for Multi Processing The central theme of parallel code is that of threads. A serial code starts off as one thread. As soon as the first parallel directive(Fortran)/pragma(C) is encountered, the master thread forks into a number of threads. The proceeding code is then executed in parallel in a manner which [...]
Posted in OpenMP | No Comments »