I/O 操作の順序付けされていない使用です。
ORDERED、MASTER、あるいは SINGLE ブロックの外の並列領域で I/O 操作を実行すると、予期しない順番で入力および出力操作が行われます。これにより、並列モードとシーケンシャル・モードで異なる実行結果がもたらされます。
ID |
問題箇所 |
説明 |
---|---|---|
1 |
呼び出し位置 |
I/O 関数が呼び出された場所 |
#include <stdio.h> int main(int argc, char **argv) { int i; FILE *fp; fp = fopen("random.txt", "w"); #pragma omp parallel for for (i = 0; i < 10; i++) { // bad: order is not guaranteed fprintf(fp, "i = %d\n", i); } fclose(fp); fp = fopen("ordered.txt", "w"); #pragma omp parallel for ordered for (i = 0; i < 10; i++) { // this is OK #pragma omp ordered fprintf(fp, "i = %d\n", i); } fclose(fp); return 0; }
© 2010 Intel Corporation. 無断での引用、転載を禁じます。