How to link CUDA library with Cilk++

左心房为你撑大大i 提交于 2019-12-11 09:32:51

问题


I am trying to develop some Hybrid program using Intel's Cilk++ and Nvidia's CUDA. I created a Shared library from Cuda code(libtest.so). And I want to link it with Cilk++ program, so that I can offload some work to GPU. But when I compile cilk++ program I am not able to link it with this cuda library and I get error as follows:

nvcc -arch=compute_20 -L. -code=sm_20 -L. -o libtest.so --shared -Xcompiler -fPIC test.cu;

cilk++ -o main -L. -ltest main.cilk;

/tmp/ccwDvzCG.o: In function `int cilk_main(int, char**)':
main.cilk:(.text+0x26): undefined reference to `void entry()'
collect2: ld returned 1 exit status

File: test.cu

#include <stdio.h>

__global__ void myk(void){
    printf("Hello from thread %d block %d\n", threadIdx.x, blockIdx.x);
}

extern "C++"
void entry(void){
    myk<<<1,1>>>();
    printf("CUDA status: %d\n", cudaDeviceSynchronize());
}

File: main.cilk

#include <cilk.h>

void entry(void);

int cilk_main(void){
    entry();
}

Previously I have linked Cilk library with CUDA code, But now I want the other way round. Is it possible to link CUDA with Cilk? If So, what am I missing?


回答1:


The extern clause should be in C++ code and not in the CUDA code because here you have definition of function in CUDA file but you call it in C++ code.



来源:https://stackoverflow.com/questions/23439766/how-to-link-cuda-library-with-cilk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!