cs205-lecture-examples

Example codes used during Harvard CS205 lectures
git clone https://git.0xfab.ch/cs205-lecture-examples.git
Log | Files | Refs | README | LICENSE

main.c (337B)


      1 #include <omp.h>
      2 
      3 void myfunc(int A[], const int N, const int tid);
      4 
      5 int main(void)
      6 {
      7     const int N = 1000;
      8     int A[N];
      9 
     10 #pragma omp parallel
     11     {
     12         const int tid = omp_get_thread_num();
     13         myfunc(A, N, tid);
     14     }
     15     // The #pragma omp for directive has no effect in dynamic extent
     16     myfunc(A, N, 0);
     17     return 0;
     18 }