- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 MSVS2012、CUDA5.5、Thrust 1.7 编译此代码:
#include <iostream>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/find.h>
#include <thrust/execution_policy.h>
struct is_odd {
__host__ __device__ bool operator()(uint64_t &x) {
return x & 1;
}
};
int main() {
thrust::counting_iterator<uint64_t> first(0);
thrust::counting_iterator<uint64_t> last = first + 100;
auto iter = thrust::find(thrust::device,
thrust::make_transform_iterator(first, is_odd()),
thrust::make_transform_iterator(last, is_odd()),
true);
int bbb; std::cin >> bbb;
return 0;
}
并得到一个错误:
Error 1 error : incomplete type is not allowed C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include\thrust\detail\type_traits.h 413 1 HostDevice
如果我使用主机/设备向量而不是计数迭代器那么一切都可以。怎么了?
最佳答案
我稍微改变了你的仿函数定义,从此:
struct is_odd {
__host__ __device__ bool operator()(uint64_t &x) {
对此:
struct is_odd : public thrust::unary_function<uint64_t, bool> {
__host__ __device__ bool operator()(const uint64_t &x) {
它为我编译了。
关于cuda - 如何在 Thrust 中将 make_transform_iterator() 与counting_iterator<> 和execution_policy 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21280239/
处理 const vector 时,以下内容不起作用: const std::vector v; v.push_back("test"); // error: v cannot be modified
代码如下: thrust::reduce(thrust::make_transform_iterator(v.begin(), square()), thrust:
C++ 和 CUDA 的新手。使用 MSVS 2015 社区和 CUDA 9.2。 我尝试制作一个仅取消引用 device_ptr 的 transform_iterator。 我收到编译错误:无法使用
我正在尝试使用 boost::make_transform_iterator 为自定义类创建迭代器,该自定义类的数据保存在映射中,迭代器使用键 vector 来访问值。 在我的问题中, map 的值是
我尝试使用 MSVS2012、CUDA5.5、Thrust 1.7 编译此代码: #include #include #include #include #include struct is
我是一名优秀的程序员,十分优秀!