But after I am launching the Kernel the process gets finished with exit code 139:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
You are completely right. I thought the segmentation fault appeared when I executed the kernel but indeed it is appearing at the line with nvrtcCreateProgram.
a character string like that is a const char *, simply casting it to const char ** is going to cause trouble. The API is designed to accept an array of strings for each parameter. You need to actually provide a proper pointer to an array of strings. Here’s an example:
I understand that there is potentially more complexity to it and that I have to include other files, which are included in stddef.h as well. But that error message makes no sense to me, since the first line of the file is a comment.
Here are the first three lines of the file:
/*===---- stddef.h - Basic type definitions --------------------------------===
*
* Copyright (c) 2008 Eli Friedman
Thats why I thought that I may have done something wrong.
It’s possible you may have done something wrong. I can’t tell from just a couple lines of code, and no program to look at.
I would start by building a really simple test case, and use a really simple include file test, that doesn’t have any other dependencies, and get that working first. I’d be willing to bet stddef.h includes other include files, and that may be troublesome. But that doesn’t seem to be the issue at hand.
But I still get the error message. This is the complete log of nvrtc:
test_header.h(1): warning: last line of file ends without a newline
test_header.h(1): error: expected a declaration
At end of source: warning: parsing restarts here after previous syntax error
1 error detected in the compilation of “cuda_program”.
When I am leaving out the line with the include everything works just fine.
But I still get the error message. This is the complete log of nvrtc:
test_header.h(1): warning: last line of file ends without a newline
test_header.h(1): error: expected a declaration
At end of source: warning: parsing restarts here after previous syntax error
1 error detected in the compilation of “cuda_program”.
When I am leaving out the line with the include everything works just fine.
The nvrtc mechanism gives 2 methods by which an include file can be incorporated into your program:
By passing the entire contents of the include file to nvrtcCreateProgram
By passing just the path of the include file to nvrtcCompileProgram
The second method is probably easier. The first method is provided in case you cannot be certain that a particular include file will be available or findable at the place you expect in the filesystem, when the program is being compiled at runtime.
The first method is not really outlined anywhere (although it is offered via jitify). An example of the second method is available in the CUDA sample codes, in the file /usr/local/cuda/samples/common/inc/nvrtc_helper.h Study the function compileFileToPTX in that helper file, and note how the cooperative_groups.h header file is passed to the nvrtcCompileProgram function.
If you want to use the first method, don’t pass the path to the file in the header_sources, pass the complete contents of the include file in header_sources. This is the proximal reason for the error you are getting. The compiler is attempting to interpret /home/martin/ as the C/C++ code contents of your header file.