What Does __Global__ Mean in the Context of a Function Declaration in C?

I'm reading a C program where a function is declared like so:

__global__ void square(float *d_out, float *d_in);

what does the __global__ specifier mean?

5

1 Answer

It is not standard C, only some extension or #define.

It looks like CUDA.

__global__ function is executed on GPU, it can be called from CPU or the GPU.

Calling __global__ functions is often more expensive than __device__.

If it is a #define, compile the file with the -E (gcc) or similar option and see how this macro is expanded.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest