Answered by:
VS 11 Beta C++ AMP Runtime Exception

Question
-
#include "stdafx.h" using namespace std; using namespace concurrency; typedef array<float, 1> FloatArray; typedef unique_ptr<FloatArray> UPFloatArray; typedef array_view<float, 1> FloatArrayView; const int buffSize = 10; void compute(FloatArray& buff) { parallel_for_each( concurrency::extent<1>(buffSize), [&buff](index<1> idx) restrict(amp) { buff[idx + buffSize] = buff[idx] * 2.0f; } ); } int _tmain(int argc, _TCHAR* argv[]) { auto buff = UPFloatArray(new FloatArray(buffSize * 2)); auto input = buff->section(0, buffSize); auto output = buff->section(buffSize, buffSize); for (int i = 0; i < buffSize; i++) { input[i] = i; } compute(*buff); output.refresh(); for (int i = 0; i < buffSize; i++) { cout << i << ": " << output[i] << endl; } cout << "Press any ..."; getchar(); return 0; }
If I remove trailing "f" in here:
buff[idx] * 2.0f;
like
buff[idx] * 2.0;
The compiled program crashes whit this exception:
Unhandled exception at at 0x7635B9BC in ConsoleCPPAndAMPTests.exe: Microsoft C++ exception: Concurrency::runtime_exception at memory location 0x003DF004.
- Edited by unbornchikken Wednesday, May 2, 2012 7:55 PM
Wednesday, May 2, 2012 6:14 PM
Answers
-
Hi unbornchikken
Is that all you get or is there a message that goes with that runtime_exception? Can you try to catch it as per our example:
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/09/runtime-exception-of-c-amp.aspxIt sounds like a double precision issue, please read this post and let us know if that is it:
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/07/double-precision-support-in-c-amp.aspxCheers
DanielPS. As a total ignorable aside, there is no VS 2011 (-: http://www.danielmoth.com/Blog/Visual-Studio-11-Not-2011.aspx
http://www.danielmoth.com/Blog/
- Proposed as answer by Zhu, Weirong Wednesday, May 2, 2012 7:51 PM
- Marked as answer by unbornchikken Wednesday, May 2, 2012 8:26 PM
Wednesday, May 2, 2012 6:36 PM
All replies
-
Hi unbornchikken
Is that all you get or is there a message that goes with that runtime_exception? Can you try to catch it as per our example:
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/09/runtime-exception-of-c-amp.aspxIt sounds like a double precision issue, please read this post and let us know if that is it:
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/07/double-precision-support-in-c-amp.aspxCheers
DanielPS. As a total ignorable aside, there is no VS 2011 (-: http://www.danielmoth.com/Blog/Visual-Studio-11-Not-2011.aspx
http://www.danielmoth.com/Blog/
- Proposed as answer by Zhu, Weirong Wednesday, May 2, 2012 7:51 PM
- Marked as answer by unbornchikken Wednesday, May 2, 2012 8:26 PM
Wednesday, May 2, 2012 6:36 PM -
Yes, it is a runtime exception about not supported double precision on the device. I think it should be better if the compiler automatically do double to float constant conversion on devices which has lack of double support, instead of throwing runtime exceptions.
PS. Topic title corrected. ;)
Wednesday, May 2, 2012 8:06 PM