Browse Source

julia: Fix execution on systems without CUDA.

Pierre Huchant 5 years ago
parent
commit
55295b97c9

+ 1 - 1
julia/src/compiler/file_generation.jl

@@ -128,7 +128,7 @@ macro codelet(x)
         CPU_CODELETS[name]=cpu_name
     end
 
-    if starpu_target & STARPU_CUDA!=0
+    if (starpu_target & STARPU_CUDA!=0) && STARPU_USE_CUDA == 1
         kernel_file = open(generated_cuda_kernel_file_name, "w")
         debug_print("generating ", generated_cuda_kernel_file_name)
         print(kernel_file, cuda_kernel_file_start)

+ 7 - 0
julia/src/globals.jl

@@ -41,3 +41,10 @@ global starpu_type_traduction_dict = Dict(
 export starpu_type_traduction_dict
 
 global mutex = Threads.SpinLock()
+
+# detect CUDA support
+try
+    STARPU_USE_CUDA == 1
+catch
+   global  const STARPU_USE_CUDA = 0
+end

+ 4 - 2
julia/src/init.jl

@@ -26,9 +26,11 @@ function starpu_init()
         debug_print("Loading external codelet library")
         ff = Libdl.dlsym(starpu_tasks_library_handle,:starpu_find_function)
         dump(ff)
-        for k in keys(CUDA_CODELETS)
+        for k in keys(CPU_CODELETS)
             CPU_CODELETS[k]=unsafe_string(ccall(ff,Cstring, (Cstring,Cstring),Cstring_from_String(string(k)),Cstring_from_String("cpu")))
-            CUDA_CODELETS[k]=unsafe_string(ccall(ff,Cstring, (Cstring,Cstring),Cstring_from_String(string(k)),Cstring_from_String("gpu")))
+            if STARPU_USE_CUDA == 1
+                CUDA_CODELETS[k]=unsafe_string(ccall(ff,Cstring, (Cstring,Cstring),Cstring_from_String(string(k)),Cstring_from_String("gpu")))
+            end
             print(k,">>>>",CPU_CODELETS[k],"\n")
         end
     else

+ 2 - 1
julia/src/translate_headers.jl

@@ -90,7 +90,8 @@ function starpu_translate_headers()
                                "STARPU_CUDA_ASYNC",
                                "STARPU_OPENCL",
                                "STARPU_MAIN_RAM",
-                               "STARPU_NMAXBUFS"])
+                               "STARPU_NMAXBUFS",
+                               "STARPU_USE_CUDA"])
 
     wc = init(; headers = STARPU_HEADERS,
               output_file = joinpath(@__DIR__, "../gen/libstarpu_api.jl"),