OpenMP: How to implement loop scheduling without for loops?

痴心易碎 提交于 2019-12-25 07:58:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!