c++ - Visual Studio 2010 + CUDA 4 : Unrecognized token error when attempting to allocate memory using NPP

标签 c++ visual-studio-2010 visual-c++ cuda

我有以下同名类的源文件 (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++ - Visual Studio 2010 + CUDA 4 : Unrecognized token error when attempting to allocate memory using NPP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5713058/

相关文章:

c++ - 在 QTCreator 中链接到 user32.lib

android - 如何在 Android 平台工具中构建 dexdump?

.net - 如何引用 System.Web 命名空间?

asp.net - 如何在 asp.net 中设置背景图片

c++ - 在 .h 文件包含在多个 cpp 文件中的类中定义 integral static const

c++ - For循环——魔数(Magic Number)程序

c++ - 为什么这段代码会无限循环

c++ - 用于三角形的 OpenGL 3.3 glDrawArrays

.net - 有没有一种简单的方法可以在 VS 2010 中签署 C++ CLI 程序集?

sql-server - [ODBC SQL Server 驱动程序][DBMSLPCN]SSL 安全错误