回答編集履歴
1
appendix
answer
CHANGED
@@ -32,4 +32,31 @@
|
|
32
32
|
}
|
33
33
|
}
|
34
34
|
}
|
35
|
+
```
|
36
|
+
|
37
|
+
----
|
38
|
+
安直なWorkaroundコードを書いておきます。
|
39
|
+
|
40
|
+
MSVCでの実行結果: [http://rextester.com/CLLT45018](http://rextester.com/CLLT45018)
|
41
|
+
|
42
|
+
```C++
|
43
|
+
// OpenMP 2.0仕様準拠コンパイラ向け(MSVC)
|
44
|
+
#include <omp.h>
|
45
|
+
#include <iostream>
|
46
|
+
|
47
|
+
int main()
|
48
|
+
{
|
49
|
+
// 実行環境によっては明示指定不要
|
50
|
+
omp_set_num_threads(12);
|
51
|
+
|
52
|
+
#pragma omp parallel for
|
53
|
+
for (int ij = 0; ij < 2*6; ij++)
|
54
|
+
{
|
55
|
+
int i = ij / 6, j = ij % 6;
|
56
|
+
#pragma omp critical
|
57
|
+
{
|
58
|
+
std::cout << i << "," << j << " #" << omp_get_thread_num() << std::endl;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
35
62
|
```
|