Hi,I hava three file:sum.h sum.cu main.cu
I want to complile sum.cu into libsum.so library,call it in main function
//
/sum.cu/
// device int sum(int a,int b)
{
return a + b;
}
//
/sum.h/
//
extern “C”{
extern device int sum(int,int);
}
//
/main.cu/
// #include <stdio.h> #include “sum.h” global void kernel(int a,int b,int *result)
{
*result = sum(a,b);
}
int main()
{
int *d_result,h_result;
1ã€nvcc -compile sum.cu(generate sum.o)
2ã€nvcc -shared -o libmysum.so sum.o (genertate libmysum.so)
3ã€when I do This :nvcc -o main main.cu
the error is:./main.cu(6): Error: External calls are not supported (found non-inlined call to sum)
Can anybody help me ?does anyone known how to create .SO dynamically link file?
Since there is currently no linker support for device functions, it is not possible to create a library of device functions. A workaround is to place the device functions in header files, which is how the CUDA math “library” is set up. Libraries of host functions that call kernels on the device are possible however, as demonstrated by CUBLAS and CUFFT.