00001
00002
00003 #include <omp.h>
00004 extern void abort (void);
00005 void
00006 subdomain (float *x, int istart, int ipoints)
00007 {
00008 int i;
00009 for (i = 0; i < ipoints; i++)
00010 x[istart + i] = 123.456;
00011 }
00012
00013 void
00014 sub (float *x, int npoints)
00015 {
00016 int iam, nt, ipoints, istart;
00017 #pragma omp parallel default(shared) private(iam,nt,ipoints,istart)
00018 {
00019 iam = omp_get_thread_num ();
00020 nt = omp_get_num_threads ();
00021 ipoints = npoints / nt;
00022 istart = iam * ipoints;
00023 if (iam == nt - 1)
00024 ipoints = npoints - istart;
00025 subdomain (x, istart, ipoints);
00026 }
00027 }
00028 int
00029 main ()
00030 {
00031 int i;
00032 float array[10000];
00033 sub (array, 10000);
00034 for (i = 0; i < 10000; i++)
00035 if (array[i] < 123.45 || array[i] > 123.46)
00036 abort ();
00037 return 0;
00038 }