#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int i, size=8;
int *a
= (int*)malloc(size
*sizeof(int)); for(i = 0; i < size; i++) {
a[i] = i+1;
}
#pragma omp parallel shared(size, a) private(i) num_threads(8)
{
int tid = 1;
#pragma omp for
for(i = 0; i < size; i++) {
printf("TID[%d] - a[%d] = %d\n", tid
, i
, a
[i
]); }
}
}
I2luY2x1ZGUgPG9tcC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgogCmludCBtYWluIChpbnQgYXJnYywgY2hhciAqYXJndltdKSAKewogIGludCBpLCBzaXplPTg7CiAgaW50ICphID0gKGludCopbWFsbG9jKHNpemUqc2l6ZW9mKGludCkpOwogIGZvcihpID0gMDsgaSA8IHNpemU7IGkrKykgewogICAgYVtpXSA9IGkrMTsKICB9CiAgI3ByYWdtYSBvbXAgcGFyYWxsZWwgc2hhcmVkKHNpemUsIGEpIHByaXZhdGUoaSkgbnVtX3RocmVhZHMoOCkKICB7CiAgICBpbnQgdGlkID0gMTsKICAgICNwcmFnbWEgb21wIGZvcgogICAgZm9yKGkgPSAwOyBpIDwgc2l6ZTsgaSsrKSB7CiAgICAgIHByaW50ZigiVElEWyVkXSAtIGFbJWRdID0gJWRcbiIsIHRpZCwgaSwgYVtpXSk7CiAgICB9CiAgfQp9