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

omp_default.cpp (275B)


      1 #include <omp.h>
      2 
      3 int main(void)
      4 {
      5     int var;
      6 #pragma omp parallel default(none) // shared(var)
      7     {
      8 #pragma omp critical
      9         {
     10             // var was not explicitly specified -> will not compile
     11             var = omp_get_thread_num();
     12         }
     13     }
     14     return 0;
     15 }