问题
I got this homework:
Implement an OpenMP program that generates prime numbers in a given interval. You should use the prime generation method given in the next page ( Do NOT use other method !). Your program should generate a csv le called results.csv that reports the timing results in the following format.
Table needed to be output
#include <stdio.h>
#define N 50
main()
{
int prime[N] ;
int j ;
int k ;
int n ;
int quo,rem ;
P1: prime[0] = 2 ;
n = 3 ;
j = 0 ;
P2: j = j+1 ;
prime[j] = n ;
P3: if (j == (N-1)) goto P9 ;
P4: n = n + 2 ;
P5: k = 1 ;
P6: quo = n / prime[k] ;
rem = n % prime[k] ;
if (rem == 0) goto P4 ;
P7: if (quo <= prime[k]) goto P2 ;
P8: k = k+1 ;
goto P6 ;
P9: for(j=0 ; j < N ; j++) printf("%d ",prime[j]) ;
}
I don't know any method to configure static, dynamic, guided scheduling without for loops and since I can not change the method, how do I do that?
来源:https://stackoverflow.com/questions/36107407/openmp-how-to-implement-loop-scheduling-without-for-loops