This project is read-only.

Cudafy.CudafyCompileException: No Cuda source code present in Cudafy module for OpenCL12

Jun 3, 2014 at 6:13 AM
I'm a user of Cudafy for my nvidia card successfully for a while now.
Today I bought an AMD card, so I'm trying to run Cudafy on both.

For the AMD device, I'm getting the error "Cudafy.CudafyCompileException: No Cuda source code present in Cudafy module for OpenCL12" when calling CudafyTranslator.Cudafy.

Any ideas?
Jun 3, 2014 at 8:59 AM
Hi Ben,
Long time no hear. What code were you trying to run?
Jun 4, 2014 at 1:48 AM
Edited Jun 4, 2014 at 3:29 AM
Hi Nick, it has been ages.

Here's what I'm trying:
        static void CudafyIt()
            GPGPU[] gpu = new Cudafy.Host.GPGPU[2];
            for(int i=0;i<2;i++)
                CompileProperties cp = new CompileProperties();
                    gpu[i] = CudafyHost.GetDevice(eGPUType.Cuda,i);
                    CudafyModes.Target = eGPUType.Cuda;
                    cp.Architecture = eArchitecture.sm_30;
                    CudafyTranslator.Language = eLanguage.Cuda;
                    gpu[i] = CudafyHost.GetDevice(eGPUType.OpenCL,i);
                    CudafyModes.Target = eGPUType.OpenCL;
                    cp.Architecture = eArchitecture.OpenCL12;
                    CudafyTranslator.Language = eLanguage.OpenCL;
                CudafyTranslator.WorkingDirectory = FileDirectory;              
                cp.CompilerPath = _CudafyCompilePath;
                cp.WorkingDirectory = Directory.GetCurrentDirectory();
                cp.IncludeDirectoryPath = _CudafyIncludeDirectoryPath;
                cp.Platform = ePlatform.Auto;

                CudafyModule km = CudafyTranslator.Cudafy(cp, typeof(ToCudafyTemp));
                gpu[i].LoadModule(km, true);
    public static class ToCudafyTemp
        public static float Ifb(bool isTrue, float valIfTrue, float valIfFalse)
            if(isTrue) return valIfTrue;
            else return valIfFalse;

_CudafyCompilePath points to nvcc.exe. Is this right? I've tried leaving this out for OpenCL without any luck too.
Jun 4, 2014 at 6:48 AM
Can you run CudafyByExample for CUDA and OpenCL?
Jun 4, 2014 at 7:19 AM
And if I change this:
CudafyModule km = CudafyTranslator.Cudafy(cp, typeof(ToCudafyTemp));
to this:
CudafyModule km = CudafyTranslator.Cudafy(typeof(ToCudafyTemp));
It will translate, but then I can't specify the CompileProperties.

Any ideas why?
Jun 4, 2014 at 10:53 AM
Best check the default values of all the CompileProperties members. You can check the source code to see what the overload without CompileProperties does when initiating CompileProperties.
Jun 5, 2014 at 2:01 AM
adding this for the OpenCL version only solved the problem:
cp.CompileMode = eCudafyCompileMode.TranslateOnly;