So what exactly is the difference between __device__ and __global__ again? I'm a little confused.
This comment was marked helpful 1 times.
Yuyang
So basically functions marked with __global__ are called by host (CPU) and executed on GPU, whereas __device__ are functions that are called by device (GPU) and also executed on GPU.
This comment was marked helpful 5 times.
jhhardin
To add to that, I think of global functions as "global" in that they span across the host and device (host calls functions to be executed on the device, as @yuyang mentions), and device functions as "device" in that they only involve the device (a device might call a device function as a subroutine or helper function).
__global__
denotes a function that can only be called from host (run by CPU) and must return void.__device__
denotes a function that can only be called from device (run by GPU) and can return anything.(From Slide 24 of CUDA Programming Model Overview, NVIDIA Corporation 2008)
This comment was marked helpful 2 times.
So what exactly is the difference between
__device__
and__global__
again? I'm a little confused.This comment was marked helpful 1 times.
So basically functions marked with
__global__
are called by host (CPU) and executed on GPU, whereas__device__
are functions that are called by device (GPU) and also executed on GPU.This comment was marked helpful 5 times.
To add to that, I think of global functions as "global" in that they span across the host and device (host calls functions to be executed on the device, as @yuyang mentions), and device functions as "device" in that they only involve the device (a device might call a device function as a subroutine or helper function).
This comment was marked helpful 0 times.