简体   繁体   English

Visual Studio 2010 + CUDA 4:尝试使用NPP分配内存时出现无法识别的令牌错误

[英]Visual Studio 2010 + CUDA 4: Unrecognized token error when attempting to allocate memory using NPP

I have the following source file (CUDA_Integral_Image.cu) for a class of the same name: 对于同名的类,我具有以下源文件(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

Attempting to compile this code results in: 尝试编译此代码会导致:

.../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

There are no other header files included in CUDA_Integral_Image.h. CUDA_Integral_Image.h中不包含其他头文件。 All the NPP dependencies (.h and lib) seem to be added without problems. 所有的NPP依赖项(.h和lib)似乎都没有问题。 Furthermore, Npp8u* and nppiMalloc_8u_C1 are recognized just fine. 此外,可以很好地识别出Npp8u *和nppiMalloc_8u_C1。 I have absolutely no idea what could be causing this error. 我完全不知道是什么原因导致此错误。

..if I change the code to: ..如果我将代码更改为:

Npp32s* pDi; // LINE 30
pDi = nppiMalloc_32s_C1(width,height,width*sizeof(int));

I get the errors: 我得到了错误:

.../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

No idea what could be causing this, would appreciate any suggestions! 不知道是什么原因造成的,不胜感激任何建议!

The last argument to nppiMalloc_32s_C1 is incorrect. nppiMalloc_32s_C1的最后一个参数不正确。 It should always be a pointer to an integer variable. 它应该始终是指向整数变量的指针。 The routine internally calculates the correct size for the allocation (include alignment) and returns the size to the caller. 例程在内部计算分配的正确大小(包括对齐),并将大小返回给调用方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM