#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int i, size=20;
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
]); }
}
}
I2luY2x1ZGUgPG9tcC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgogCmludCBtYWluIChpbnQgYXJnYywgY2hhciAqYXJndltdKSAKewogIGludCBpLCBzaXplPTIwOwogIGludCAqYSA9IChpbnQqKW1hbGxvYyhzaXplKnNpemVvZihpbnQpKTsKICBmb3IoaSA9IDA7IGkgPCBzaXplOyBpKyspIHsKICAgIGFbaV0gPSBpKzE7CiAgfQogICNwcmFnbWEgb21wIHBhcmFsbGVsIHNoYXJlZChzaXplLCBhKSBwcml2YXRlKGkpIG51bV90aHJlYWRzKDgpCiAgewogICAgaW50IHRpZCA9IDE7CiAgICAjcHJhZ21hIG9tcCBmb3IKICAgIGZvcihpID0gMDsgaSA8IHNpemU7IGkrKykgewogICAgICBwcmludGYoIlRJRFslZF0gLSBhWyVkXSA9ICVkXG4iLCB0aWQsIGksIGFbaV0pOwogICAgfQogIH0KfQ==