ComputationalResources.jl icon indicating copy to clipboard operation
ComputationalResources.jl copied to clipboard

Add resource for CUDAnative?

Open Evizero opened this issue 8 years ago • 8 comments

One discussion that might be worth having is to differentiate between

  1. supporting CUDAnative, which requires the user to have a self-compiled julia version, or
  2. supporting the executing of *.ptx files using CUDAdrv.

maybe CUDADev vs CUDALibs. ? Whats interesting about CUDAnative is that one can emit and store the produced ptx output, like the following example shows (taken verbatim from https://github.com/JuliaGPU/CUDAnative.jl/blob/master/examples/reduce/benchmark.jl#L16-L22)

# PTX generation
open(joinpath(@__DIR__, "reduce.jl.ptx"), "w") do f
    code_ptx(f, reduce_grid,
                        Tuple{typeof(+), CuDeviceArray{Int32,1},
                              CuDeviceArray{Int32,1}, Int32};
                        cap=v"6.1.0")
end

This means that if one is clever about it, it is possible to ship with pre-compiled ptx kernels to reduce user requirements, while as developers still write everything using CUDAnative

Naturally this is only part of the puzzle, but we gotta start the discussion somewhere :)

Evizero avatar Jun 23 '17 14:06 Evizero

I'd be a supporter of such kinds of differentiation. As you surely know, "resources" are pretty thin wrappers, so adding a bazillion of them doesn't seem like a problem, especially when there's a genuine need like in this case.

timholy avatar Jul 13 '17 12:07 timholy

One pitfall that came to mind is if there should be some kind of "superset" logic in such a case. For example if someone declares addresource(CUDADev), does (s)he still have to declare addresource(CUDAlib)?

Evizero avatar Jul 13 '17 12:07 Evizero

Would the algorithm be shared in any sense? Or would they be executing completely different code?

timholy avatar Jul 13 '17 12:07 timholy

In my understanding this was more about declaring capabilities. I didn't really consider shared dispatch. For that purpose ::Union{CUDADev,CUDALib} seems easy enough (?) I am lacking data on this. I'll play around with the idea

Evizero avatar Jul 13 '17 12:07 Evizero

Well, the main issue is that the algorithm dispatches on the resource,

myalg(::CPU1, args...) = 1
myalg(::CPUThreads, args...) = 2
...

timholy avatar Jul 13 '17 12:07 timholy

@Evizero I'm interested in this feature as well. Have you got around it eventually?

navidcy avatar Jul 29 '18 00:07 navidcy

not so far, no

Evizero avatar Jul 29 '18 06:07 Evizero

@navidcy, it's only a couple of lines of code to add a new resource, so if you are ready to use such a feature I'd recommend just submitting a PR.

AFAICT CUDAnative no longer requires a source-build of Julia, so life just keeps getting better :smile:.

timholy avatar Aug 25 '18 13:08 timholy