Sending programs from CPU to GPU How does a CPU know which piece of code should be executed on GPU (i.e how to recognize whether a code is shader or not) and how is it been sent to GPU VRAM?Is it via DMA?
Most, if not all, approaches to GPU programming require the developer to manually identify code that will be executed on the GPU. The code for the GPU is compiled separately from CPU code, so it is clear which binary code is for which processor type. Moving the GPU code to VRAM is often done with DMA, but may be moved to GPU accessible memory using other techniques such as CPU writes across PCIe, or direct CPU memory access by the GPU.

The GPU compiler often resides in userspace, and a system call will hand binary GPU code to the kernel, which can then make the code available to the GPU.