source: CIVL/examples/omp/threadPrivate.c@ e2570cd

main test-branch
Last change on this file since e2570cd was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 890 bytes
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <omp.h>
4
5int a, b, i, tid;
6float x;
7int z[10];
8
9#pragma omp threadprivate(a, x, z)
10
11int main (int argc, char * argv[]){
12
13/* Explicitly turn off dynamic threads */
14 //omp_set_dynamic(0);
15 //z[0] = 0;
16 printf("1st Parallel Region:\n");
17#pragma omp parallel private(b,tid)
18 {
19 tid = omp_get_thread_num();
20 a = tid + 7;
21 b = tid + 5;
22 x = 1.1 * tid +1.0;
23 z[0] = 9;
24 printf("1Thread %d: a,b,x,z= %d %d %f %d\n",tid,a,b,x,z[0]);
25 } /* end of parallel section */
26
27 printf("************************************\n");
28 printf("Master thread doing serial work here\n");
29 printf("************************************\n");
30
31 printf("2nd Parallel Region:\n");
32#pragma omp parallel private(tid)
33 {
34 tid = omp_get_thread_num();
35 printf("2Thread %d: a,b,x,z= %d %d %f %d\n",tid,a,b,x,z[0]);
36 } /* end of parallel section */
37
38}
Note: See TracBrowser for help on using the repository browser.