gpt4 book ai didi

c++ - 功放库错误

转载 作者:行者123 更新时间:2023-11-28 00:58:11 24 4
gpt4 key购买 nike

我正在尝试开始使用 C++ Amp 库。我正在关注这个 MSDN Magazine guide 但是我在 amplibrary(不是我的代码)中得到这部分代码的错误。

 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;

错误是

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

到目前为止我复制的代码

#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 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 ==========

最佳答案

智能感知错误是一个无害的已知 VS 11 Beta 问题。您可以安全地忽略它。在错误窗口中,您还可以过滤以仅显示打开文件的错误,如果您不想看到它,可以通过这种方式将其过滤掉。但这并不能阻止您构建和运行,所以请忽略。

至于您在代码中发现的任何其他问题,请点击代码的 MSDN 杂志文章链接,然后您可以使用它,或者使用它来比较您输入的内容与我提供的内容文章。

干杯

丹尼尔

关于c++ - 功放库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10030359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com