| Hi, Not sure this is totally relevent to MacPorts Users who usually discuss install problems, but I have a weird one here and you might help! Testing OpenMP on my Mac, I find that the output is slightly random when running in parallel mode while it is correct in sequential mode. the same test on an Ubuntu machine did not reveal the same problem. I use Macport gcc7.3 : OpenMP>gcc --version gcc (MacPorts gcc7 7.3.0_0) 7.3.0 I compile with or without the -fopenmp option and in parallel mode I get this : OpenMP>gcc -fopenmp -o essai_par 2boucles.c OpenMP>essai_par a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 0, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_par a[0,1] 2, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 On the 6th call, I got zero instead of 2, on the 7th call, I got zero instead of 20000. No need to say this is totally random. I use the #pragma parallel private I also tried with the #pragma parallel default(shared) and I got this : OpenMP>gcc -fopenmp -o essai_pardef 2boucles.c OpenMP>essai_pardef a[0,1] 2, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 0, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 got the first two wrong, then a few correct ones. I returned to gcc5.5, just in case 7.3 would be faulty : OpenMP>gcc --version gcc (MacPorts gcc5 5.5.0_0) 5.5.0 OpenMP>gcc -fopenmp -o essai_pardef 2boucles.c OpenMP>essai_pardef a[0,1] 1, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 20000, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 OpenMP>essai_pardef a[0,1] 2, a[99,199] 0, a[999,999] 1000000 b[1] 2, b[100] 200, b[999] 1998 and it looks even worse. Is it a problem with the Mac (MBP, OS X 10.12.6) or a problem with the MP gcc ? I attach the test program if one wants to test it on another Mac machine. Laurent |
2boucles.c
Description: Binary data
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème" (devise Shadok) |
