locked
VS 11 Beta C++ AMP Runtime Exception RRS feed

  • 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.




    Wednesday, May 2, 2012 6:14 PM

Answers

All replies