Help with my first C++ AMP programme


  • Hi, 

    It is my first attempt with C++ AMP, and do not manage to have it ok. I Wonder if the debbuger do not get me wrong so I prefer asking for help here.

    I do some processing on groups of 10 uint32_t. I have many of them in a vector. Within the lambda I call std::vector<uint32_t>::operator[] to access each of the uint32_t. But apparently this operator does not have the restriction specifier restrict(amp). 

    Fine. Does that mean that I can only use array_view with integral types ? If so, I can lay down my whole structure into a big array of uint32_t (array_view<uint32_t,2> e(N,sz)), but how do I specify I only want them by group of 10 ? Is my only way out to use tiles of 1x10 uint32_t ?

    So far, I build the Following code: 

    typedef std::vector<uint32_t> A;
    int N=100;
    int sz = 10;
    A a(sz,1);
    std::vector<A> v(N,a);
    extend<1> e(N);
    array_view<A,1> a(e,v);

    parallel_for_each(e, [=](index<1> idx) restrict(amp)
        uint32_t b=0;
        for(int i = 0; i<sz; i++)
            b+=a(idx)[i]; /* <= does not work. The overloaded function std::vector<uint32_t>::operator[] has restriction specifiers not compatible with lambda function blablabla restrict(amp) */


    Friday, January 4, 2019 2:58 PM