Text-only Table of Contents (frame/ no frame)
(6) Shared vs. Private Variables Previous Top Next

Shared vs. Private Variables

Example of Code with No Data Dependencies
!Fortran example 

!$omp parallel do private(temp) shared(n,a,b,c)
do i = 1, n
temp = 2.0*a(i)
a(i) = temp
b(i) = c(i)/temp

/* C/C++ Example */

#pragma omp parallel for private(temp) shared(n,a,b,c)
for(i=1; i<=n; i++){
temp = 2.0*a[i];
a[i] = temp;
b[i] = c[i]/temp;

Previous Top Next

shared_and_private.src  last modified Mar 23, 2009 Introduction Table of Contents
(frame/no frame)
(single file)
© Dartmouth College