How can I use global invocation of device functions in CMake when they are distributed across different files?

hello,i want to use the Dynamic parallelism in my files,while i have a global function and i want to use the device function in the file,




and i add the cudadevrt in the CmakeLists

how can i solve it?

Please do not post pictures of code on this forum.

1 Like

hi,Robert,
thank you for advice,
now i have an easy model,i got main.cu like this

include <stdio.h>
include “cuda_runtime.h”
include “device_launch_parameters.h”
include “hel/hel.cuh”

global void hello_world(void)
{
spherical_harmonics_d();
}
int main(){
printf(“CPU: Hello world!\n”);
hello_world <<<2, 200>>>();
// cudaDeviceReset must be called before exiting in order for profiling and
// tracing tools such as Nsight and Visual Profiler to show complete traces.
cudaDeviceReset();
return 0;
}

and i have a hello.cu like this

include “hel.cuh”
include “stdio.h”
device void spherical_harmonics_d()
{
printf(“hello”);
}

and the hello.cuh like this
#ifndef HEL_CUH

define HEL_CUH

device void spherical_harmonics_d();

endif

but i got the problem like below ,please tell me how to fix it

you will need to specify relocatable device code with device linking. I know how to do this for nvcc but not Cmake. Cmake is not a NVIDIA product. I think you can probably find how to do it with google.