Skip to content

Commit 9458b39

Browse files
authored
Merge pull request JuliaGPU#239 from JuliaGPU/tb/detect_changes
Automatically determine whether to build the support library on CI.
2 parents fc12317 + 6c86407 commit 9458b39

File tree

11 files changed

+71
-5
lines changed

11 files changed

+71
-5
lines changed

.buildkite/pipeline.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
steps:
22
# Julia versions
33

4-
- label: "Julia 1.8 (development)"
4+
- label: "Julia 1.8"
55
plugins:
66
- JuliaCI/julia#v1:
77
version: 1.8
@@ -13,8 +13,7 @@ steps:
1313
- lib
1414
- examples
1515
command: |
16-
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
17-
julia --project=deps deps/build_local.jl
16+
julia --project=deps deps/build_ci.jl
1817
agents:
1918
queue: "juliagpu"
2019
intel: "*"
@@ -35,6 +34,8 @@ steps:
3534
- src
3635
- lib
3736
- examples
37+
command: |
38+
julia --project=deps deps/build_ci.jl
3839
agents:
3940
queue: "juliagpu"
4041
intel: "*"
@@ -52,6 +53,8 @@ steps:
5253
- src
5354
- lib
5455
- examples
56+
command: |
57+
julia --project=deps deps/build_ci.jl
5558
agents:
5659
queue: "juliagpu"
5760
intel: "*"
@@ -73,6 +76,8 @@ steps:
7376
- src
7477
- lib
7578
- examples
79+
command: |
80+
julia --project=deps deps/build_ci.jl
7681
env:
7782
ZE_ENABLE_VALIDATION_LAYER: '1'
7883
ZE_ENABLE_PARAMETER_VALIDATION: '1'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LocalPreferences.toml

deps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

77
project(oneAPISupport)
88

9-
add_library(oneapi_support SHARED sycl.h sycl.hpp sycl.cpp onemkl.cpp)
9+
add_library(oneapi_support SHARED src/sycl.h src/sycl.hpp src/sycl.cpp src/onemkl.cpp)
1010

1111
target_link_libraries(oneapi_support
1212
mkl_sycl

deps/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[deps]
22
CMake_jll = "3f4e10e2-61f2-5801-8945-23b9d642d0e6"
33
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
4+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
5+
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
46
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
57
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
68
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

deps/build_ci.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Pkg
2+
Pkg.activate(@__DIR__)
3+
Pkg.instantiate()
4+
5+
using Git, Scratch, Dates
6+
7+
oneAPI = Base.UUID("8f75cd03-7ff8-4ecb-9b8f-daf728133b1b")
8+
9+
# get scratch directories
10+
support_dir = get_scratch!(oneAPI, "support")
11+
12+
# is this a full-fledged check-out?
13+
if isdir(joinpath(@__DIR__), "..", ".git")
14+
# determine latest change to the wrappers
15+
deps_timestamp = parse(Int, read(`$(git()) -C $(@__DIR__) log -1 --format=%ct src`, String))
16+
@info "Latest change to the wrappers: $(unix2datetime(deps_timestamp))"
17+
18+
# find out which version of oneAPI_Support_jll we are using
19+
Pkg.activate(joinpath(@__DIR__, ".."))
20+
deps = collect(values(Pkg.dependencies()))
21+
filter!(deps) do dep
22+
dep.name == "oneAPI_Support_jll"
23+
end
24+
library_version = only(deps).version
25+
@info "oneAPI_Support_jll version: $(library_version)"
26+
27+
# compare to the JLL's tags
28+
jll_tags = mktempdir() do dir
29+
if !isdir(joinpath(support_dir, ".git"))
30+
run(`$(git()) clone -q https://github.com/JuliaBinaryWrappers/oneAPI_Support_jll.jl $dir`)
31+
else
32+
run(`$(git()) -C $dir fetch -q`)
33+
end
34+
tags = Dict{String,Int}()
35+
for line in eachline(`$(git()) -C $dir tag --format "%(refname:short) %(creatordate:unix)"`)
36+
tag, timestamp = split(line)
37+
tags[tag] = parse(Int, timestamp)
38+
end
39+
tags
40+
end
41+
jll_timestamp = jll_tags["oneAPI_Support-v$(library_version)"]
42+
@info "oneAPI_Support_jll timestamp: $(unix2datetime(jll_timestamp))"
43+
44+
if deps_timestamp > jll_timestamp
45+
@info "Wrappers have changed since the last JLL build. Building the support library locally."
46+
include(joinpath(@__DIR__, "build_local.jl"))
47+
else
48+
@info "Wrappers have not changed since the last JLL build. Using the JLL's support library."
49+
end
50+
else
51+
@warn """oneAPI.jl source code is not checked-out from Git.
52+
This means we cannot check for changes, and need to unconditionally build the support library."""
53+
include(joinpath(@__DIR__, "build_local.jl"))
54+
end

deps/build_local.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# build liboneapi_support with C wrappers for C++ APIs
22

3-
using Pkg, Scratch, Preferences, CMake_jll, oneAPI_Level_Zero_Headers_jll
3+
using Pkg
4+
Pkg.activate(@__DIR__)
5+
Pkg.instantiate()
6+
7+
using Scratch, Preferences, CMake_jll, oneAPI_Level_Zero_Headers_jll
48

59
oneAPI = Base.UUID("8f75cd03-7ff8-4ecb-9b8f-daf728133b1b")
610

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)