Nvcc does not understand __global__

Attempting to use the nvcc to compile code that must be runnable
on the device ( a Quadro GPU ) and callable from the host machine.

At the very least I expect the function to be a callable line in some
code that executes on the host and then the "kernel" code function
will get running on the Quadro.

This all works perfectly fine if the code is inside a single large file.

When I break it out into little code pieces then we have problems :


titan$ nvcc -gencode arch=compute_35,code=sm_35 -gencode arch=compute_60,code=sm_60 -Wno-deprecated-gpu-targets --ftz=false --prec-div=true --prec-sqrt=true --fmad=true -c -o array_offset.o array_offset.c
In file included from array_offset.c:3:
mand.h:55:11: error: expected ‘;’ before ‘void’
   55 | __global__ void gpu_mbrot( const double *c_r, const double *c_i, uint32_t *mval, int num_elements );
      |           ^~~~~
      |           ;
titan$ 

So there we see that nvcc has no clue what "__global__" decoration means
and yet the documentation claims : 

    https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#global

     7.1.1. __global__

The __global__ execution space specifier declares a function as being a kernel. Such a function is:

    Executed on the device,

    Callable from the host,

    Callable from the device for devices of compute capability 5.0 or higher (see CUDA Dynamic Parallelism for more details).

I do not care about the last feature there. The little function is supposed to execute on the Quadro device. It will not be "callable" ( hello!? ) by the device to any other device. So that is just fine with me.

So there you have it. Near as I can tell the decoration "__global__" does not mean anything to NVCC in my header file.

Please do not format everything as code as it uses horizontal scrollbars. This makes it difficult to read your text.

By default, nvcc delegates to the standard c compiler for .c files. You need to use nvcc -x cu if you want to compile them as cuda files.

oops … okay I will give that a try.

Also I was looking for a trivial way to post as just text but that does not
seem to exist. So I will just hope this is readable as is.

I found this : Error: kernel launch from __device__ or __global__ functions requires separate compilation mode - #2 by Robert_Crovella

That worked out perfectly and now everything works again. All the data looks good and I can get back to making some forward progress. The “nvcc -x cu” was a real relief from my hair pulling and coffee spilling. Works like a charm! Thank you very much.