Visual Studio 2010 + CUDA 4:尝试使用NPP分配内存时出现无法识别的令牌错误
Visual Studio 2010 + CUDA 4: Unrecognized token error when attempting to allocate memory using NPP
我有以下相同名称的类的源文件(CUDA_Integral_Image.cu):
#include "cuda_runtime.h"
#include "npp.h"
#include "CUDA_Integral_Image.h"
#include <stdlib.h>
#include <time.h>
...
// allocated device source image
int step = width;
Npp8u* pSI = nppiMalloc_8u_C1(width, height, &step);
// copy test image up to device
cudaMemcpy2D(pSI, width, pHI, width, width, height, cudaMemcpyHostToDevice);
// allocate device result images
Npp32s* pDi = nppiMalloc_32s_C1(width,height,width*sizeof(int)); // LINE 30
尝试编译这段代码会导致:
.../CUDA_Integral_Image.cu(30): error : unrecognized token
1>
.../CUDA_Integral_Image.cu(30): error : expected an identifier
1>
.../CUDA_Integral_Image.cu(30): error : unrecognized token
1>
.../CUDA_Integral_Image.cu(30): error : expected an expression
CUDA_Integral_Image.h中没有其他头文件。所有NPP依赖项(.h和lib)的添加似乎都没有问题。此外,可以很好地识别Npp8u*和nppiMalloc_8u_C1。我完全不知道是什么原因导致这个错误。
. .如果我将代码改为:
Npp32s* pDi; // LINE 30
pDi = nppiMalloc_32s_C1(width,height,width*sizeof(int));
我得到错误:
.../CUDA_Integral_Image.cu(30): error : unrecognized token
1>
.../CUDA_Integral_Image.cu(30): error : expected an identifier
1>
.../CUDA_Integral_Image.cu(31): error : identifier "pDi" is undefined
1>
.../CUDA_Integral_Image.cu(31): error : unrecognized token
1>
.../CUDA_Integral_Image.cu(31): error : expected an expression
不知道是什么原因导致的,感谢任何建议!
nppiMalloc_32s_C1的最后一个参数不正确。它应该始终是指向整型变量的指针。例程在内部计算分配的正确大小(包括对齐),并将大小返回给调用者。
相关文章:
- 内存错误低于在C++年实现埃拉托色尼筛分时的预期
- 将 vector<vector<int>> 传递到函数中会产生内存错误
- 为什么删除分配的阵列会导致内存错误?
- 自定义哈希表实现-将字符串映射到整数时出现内存错误
- 需要找到3个小错误-内存错误
- 从'deleted function'获取内存错误
- OpenGL, GLFW, GLAD. glViewport(0, 0, 800, 600) 抛出内存错误
- 销毁 std::queue 会导致内存错误
- 加速进程间:管理共享内存错误
- 删除映射中的指针会导致内存错误
- 由于从 std::map 派生的类中的 std::map 迭代器导致的内存错误
- 当我用clang编译代码时,GCOV会出现内存错误
- 查找素数和时出现内存错误
- 循环链表的内存错误:未分配正在释放的指针
- 为什么我会因Valgrind遇到内存错误?(C ,抽象语法树评估)
- 我如何解析包含65k行的代码的文件,导致[BCC32致命错误] F1008出于内存错误
- 动态内存错误
- 内存错误C 私有INT
- 无法在 Mac OS X 上分配内存错误 - java(xx,xx) malloc: *** mmap(size=XX)
- 类对象的可变级别内存错误检测