回答編集履歴

1

appendix

2018/06/07 07:56

投稿

yohhoy
yohhoy

スコア6191

test CHANGED
@@ -67,3 +67,57 @@
67
67
  }
68
68
 
69
69
  ```
70
+
71
+
72
+
73
+ ----
74
+
75
+ 安直なWorkaroundコードを書いておきます。
76
+
77
+
78
+
79
+ MSVCでの実行結果: [http://rextester.com/CLLT45018](http://rextester.com/CLLT45018)
80
+
81
+
82
+
83
+ ```C++
84
+
85
+ // OpenMP 2.0仕様準拠コンパイラ向け(MSVC)
86
+
87
+ #include <omp.h>
88
+
89
+ #include <iostream>
90
+
91
+
92
+
93
+ int main()
94
+
95
+ {
96
+
97
+ // 実行環境によっては明示指定不要
98
+
99
+ omp_set_num_threads(12);
100
+
101
+
102
+
103
+ #pragma omp parallel for
104
+
105
+ for (int ij = 0; ij < 2*6; ij++)
106
+
107
+ {
108
+
109
+ int i = ij / 6, j = ij % 6;
110
+
111
+ #pragma omp critical
112
+
113
+ {
114
+
115
+ std::cout << i << "," << j << " #" << omp_get_thread_num() << std::endl;
116
+
117
+ }
118
+
119
+ }
120
+
121
+ }
122
+
123
+ ```