- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When running a MKL_DNN operation previously created using dnnConvolutionCreateForwardBias_F32() the XMM7-8 registers (and possibly more) are not preserved.
I have code similar to this (but of course much more elaborate) which does not work in relase mode:
void RunConvolution() { dnnPrimitive_t handle; dnnConvolutionCreateForwardBias_F32(&handle, --- other pars ---); void* resources[dnnResourceNumber]; --- fill in pointers to buffers, kernel and bias --- dnnExecute_F32(handle, resources); } void main() { Timer timer; for (o =0; o < 10; o++) { for (int i = 0; i < 10; i++) RunConvolution(); cout << timer.Elapsed() / 10.0 << endl; } }
I am using the Visual Studio 2017 compiler and I noted it uses XMM7 to store the constant 10.0 _over_ the entire loops which calls RunConvolution(). I tracked the contents of the register and noted that it is destroyed by dnnExecute_F32() but that's just a thin wrapper so the actual problem is probably in some assembly code in the function redirected to when the handle refers to a structure created by dnnConvolutionCreateForwardBias_F32().
According to Microsoft documentation XMM6 and up are to be preserved over function calls, so the numbers printed are bogus. I can't see any other explanation for this than that the calling convention has been breached by the MKL DNN code.
I am using MKL 2018.1 version, 64 bit, static linking with intel threading (not TBB).
I have not tested other operations except dnnConvolutionCreateForwardBias_F32.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dnnConversionExecute_F32() also does not preserve registers properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Gustafsson, bengt
Thank you for raising the question. So as i understand, that the original problem is the code won't work in release mode, the possible reason is XMM7-8 registers (and possibly more) are not preserved. As. https://stackoverflow.com/questions/262162/why-did-windows-64-choose-to-require-xmm6-and-xmm7-to-be-saved-restored
Could you please tell what kind of CPU you are using? does the code work for other machine?
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue is, as you presumed, that you violate the register saving convention that XMM6-7 have to be preserved, and that Microsoft compilers (both 2013 and 2017) rely on these registers actually being preserved.
I'm running a Intel i7-8700.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested this with MKL2018.2 and it fixed the problem.
Thanks for the good work!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Gustafsson,
Thank you a lot for the confirmation!
Thanks,
Ying
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page