Hi All,
I made C version of sample code which demonstrate the problem(?).
I attach the code to this post.
I renamed files so that ML system does not remove files.
So, please rename back "cdemo.txt" to "cdemo.c" and
"Makefile.txt" to "Makefile." I'm sorry for this.
With these two files, make produce cdemo.exe.
If you run cdemo.exe several times, I think,
you will get different "out.txt" at time to time, as I did.
I see this behavior with mingw-w64 of x86-64 package of msys2.
I'm not sure whether this happens with other setup of mingw-w64.
So, I'm very grateful if you check behavior on your system and let me know,
especially if you have some other set up of mingw-w64.
Best,
Takashi
//--------------------------------------------------------------------
// Demo of possible bug in "omp for schedule(dynamic,1)" of mingw-w64
//--------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i,j;
double ai[6];
double a,b,c,x;
double Mat[6][6];
FILE *output;
ai[0] = 500.0;
ai[1] = 50.0;
ai[2] = 20.0;
ai[3] = 10.0;
ai[4] = 5.0;
ai[5] = 1.0;
output = fopen("out.txt","w");
#pragma omp parallel num_threads(4)
#pragma omp for schedule(dynamic,1) private(i,j,a,b,c,x)
for (j=0; j<6; j++) {
for (i=j; i<6; i++) {
a = ai[i];
b = ai[j];
c = a + b;
x = pow(c,3.0/2.0);
Mat[i][j] = x;
Mat[j][i] = x;
}
}
for (j=0; j<6; j++) {
for (i=j; i<6; i++) {
fprintf(output," %d %d %1.16e\n", i+1,j+1,Mat[i][j]);
}
}
fclose(output);
return 0;
}
//------------------------------------------------------------------
.SUFFIXES: .c .o
CC = gcc
CFLAGS = -lm -fopenmp -O3 -Wall
PROG1 = cdemo.exe
OBJS1 = cdemo.o
all: $(PROG1)
clean:
rm -f *.o *~ *.exe
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
$(PROG1): $(OBJS1)
$(CC) $(CFLAGS) $(OBJS1) -o $@ $(LIBS)
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public