关于AMP的array_view索引问题

WNs_ACE 2019-03-17 10:38:01
今天我测试c++的AMP,在微软官网看到的例子,然后拷贝到程序中直接运行,发现程序在编译的时候出现类模板出错,我在网上看了很多资料大家都是这样写的,为啥就我有问题呢?

#include <iostream>
#include <amp.h>
#include <amp_math.h>

using namespace std;
using namespace concurrency;
using namespace concurrency::details;
using namespace concurrency::fast_math;

void test01()
{
int aCPP[] = { 1, 2, 3,
4, 5, 6 };
//新建2维(两行三列)array_view包装器
array_view<int, 2> a(2, 3, aCPP);
index<2> idx(1, 2);

//输出6
std::cout << a(1,2) << "\n";
}

int main()
{
test01();
}





1>AMP.cpp
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\amp.h(2616): error C3861: “_Access”: 找不到标识符
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\amp.h(2616): note: “_Access”: 函数未在模板定义上下文中声明,只能通过实例化上下文中参数相关的查找找到
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\amp.h(2618): note: 编译 类 模板 成员函数 "_Value_type &Concurrency::array_view<_Value_type,2>::operator ()(const Concurrency::index<2> &) const" 时
1> with
1> [
1> _Value_type=int
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\amp.h(2650): note: 参见对正在编译的函数 模板 实例化“_Value_type &Concurrency::array_view<_Value_type,2>::operator ()(const Concurrency::index<2> &) const”的引用
1> with
1> [
1> _Value_type=int
1> ]
1>d:\testproject\c++\并行与异步\amp\amp.cpp(23): note: 参见对正在编译的 类 模板 实例化 "Concurrency::array_view<int,2>" 的引用
...全文
237 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
WNs_ACE 2019-03-17
  • 打赏
  • 举报
回复
补充一下,我是使用vs2017来编译的
WNs_ACE 2019-03-17
  • 打赏
  • 举报
回复
木有人知道么?别沉

24,855

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧