Possible bug with OpenMP and optimizations in version 12.0.2.154

Possible bug with OpenMP and optimizations in version 12.0.2.154

I am having some problems with C++ compiler version 12.0.2.154 (build 20110112). My code works fine on version 11.1.8.070 and on gcc, but I get wrong numeric results on the newest version.

On icl I use /fast /Qopenmp /fp:precise /fp:double.

On gcc I use -O3 -ffast-math -fopenmp.

I noticed that if I remove OpenMP it works fine. It also works if I use /O1.

The only place where I use OpenMP is in the following function:

void calc_curvature(big_vector_t *y, big_vector_t *z) {

int i, d;

#pragma omp parallel for private(i, d)

for ( i = 0 ; i < params->particle_count ; i++ ) {

for ( d = 0 ; d < 3 ; d++ ) {
z[i].v.a[d] -= calc_dW(y, i, d) / params->particle[i].m ;
}

}

}

Here, params is a global and calc_dW does not change anything in y.

It is a physical simulation. The summation is the force. In the newer compiler the force is much less than it should be. It is not noticeable in the first cycles, but as the simulation goes on, the results differ a lot.

P.S. This site is very very slow. I get several time-outs and server errors. Are you experiencing problems?

29 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

It would nice if you can help us with small butcomplete test case to investigate the issue.

I found where the problem is. It is another function that uses OpenMP:

void calc_membrane(big_vector_t *y, big_vector_t *z) {

int i, d;
element_t e;
double dW[3][3];

#pragma omp parallel for private(i, d, e, dW)

for ( i = 0 ; i < params->triangle_count ; i++ ) {

e.X[0] = params->reference[params->triangle[i].node[0]].x;
e.X[1] = params->reference[params->triangle[i].node[1]].x;
e.X[2] = params->reference[params->triangle[i].node[2]].x;

e.x[0] = y[params->triangle[i].node[0]].x;
e.x[1] = y[params->triangle[i].node[1]].x;
e.x[2] = y[params->triangle[i].node[2]].x;

for ( d = 0 ; d < 3 ; d++ ) {
dW[0][d] = calc_dW(e,0,d) / params->particle[params->triangle[i].node[0]].m ;
dW[1][d] = calc_dW(e,1,d) / params->particle[params->triangle[i].node[1]].m ;
dW[2][d] = calc_dW(e,2,d) / params->particle[params->triangle[i].node[2]].m ;
}

#pragma omp critical

for ( d = 0 ; d < 3 ; d++ ) {
z[params->triangle[i].node[0]].v.a[d] -= dW[0][d] ;
z[params->triangle[i].node[1]].v.a[d] -= dW[1][d] ;
z[params->triangle[i].node[2]].v.a[d] -= dW[2][d] ;
}

}

}

If I remove these two pragmas, the code works fine. And, as I said before, it also works fine with icl 11.1, gcc or /O1.

I am sorry I can't provide a small complete test case. My code is quite big. The source code is over 100KB.

Try this:

void calc_membrane(big_vector_t *y, big_vector_t *z) {

#pragma omp parallel for

for (int i = 0 ; i < params->triangle_count ; i++ ) {

element_t e;
double dW[3][3];

e.X[0] = params->reference[params->triangle[i].node[0]].x;
e.X[1] = params->reference[params->triangle[i].node[1]].x;
e.X[2] = params->reference[params->triangle[i].node[2]].x;

e.x[0] = y[params->triangle[i].node[0]].x;
e.x[1] = y[params->triangle[i].node[1]].x;
e.x[2] = y[params->triangle[i].node[2]].x;

for (int d = 0 ; d < 3 ; d++ ) {
dW[0][d] = calc_dW(e,0,d) / params->particle[params->triangle[i].node[0]].m ;
dW[1][d] = calc_dW(e,1,d) / params->particle[params->triangle[i].node[1]].m ;
dW[2][d] = calc_dW(e,2,d) / params->particle[params->triangle[i].node[2]].m ;
}


#pragma omp critical
{

for (int d = 0 ; d < 3 ; d++ ) {
z[params->triangle[i].node[0]].v.a[d] -= dW[0][d] ;
z[params->triangle[i].node[1]].v.a[d] -= dW[1][d] ;
z[params->triangle[i].node[2]].v.a[d] -= dW[2][d] ;
}
}

}

}

Jim Dempsey

www.quickthreadprogramming.com

I get compile errors:

membrane.c
membrane.c(509): error: expected an expression
    for (int i = 0 ; i < params->triangle_count ; i++ ) {
         ^

membrane.c(509): error: identifier "i" is undefined
    for (int i = 0 ; i < params->triangle_count ; i++ ) {
                     ^

membrane.c(522): error: expected an expression
      for (int d = 0 ; d < 3 ; d++ ) {
           ^

membrane.c(522): error: identifier "d" is undefined
      for (int d = 0 ; d < 3 ; d++ ) {
                       ^

membrane.c(530): error: expected an expression
      for (int d = 0 ; d < 3 ; d++ ) {
           ^

membrane.c(509): error: OpenMP for-init does not conform
    for (int i = 0 ; i < params->triangle_count ; i++ ) {
    ^

membrane.c(509): error: OpenMP for-test does not conform
    for (int i = 0 ; i < params->triangle_count ; i++ ) {
    ^

membrane.c(509): error: OpenMP for-incr does not conform
    for (int i = 0 ; i < params->triangle_count ; i++ ) {
    ^

Jim changed the code to take advantage of C99 features, so you'll need to use -std=c99

With/Qstd=c99 it compiles fine, but I still get the same results. It works on version 11.1 but not on 12.

The result is as if this function is not executed at all. Compiling it on 11.1 without this function yields the same (or very similar) results as compiling it on 12 with the function.

Edit: I just ran a test. I saved the vector "z" before and after calling the function "calc_membrane". On version 12 it is not being modified. As I said, it's like the function is not executed at all.

I made a test case. See atached file.

It loads some data and runs my function. The contents of the vector z are saved before and after calling the function. Without openmp it works fine, but with it the vector remains unchanged.

There is also a batch file with the command line I am using.

Attachments: 

AttachmentSize
Downloadapplication/zip bug_test.zip38.77 KB

I get compilation error with Intel compiler 12.0 when compiling attached testcase.

c:\>icl test.c /fast /Qopenmp /fp:precise /fp:double

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.127 Build 20101116

Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

test.c

ipo: remark #11001: performing single-file optimizations

ipo: remark #11006: generating object file C:\Users\opsachan\AppData\Local\Temp\

ipo_772.obj

(0): internal error: backend signals

icl: error #10014: problem during multi-file optimization compilation (code 4)

It's not a problem with my code. It's an internal error. Seems to be a bug in the compiler.

I see you are using version12.0.1.127. Try using the latest one: 12.0.2.154.

Thanks for the clarification. I moved to 12.0.2.154. I can compile and run the testcase with OpenMP and without it. But I did not get any visual clue on differences. Could you please let me know what value is going wrong with OpenMP?

Om

Two files are created when you run the program.bug_00000.txt is all zeros as it should be. bug_00001.txt should have many non-zero values, but it is also all zeros when you use OpenMP. It shows that the vector is not being modified when OpenMP is used.

BTW, I am using Windows 7 x64 on a Core i7 930.

The private variables are constucted using default constructor by each thread.The array dW[3][3] in private list seems to be incorrect.

You may changed your codeas given below and try.

// double dW[3][3];

//#pragma omp parallel for private(i, d, e, dW)

#pragma omp parallel for private(i, d, e)

for ( i = 0 ; i < params->triangle_count ; i++ ) {

double dW[3][3];

I tried your code. Same problem as before. "z" remains unchanged when I use OpenMP.

Once again, this code:

- works on version 11.1 with or without OpenMP

- works on GCC with or without OpenMP.

- works on version 12 without OpenMP.

- fails on version 12 with OpenMP.

And remember that it caused an "internal error" on an earlier release of the v12 compiler.

Small update:

- I tried the code with Microsoft Visual Studio 9.0. It works fine.

- With Intel v11.1 on Linux also works fine.

- With Intel v12 on Linux I get the same problem.

Bug is still present in version 12.0.4.196.

I modified the test case (attached). It now shows on screen the differences between running the same code with and without openmp.

If I compile with version 11.1.070 I get:

calculating with openmp
zeroes: 57 non_zeroes: 1869
calculating without openmp
zeroes: 57 non_zeroes: 1869

Which is correct. With version 12.0.4.196 I get:

calculating with openmp
zeroes: 1926 non_zeroes: 0
calculating without openmp
zeroes: 57 non_zeroes: 1869

Which is wrong. Notice that with openmp the vector does not get updated at all. It remains all zero.

Any updates on the status of this issue?

Attachments: 

AttachmentSize
Downloadapplication/zip bug_test_new.zip38.78 KB

I tried the code in bug+test+new.zip using Microsoft C (16.00.30319.01 for x64) and found that different optimization levels gave different results.

This could indicate that there are problems with the code or with its usage of OpenMP directives.

When dealing with floating point arithmetics, it is normal to get slightly different results when using different optimizations and OpenMP. If you just change the order of a sum you might get different results. But this is not the issue here. I am not getting different reults. I am getting all zeroes when using compiler v12. I tried this same code on GCC, Microsoft and Intel v11. They all give slightly different results, but not all zeroes.

Perhaps I was too brief in my previous post, not being aware of the significance of the counts in your application. However, this is what I found, which is different from what you stated about Microsoft C.

s:langItalo>cl /Od /openmp test.c /Fetest
Microsoft  C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.c
Microsoft  Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

s:langItalo>.test
calculating with openmp
zeroes: 1926     non_zeroes: 0
calculating without openmp
zeroes: 1926     non_zeroes: 0

Strange. Are you loading the data file?

So, if Microsoft's compiler is correct, then Intel v11, with ou without OpenMP, and v12 without OpenMP are wrong?

Here is what I get using Microsoft:

Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 tools.
Microsoft C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

test.c
Microsoft Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

/out:solver.exe
test.obj
calculating with openmp
zeroes: 57 non_zeroes: 1869
calculating without openmp
zeroes: 57 non_zeroes: 1869

With GCC I get:

Using built-in specs.
COLLECT_GCC=H:\MinGW32\bin\gcc.exe
COLLECT_LTO_WRAPPER=h:/mingw32/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-lib
stdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.0 (GCC)
test.c: In function 'v3_norm':
test.c:87:3: warning: implicit declaration of function 'sqrt'
test.c:87:10: warning: incompatible implicit declaration of built-in function 'sqrt'
calculating with openmp
zeroes: 57 non_zeroes: 1869
calculating without openmp
zeroes: 57 non_zeroes: 1869

With that, you have exposed the bug in your program: in function v3_norm(vector3_t x), you use the function sqrt without declaring its type. Either add #include or declare extern double sqrt(double); in that function.

GCC detected your incorrect use of the known function sqrt(). I suspect that the other compilers did not.

It's just a warning. Anyway, I added #include on the test file. Now I don't get the warning anymore. But the results are the same. On Intel v12 I get:

Intel Parallel Studio XE 2011 Update 1
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Intel Composer XE 2011 Update 4 (package 196)
Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 tools.

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

test.c
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:\Users\Bim\AppData\Local\Temp\ipo_2548.obj
Microsoft Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test.exe
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
C:\Users\XXX\AppData\Local\Temp\ipo_2548.obj
Press any key to continue . . .
calculating with openmp
zeroes: 1926 non_zeroes: 0
calculating without openmp
zeroes: 57 non_zeroes: 1869

To sum up:

Intel v11 without openmp: works
Intel v11 with openmp: works
Microsoft v15 without openmp: works
Microsoft v15 with openmp: works
GCC v4.5.0 without openmp: works
GCC v4.5.0 with openmp: works
Intel v12 without openmp: works
Intel v12 with openmp: does not work

The only one that does not work is Intel v12 with openmp.

>It's just a warning. Anyway, I added #include

I would not take that position, since not including math.h constitutes an error that many compilers would compile into buggy code without issuing any warning. With this error fixed, I think that any C compiler would correctly compile your program for operation in serial mode.

The operation under OpenMP is another question altogether. You probably have to heed Jim Dempsey's suggestions in this thread and check that the "with openmp" function(s) are actually causing parallel threads to be run with all the compilers that you try.

I added printf("%i", omp_get_thread_num()); inside the openmp blocks to make sure that parallel threads are being run in each case. The result shows that indeed they are.

In Intel v11 I get:

Intel C++ Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1.070
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 tools.

Intel C++ Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1    Build 20101201 Package ID: w_cproc_p_11.1.070
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.

test.c
ipo: remark #11001: performing single-file optimizations
ipo: remark #11005: generating object file C:UsersBimAppDataLocalTempipo_2208.obj
Microsoft  Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:test.exe
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
C:UsersBimAppDataLocalTempipo_2208.obj

calculating with openmp
33300055522277444666111733333300000055555522224444442266661116171717733333300000067755555544444422221112123313100000033366666677777755555544444422221112101010033333366667777700255555544444411176613131
33330000002222225555444444557777776666111616113333330000002222224444445555557777776666111616113333330000002222224444445555557777776666111616113333330000002222224444445555557777776666111633333300000022
22221644444455557777333300000011557733222222666666444444000010011155555577777733333312222226666444400000055555517777773333332222220000005555551116677777733333344222222000000555555666677777733333344444
42222220000005555777777111556633333344444422222200000077771117755555516666661333333144444422220000002277777755556666665533333311144440000001441222277777766666655555533333300000044444412277777766665555
55663333000000334444441111112222227777775555666666550000003333334444111441222222177777766666615555550000003333334444442222227777776666661111115555550000003333444444332222227777776666661111115555550000
00444444333333222222777777666611166555555100000014444333333222222447777771666666555500000033333355222222444444777777111116666000000333333166555555222222444444777700000033333377111666655555522222244440
00000446633333311177777755555522222200000044444466663333111331117777776655555522222200000044443333111331117777666655555544772226222000633333301110055555514444777722222447726666661333333100005555554444
44007777772222226666333311136611135555554444440000007777772222226666661111333333555555144440000007777774422222266666613333335555550000777777444444222266666611100333333555555777777444444666666000000333
33312215555557777771444466666644000000333333222222555555777711166666644440000004411177333333222222555555666666000000444411144777777333322222255555513316666000000444444777777222222555533333355166000000
44444477772222333355555511166666622000444444775555551113306666662222224444777777555511144553333336666661001222222177777744444455555533333366660000006622222211117777771444444555533333300000066666622222
27777774444443333330006666660001222222777777444444553333336666000000661111112222227777774444445555553333330000666611166110012222227777774444445555553333336666660000111002222227777771144444415553333336
66666000000222222777777555444444111133333366666600000022222277777755555514444443333336666660000002222221777777555555444444333333666666000000222222111177777755555511444444333333666666000000222222777777
55551115511144444433333366666600000022222277777755555511144444433333316666661100000022222277777755555544443333336666661110000004422222277777711155555533333366666600000044444422222277777711111155555333
33366666600000044444422222277777711111133333366666600000044444422222277777711133333366666600000051144444412222227777773333336666000000555555444444661112222221777777333333100000015555544444456666662222
22777733333300000077111114444441555555666666222222333333000000777744444477111155555566666622222233333300000044444477777755555511666666222222333333000000444444777755555511177666666222222113333330000004
44444155555577777766666622233333322200000044444411111155577777766666633333322222200000044444411177777766633333311166622222200000044444455577777733333311111666666222222100000044444455555577777733333366
66662222221111110000004444445555557777773333336666662222111220000004444445555557777773333331166666622222200000044444455555577777733333366666622222000444444555777777255513333330006666664444447777772222
22555555111111333333000000666666444444777777222222555555111333333100000066666644444477777722222255555533333300000066666644444477777722222255555533333300000011666666444477777744222222555555333333000000
11111166666677777744444422222255555533333300000011111166666677777744444422222255555533333300000011111166666677777744444422222255555533333300000111111666666777777444444222222555555033331113366666677777
74444441112222225555550000003333336666667777774444441111112222225555550000003333336666667777774444441111112222225550003333335550006666667777774444441111222222333333555555000000666666777777444444112222
22333333555555000000666666777777444444111111222222333333555555000000666666777777444444111111222222333333555555000000666666777777444444111111222222333333555555000000666677777744444466111111222222333333
55555500000077777744444466666611111122222233333355555500000077777744444466666611111122222233333355555500000077777744444466666611111122222233333355555500000077777744444466666611111122222233333355555500
00007777774444446666661111112222223333335555550000007777774444446666661111112222223333335555550000007777774444446666661111112222223333335555550000007777774444446666661111112222223333335555550000007777
77444444666666111111222222333333555550007777770005444444666666111111222222333333777777000000555555444444666666111111222222333333777700000055555577444444666666111111222222333333000000555555777777444444
66666611111122222233333300000055577777755544444466666611111122222233333300007777775555550044444466666611111122222233333377777755555500000044444466666611122222233333311177777755555500004444440066666622
22223333331111117777775555554444440000006666662222223333331111117777775555554444440000006666662222223333331111117777775555554444440000006666662222223333331111117777775555554444440000006666662222223333
33111111777777555555444444000000666666222222333333111111777777555555444444000000666666222222333333111111777777555555444444000000666666222222333333111111777777555555444444000000666666222222333333111111
77777755555544440000006666664422222233333311111177777755555500000066666644444422222233333311111177777755555500000066666644444422222233333311111177777755555000000666666544444422222233333311177777711100
00006666665555554444442222223333337777771111110000006666665555554444442222223333337777771111110000006666665554444442222225553333337777771110000001116666664444442222225555553333337777770000001111116666
66444444222222555555333333777777000000111111666666444444222222555555333333777777000000111666666444444111222222555555333333777777000000666666444444111111222222555553333335777777000000666666444444111111
22222233333355555577777700000066666644444411111122222233333355555577777700000066666644444411111122222233333355555577777700000066666644444411111122222233333355555577777700006666664444441111110022222233
33335555557777776666664444441110000002222223333331115555557777776666664444440000002222223333331111115555557777776666664444440000002222223333331111115555557777776666664444440000002222223333331111115555
55777777666644400000022222266333333111111444555555777777000000222222666666333333111111444444555555777777000000222222666666333333111111444444555555777700000022222277666633333366111144444411555555000000
22222277777733333366666644441111115555554400000022222277777733333366666611111155555544440000004422222277777733333366666611111155555500000044444422222277777733333366666611111155555500000044444422227777
77333333666666111111555555220000004444447777773333336666661111115555552222220000004444447777773333336666661111115555552222220000004444447777773333336666661111115555552222220000004444777777333333666666
44111111555555222222000000777777333333666666444444111111555555222222000000777777333333666666444444111555222222555111000000777777333333666666444444222225555552111111000000777777333333666666444444555552
22222511111100000077777733333366666644444422222255555511111100000077777733366666644444422222255555511111100000077777766666644444422222255555511111100000077777766666644444422222255555511111100077777766
66664444442222225555551111117776666664444442222225551116666664442226666666666666665555555555555555555551115555551111115551111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
zeroes: 57     non_zeroes: 1869

calculating without openmp

zeroes: 57     non_zeroes: 1869

GCC and Microsoft are similar. They all show different thread numbers. On Intel V12 I get:

Intel Parallel Studio XE 2011 Update 1
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Intel Composer XE 2011 Update 4 (package 196)
Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 tools.

Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

test.c
ipo: remark #11001: performing single-file optimizations
ipo: remark #11006: generating object file C:UsersBimAppDataLocalTempipo_1080.obj
Microsoft  Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:test.exe
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
C:UsersBimAppDataLocalTempipo_1080.obj

calculating with openmp
03334441112225560665077733333344444111412121226662265656555500000077777733334444411131413122226665556265625500000077774444447733333111311166662626222255555500000044444477777733331113113166666622222255
55550000004444447777773333311131116666262625555552220000004444447777773333111311316665656565222222550000004444447777773333311131116666262622225555550000004444447777773333311131116666262622225555550000
00444444777777333331113111666626262555555222000000444444777777333311131311666565656555222222000000444444777777333331113111666565656555222222000000444444777777333331113666666551515155222222000000444444
77777733333666366611151515155522222200000044444477777733336661115131516656555222200000022344444477777111711166656565655500000022222233334444447777111773366665656555511010000022222244444477777733333666
35565611151515160000002222224444447777773335555111666666000333222550022441014124447777766676636333335555550000111212121444444777777666332260662033335555511154414141777776664472262626200000023333335555
51115111444444777776667666000000222222333333555551115141414444777776667606060022222233350055551113334415141777776666766444222222000000333333555551115771717176667646464444222222000000333333555551115771
71717666766644444422222200000033333355555111577171717766666644444422222200000033355555111713151337777666764646444422222200000055551115115133333377777666766644444422222200000055555511111313337777766633
44676464222222000000555551111514143333337777766672262626200000025555511154414133144433337777766670060626222555550022111504411414443333337777766672262626225555550000011101114444443333337777766672262626
22555555000001110111444444333333777776667226262622555500000011155141414433333377777676664664222200000022555551115131313333777776667446466000000222222555551114453314131377777766606363600000222222555544
44111141517777753333376666364600000022222111211155555577777733333344444666600646000022222111255151517777333337755344444666006460622222211101717177775555553333330044444666466262222111277171717755555533
33330000004444466662626222111714117777755555523333330000066606664444411114117777775555552222223333000006663304464664411147717171555555772222223333330000066606464644111515151555777777442222223333000000
66663636111515151555777777444444222222000000333366666611151513155557777774444442222000003226660666111515151555777777444444333333222222000066606066111151515555777744447744333333222222000066600111556656
55115177777744444433333322222200006665560656551111510177777744444433333322222666555626565000000111577171717744443333222223366646264600000055555111577171717733332233222244444466666600000055555111777777
33333311152222244444662466660000007777773333331111151555522522244444666666240000007777773333331111115555566656662222224444440000007777773333331111115555665566662222224444440000007777773333111111555336
66555662222644440022000047777771114333111553335556665222220066200007777776444411144131313333555552222225000077777700666666444441114333113332221552225555777777000000666644444433333311166121212222555557
77777500000044443333336644666611112121222277777755555000000533333344444466666611112121227777772200000055555533333344444466666611117171777722222200000055555333333544444466666611117177177222222700000033
33335555444444556666661111212122227777770000003333334444445555665566661111212122227777770000003333433444445555566656661111121222227777770000003333444444553355566656611162212112227777770000004444333333
55555544666661116221211222777777000000333333555555444444666661116222111222777777000000333333555554444446666665111121212222777777000000333333444444666666555551111115222222777777000000333333444444666666
11115115555522222277777700000333333044444466666611115115555225222277773333377000000444446666663411111155555225222277770000006666667733334444441113315115555222222000000566666677774444447733333311121212
10000005522255566656644467777773344333114310101012220055555522066666627777774444443333311135515110000006666665552222227777774444443333311130001116666665500055225522227777774444333333111441616166660000
00555552225777773333332224444447111161616666000055005553335333222222444444777771117661611666000000555553333335222222444444777771117661611666000000333335555552222224444447777771111116666660000005553555
22222244444477777711111166666600000033333355555225222244444477777711111166666600000033333355555522222244444477777711111661666600000033333355555522222244444477777711166611166600000033333355555522222244
44447777117716116616660000003333335555552222224444447777771116116666600000033333355555522214444447777776666660020000333333555555111111444444772277776666660000003333335555551114444442222227777776666660
00000333355555544444422222277777766666600000055555544444422222277777766666600000055555544444422222277777766666600000055555511133444444222222777777666666000000555511133333311155444444222222777777666666
00000033331133155555544444422222277777766666600111000033333355555445444422222277777766666611111100000033333355555544444422222277777666666111111000000333333555555444444222222666666711111100000033333355
55554444222446662226667777117711110000003333335555544444422222266666677577771111110000003333334444442222266666655255557777771111110000003333334444446666662222225555777777551111110000003333334444446666
66222222777777555551115111000000333333444446666662224777777552511111100000033333366666622444444777777111111000555003333336666662222224444447777771111115550555333333666666222222444444777777111110001000
55555533333366666622222244444477777711111100000555055533333366666622222244444477777711111100000055533355533366666622222244444477777711100000055555533333366666611122222244444477777700000555555333333666
66611111122222244404447777755755533533336666661111112222220000004444447777775555553333336666661111112222220000004444447777775553336666663335551111112222220000004444447777776666663333335555551112222220
01110000444444777777666666333333555552252222111111000004444447777776666663333335505552222221114444447777776666663333335111000000222222444444777777666666333333555551110000002222225111444444777777666666
33333300000022222255555115144444477111777766666333333000000226222255555544444411177777733113000000333166666622222255555544444477777700000033333311166666622222255544444477777711155500003333336600666622
22224444447777771111155155553333330000006666662222224444447777771111155153330000003555663366662222224444447777771110111000005555553333336666662222224444747477771111110000005555553333336666662222224444
44777777111111000005555553333336666662202222444444777777111551115553353333666600000022244444466772722111111555555333333007770000444446666662222221111145515555333333777777000000666666222222444444111115
51555533333377777700000066666622222244444114155555533311133377777700000066666622222244444455555511111133333377777700000066662226644455511111133333377777700000066666611133333344422211155577777700000066
66663333334444442222221111115555557777770000006666663333334444442222211211115555577777700500006666663333334444222441117777771222555110055500006666663333334444447777772222221111115555500066666633333344
44447772222221116666660005777333111443334444222226666660020000555557775777111111333333444444666666222222000000555557775777111111333333444444666666222222000000555555777777111111333333444444666666222222
00000550575577577711131113333344444466666622222200000055555577777711111133333344444466666622222200000055555577777711111133333344444466666622222200000055555577777711113333334411444466622222000000555777
77733333311111155524444440000077777733033331111115555522252224444447777770000003333331111115552255522224444447770000003333111111555555222222444444000000111111555222222533554444440000001111112222223333
33555554454000111111222222333333555555111111222333555555111111555555111111555111
zeroes: 1926     non_zeroes: 0

calculating without openmp

zeroes: 57     non_zeroes: 1869

Here is the code with the math.h fix and the thread numbers.

Attachments: 

AttachmentSize
Downloadapplication/zip bug_test_newer.zip39.34 KB

Just a reminder, this bug is related to OpenMP and optimizations. If I use /Od or /O1 it works fine. /O2 /O3 and /fast don't work.

Leave a Comment

Please sign in to add a comment. Not a member? Join today