none
compiler error c3577 with restrict(cpu) RRS feed

  • Question

  • Hi,

    I tried to play with the code example from one of the msdn pages

    http://msdn.microsoft.com/de-de/library/vstudio/hh265136.aspx

    #include <amp.h>
    #include <iostream>
    using namespace concurrency;

    const int size = 5;
    void CppAmpMethod(void);

    int main(void) {
        CppAmpMethod();
        return 0;
    }

    void CppAmpMethod() {
        int aCPP[] = {1, 2, 3, 4, 5};
        int bCPP[] = {6, 7, 8, 9, 10};
        int sumCPP[size];
        
        // Create C++ AMP objects.
        array_view<const int, 1> a(size, aCPP);
        array_view<const int, 1> b(size, bCPP);
        array_view<int, 1> sum(size, sumCPP);
        sum.discard_data();

        parallel_for_each(
            // Define the compute domain, which is the set of threads that are created.
            sum.extent,
            // Define the code to run on each thread on the accelerator.
            [=](index<1> idx) restrict(amp)
        {
            sum[idx] = a[idx] + b[idx];
        }
        );

        // Print the results. The expected output is "7, 9, 11, 13, 15".
        for (int i = 0; i < size; i++) {
            std::cout << sum[i] << "\n";
        }
    }

    with restrict(amp) the code compiles fine, but if I change to restrict(cpu), I get the following error message

    amp_ex1.cpp(32): error C3577: 'concurrency::parallel_for_each kernel argument' ist unzulässig: Aufruf für Member 'void operator()(Concurrency::index<_Rank>) restrict(amp)' kann nicht aufgelöst werden.
    1>          with
    1>          [
    1>              _Rank=1
    1>          ]
    1>          Auflösungsfehler folgt
    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\amp.h(6429): error C3930: 'CppAmpMethod::<lambda_ecda4d9e53435552651ff852ce00b7d1>::operator ()' : Keine überladene Funktion verfügt über Einschränkungsspezifizierer, die mit dem Ambient-Kontext 'Concurrency::parallel_for_each' kompatibel sind.

    ...what is wrong with restrict(cpu)? MSDN-Help pages tell that restrict(cpu) is a valid term.

    If restrict(amp) restricts the compiler to some subset, why is it wrong to use the superset?

    Thank You for Your answers.

    Norbert

    Saturday, February 16, 2013 12:19 PM

All replies