0

I'm having trouble debugging my AVX2 code in Visual Studio 2015, update 1 (targeting Win10).

When using the debugger and inspecting an AVX2 register, the contents differs when using a breakpoint and stepping over the _mm256_insertf128_ps-intrinsic (for example) compared to running the program normally. The bug is easy to reproduce. Simply create a new Win console application with the following code in the main function:

1: __m128 lo = _mm_set1_ps(2.0f);
2: __m128 hi = _mm_set1_ps(4.0f);
3: __m256 avx = _mm256_castps128_ps256(lo);
4: avx = _mm256_insertf128_ps(avx, hi, 1);
5: for (int i = 0; i < 8; i++)
6:     printf("%.2f\n", avx.m256_f32[i]);

Setting a breakpoint on line 4 and stepping over it causes the following output from the print loop on lines 5-6:

2.00
2.00
2.00
2.00
0.00 <- Wrong!
0.00 <- Wrong!
0.00 <- Wrong!
0.00 <- Wrong!

Running the program gives the following output:

2.00
2.00
2.00
2.00
4.00 <- Correct
4.00 <- Correct
4.00 <- Correct
4.00 <- Correct

I have tried this using both the MSVC and Intel compiler (ver. 16), and both exhibit the same behavior.

Has anyone else stumbled on this problem? Does anyone know what could be the cause for this? Is there any workaround for it?

Thanks in advance!

repstosq
  • 3
  • 1
  • 1
    Source looks fine, I think. Post the asm; it should be obvious whether or not it matches the source. Also maybe try a non-MSVC-specific of getting the floats out of the vector. (e.g. store to a float array with `_mm256_storeu_ps`, or shuffle each element in turn to the low element of the register and cast to scalar with `_mm_cvtss_f32`) – Peter Cordes Mar 01 '16 at 10:26
  • 3
    It is a bug in the new debugging engine, it has a lot of them. Workaround is Tools > Options > Debugging > General > tick "Use Native Compatibility Mode". That forces the older debugging engine to be used, it doesn't have this problem. You can report the bug at connect.microsoft.com – Hans Passant Mar 01 '16 at 12:03

1 Answers1

0

If you download "Visual Studio 2015 Update 2" you will find this is now fixed.

Answer found here; https://stackoverflow.com/a/36801311

Community
  • 1
  • 1