开发者

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:

#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. All the NPP dependencies (.h and lib) seem to be added without problems. Furthermore, Npp8u* and nppiMalloc_8u_C1 are recognized just fine. 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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜