Do Cycles nodes run on CPU or GPU?
Cycles implements the shaders for both CPU and GPU through the shader virtual machine which can be found in /intern/cycles/kernel/svm. The same nodes are also separately implemented in the Open Shading Language (OSL) and can be found in /intern/cycles/kernel/shaders. For instance you will see that the brick texture node exists both as svm_brick.h and node_brick_texture.osl. OSL only runs on the CPU and integrating a OSO to SVM compiler was previously discussed but abandoned due to maintenance and performance concerns. Therefore your own OSL scripts have the same limitation and will only be executed on the CPU.

Note that using OSL is entirely optional and it's not enabled by default. OSL can be enabled in the Render Properties.



Additional information about Cycles can be found in the wiki. The articles may not always be fully polished, but they should be a good starting point to dig deeper into the code. The structure of Cycles source code is documented in the Source Code Layout page.