c - Why does OpenMP forbid use lastprivate in "#pragma omp parallel"? -


my openmp program this:

#include <stdio.h> #include <omp.h>  int main (void) {     int = 10;      #pragma omp parallel lastprivate(i)     {         printf("thread %d: = %d\n", omp_get_thread_num(), i);         = 1000 + omp_get_thread_num();     }      printf("i = %d\n", i);      return 0; } 

use gcc compile , generate following errors:

# gcc -fopenmp test.c test.c: in function 'main': test.c:8:26: error: 'lastprivate' not valid '#pragma omp parallel'      #pragma omp parallel lastprivate(i)                           ^~~~~~~~~~~ 

why openmp forbid use lastprivate in #pragma omp parallel?

the meaning of lastprivate, assign "the sequentially last iteration of associated loops, or lexically last section construct [...] original list item."

hence, there no meaning pure parallel construct. not idea use meaning "the last thread exit parallel construct" - race condition.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -