Writing GPU supported Shaders

I want to convert some procedural textures to OSL (see shaders.co.uk) but also want to support CPU and GPU rendering. I can see that the built-in shaders work for CPU and GPU but I can’t find the CUDA or OPENCL representations in the source code. Does anyone have any insight as to how to create a texture that works for both (even though I may have to write the CUDA/OPENCL implementation)?

Thanks in advance


There’s no specific CUDA/OpenCL version, it’s just C code that works on all backends with some preprocessor magic. The code for SVM (the backend the works on CPU and GPU) is under cycles/kernel/svm (It’s all header files, but they contain the actual code).