0
votes

I'm trying to getting started using the C++ Amp Library. I am following this MSDN Magazine guide but I getting an error for this portion of code which is in the amplibrary(not my code).

 protected:
    _Accelerator_view_impl_ptr _M_accelerator_view;
    _Accelerator_view_impl_ptr _M_access_on_accelerator_view;
    void * _M_data_ptr;
    void * _M_host_ptr;
    size_t _M_elem_size;
    size_t _M_num_elems;
    bool   _M_owns_data;
    bool   _M_is_staging;

the error is

3 IntelliSense: illegal parameter type "void *" for amp-restricted function "Concurrency::details::_Texture_descriptor::_Texture_descriptor(Concurrency::details::_Texture *_Texture_ptr) restrict(cpu,amp)" (declared at line 538 of "c:\program files (x86)\microsoft visual studio 11.0\vc\include\amprt.h") c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\amprt.h 1466 16

the code i've copied so far

#include <amp.h>                // C++ AMP header file
#include <iostream>             // For std::cout etc
using namespace concurrency;    // Save some typing :)
using std::vector;     // Ditto. Comes from <vector> brought in by amp.h

int main()
{
    do_it();

    std::cout << "Hit any key to exit..." << std::endl;
    std::cin.get();
}

void do_it()
{
    // Rows and columns for matrix
    const int M = 1024;
    const int N = 1024;

    // Create storage for a matrix of above size
    vector<int> vA(M * N);
    vector<int> vB(M * N);

    // Populate matrix objects
    int i = 0;
    std::generate(vA.begin(), vA.end(), [&i](){return i++;});
    std::generate(vB.begin(), vB.end(), [&i](){return i--;});

    // Output storage for matrix calculation
    vector<int> vC(M * N);

    perform_calculation(vA, vB, vC, M, N);
}

void perform_calculation(
    vector<int>& vA, vector<int>& vB, vector<int>& vC, int M, int N)
{
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < N; j++)
        {
            vC[i * N + j] = vA[i * N + j] + vB[i * N + j];
        }
    }
}

BUILD OUTPUT

------ Build started: Project: Project1, Configuration: Debug Win32------  
Source.cpp 
LINK : padding exhausted: performing full link  
Project1.vcxproj ->C:\Development\Project1\Debug\Project1.exe 
CodeContracts:
Project1: Run static contract analysis. 
CodeContracts: Project1:  Cannot load assembly 'C:\Development\Project1\Project1\Debub\Decl\Project1.exe'
CodeContracts: Project1: Total methods analyzed 0  
CodeContracts:Project1: Total time 135ms. 0ms/method  
CodeContracts: Checked 0 assertions.  
CodeContracts: Project1: Static contract analysis done. 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1
That's an IntelliSense error -- when you actually try to build, what errors do you get (if any)?ildjarn
@ildjarn i get an error saying that do_it() is not definedAntarr Byrd
That's because you're declaring do_it after the point where it's used. Move the definition in front of main or add a forward declaration in front of main -- this has nothing to with C++11 or AMP, it's very fundamental C++ rules.ildjarn
@ildjarn Thanks been doing C# too long :). But I still can't build because of the first error.Antarr Byrd
Which error? The IntelliSense error? IntelliSense is orthogonal to building -- if you have an actual build error, please post it in your question. :-]ildjarn

1 Answers

3
votes

The intellisense error is a harmless known VS 11 Beta issue. You can safely ignore it. In the errors window, you can also filter to only show errors for your open files, and that way you’d filter this out if you prefer not seeing it. But this doesn’t stop you building and running, so just ignore.

As for the any other issues you find with the code, please follow the link of the MSDN magazine article for the code, and then you can either use that, or use it to compare what you are typing against what I provided with the article.

Cheers

Daniel