MCPcopy Create free account
hub / github.com/AdvancedCompiler/AdvancedCompiler / main

Function main

code/Chapter9/9-27.c:17–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16int N = 320;
17int main(){
18double start_time,end_time;
19double z[N],x[N],y[N];
20int i,j,f;
21double scale;
22for(i=0;i<N;i++)
23{
24 z[i] = 0.0; x[i] = 0.001; y[i] = 0.999;
25}
26start_time = omp_get_wtime();
27#pragma omp parallel default(none) \
28 shared(N,x,y,z,scale) private(f,i,j) num_threads(8)
29{
30 f= 1.0;
31#pragma omp for
32 for(i=0;i<N;i++){
33 z[i] = x[i] + y[i];
34 complexcompute(omp_get_thread_num());
35 }
36//printf("thred %d compute end\n",omp_get_thread_num());
37#pragma omp single
38complexcompute(200);
39#pragma omp single
40 scale = sum(z,0,N) + f;
41}
42end_time = omp_get_wtime();
43printf("used_time = %lf\n",end_time-start_time);
44printf("scale = %lf",scale);
45}
46

Callers

nothing calls this directly

Calls 2

complexcomputeFunction · 0.85
sumFunction · 0.85

Tested by

no test coverage detected