Skip to content

Commit 9c5eae9

Browse files
committed
Initial commit.
0 parents  commit 9c5eae9

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2018 Tim Besard, and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
NCCL.jl
2+
=======
3+
4+
*A Julia wrapper for the NVIDIA Collective Communications Library.*
5+
6+
7+
Status
8+
------
9+
10+
This package is very incomplete, and completely untested.

REQUIRE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CUDAapi 0.4.0

deps/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ext.jl
2+
ext.jl.bak

deps/build.jl

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using CUDAapi
2+
3+
const config_path = joinpath(@__DIR__, "ext.jl")
4+
const previous_config_path = config_path * ".bak"
5+
6+
function write_ext(config, path)
7+
open(path, "w") do io
8+
println(io, "# autogenerated file, do not edit")
9+
for (key,val) in config
10+
println(io, "const $key = $(repr(val))")
11+
end
12+
end
13+
end
14+
15+
function read_ext(path)
16+
config = Dict{Symbol,Any}()
17+
r = r"^const (\w+) = (.+)$"
18+
open(path, "r") do io
19+
for line in eachline(io)
20+
m = match(r, line)
21+
if m != nothing
22+
config[Symbol(m.captures[1])] = eval(Meta.parse(m.captures[2]))
23+
end
24+
end
25+
end
26+
return config
27+
end
28+
29+
function main()
30+
ispath(config_path) && mv(config_path, previous_config_path; force=true)
31+
config = Dict{Symbol,Any}(:configured => false)
32+
write_ext(config, config_path)
33+
34+
35+
## discover stuff
36+
37+
toolkit_dirs = CUDAapi.find_toolkit()
38+
39+
config[:libnccl] = CUDAapi.find_cuda_library("nccl", toolkit_dirs)
40+
if config[:libnccl] == nothing
41+
error("could not find NCCL")
42+
end
43+
44+
config[:configured] = true
45+
46+
47+
## (re)generate ext.jl
48+
49+
if isfile(previous_config_path)
50+
@debug("Checking validity of existing ext.jl...")
51+
previous_config = read_ext(previous_config_path)
52+
53+
if config == previous_config
54+
@info "NCCL.jl has already been built for this toolchain, no need to rebuild"
55+
mv(previous_config_path, config_path; force=true)
56+
return
57+
end
58+
end
59+
60+
write_ext(config, config_path)
61+
62+
return
63+
end
64+
65+
main()

src/NCCL.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module NCCL
2+
3+
const ext = joinpath(dirname(@__DIR__), "deps", "ext.jl")
4+
isfile(ext) || error("NCCL.jl has not been built, please run Pkg.build(\"NCCL\").")
5+
include(ext)
6+
if !configured
7+
# default (non-functional) values for critical variables,
8+
# making it possible to _load_ the package at all times.
9+
const libnccl = nothing
10+
end
11+
12+
13+
end

0 commit comments

Comments
 (0)