I am tryint to integrate CUDA in an existing project, in which several libs (DLLs) are created. I started with a very simple kernel that computes a dot product :
// dotProd_kernel.cu
__global__ void dotProd( double* result, double* vec1, double* vec2)
{
int i = threadIdx.x;
result[i] = vec1[i] * vec2[i];
}
This kernel is called by a host script :
// doProd.cu
#include <cutil_inline.h>
#include <dotProd_kernel.cu>
extern "C" double CUDA_dot(THTensor *vec1, THTensor *vec2);
double CUDA_dot(THTensor *vec1, THTensor *vec2)
{
// [content skipped]
// execute the kernel
dotProd<<< 1, nbThreads >>>(device_vec1, device_vec2, device_result_array);
// [content skipped]
return sum;
}
I generate build files using cmake, and use Visual Studio 2008 Pro to compile it. If I simply use a .cu file with a foobar function that calls no kernel, it executes fine. But with the above code, I get the following error :
c:\cuda\include\math_functions.h(3459) : error C2491: 'log1p' : definition of dllimport function not allowed
The resulting code that calls the CUDA code is exported as a DLL. Is this the problem ?
Actually, the CUDA library defines the log1p function, and so was an obscure part of the code I’m trying to add CUDA to. Thus, there was some kind of conflict between the two. I simply renamed the function in my code, and it worked !