@@ -1,28 +1,33 @@
|
|
1 |
#include <omp.h>
|
2 |
#include <stdio.h>
|
3 |
#include <stdlib.h>
|
4 |
|
|
|
5 |
int main(int argc, char* argv[])
|
6 |
{
|
7 |
int thread_count = omp_get_max_threads();
|
8 |
if ( argc >= 2 )
|
9 |
thread_count = atoi( argv[1] );
|
10 |
|
11 |
int iterations = thread_count;
|
12 |
if ( argc >= 3 )
|
13 |
iterations = atoi( argv[2] );
|
14 |
|
15 |
-
#pragma omp parallel
|
16 |
-
default(none) shared(iterations)
|
17 |
-
for ( int iteration = 0; iteration < iterations; ++iteration )
|
18 |
{
|
19 |
-
#pragma omp
|
20 |
-
|
21 |
-
, omp_get_thread_num()
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
return 0;
|
28 |
}
|
1 |
#include <omp.h>
|
2 |
#include <stdio.h>
|
3 |
#include <stdlib.h>
|
4 |
|
5 |
+
|
6 |
int main(int argc, char* argv[])
|
7 |
{
|
8 |
int thread_count = omp_get_max_threads();
|
9 |
if ( argc >= 2 )
|
10 |
thread_count = atoi( argv[1] );
|
11 |
|
12 |
int iterations = thread_count;
|
13 |
if ( argc >= 3 )
|
14 |
iterations = atoi( argv[2] );
|
15 |
|
16 |
+
#pragma omp parallel num_threads(thread_count) default(none) shared(iterations, stderr)
|
|
|
|
|
17 |
{
|
18 |
+
#pragma omp for
|
19 |
+
for ( int iteration = 0; iteration < iterations; ++iteration )
|
20 |
+
fprintf(stderr, "stage 1: %d/%d: iteration %d/%d\n", omp_get_thread_num(), omp_get_num_threads(), iteration, iterations );
|
21 |
+
|
22 |
+
//#pragma omp barrier
|
23 |
+
#pragma omp for
|
24 |
+
for ( int iteration = 0; iteration < iterations; ++iteration )
|
25 |
+
fprintf(stderr, "stage 2: %d/%d: iteration %d/%d\n", omp_get_thread_num(), omp_get_num_threads(), iteration, iterations );
|
26 |
+
|
27 |
+
#pragma omp for
|
28 |
+
for ( int iteration = 0; iteration < iterations; ++iteration )
|
29 |
+
fprintf(stderr, "stage 3: %d/%d: iteration %d/%d\n", omp_get_thread_num(), omp_get_num_threads(), iteration, iterations );
|
30 |
}
|
31 |
|
32 |
return 0;
|
33 |
}
|