Skip to content

Commit 14a1f59

Browse files
committed
Build the libpoplar wrapper in CI
1 parent dca1f4d commit 14a1f59

File tree

5 files changed

+136
-1
lines changed

5 files changed

+136
-1
lines changed

.github/workflows/build_libpoplar.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build libpoplar wrapper
2+
3+
on:
4+
push:
5+
branches: "main"
6+
tags: ["*"]
7+
pull_request:
8+
release:
9+
10+
jobs:
11+
build-libpoplar:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: ${{ matrix.docker_image }}
15+
options: --privileged
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- docker_image: graphcore/poplar:3.2.0-ubuntu-20.04-20230314
21+
steps:
22+
- name: "Install, g++, jq"
23+
# g++ is needed to build the wrapper, jq for
24+
# the `julia-actions/cache` workflow
25+
run: |
26+
apt-get update -y
27+
apt-get install -y g++ jq
28+
env:
29+
DEBIAN_FRONTEND: noninteractive
30+
- uses: actions/checkout@v4
31+
- uses: julia-actions/setup-julia@v1
32+
with:
33+
version: "1.7"
34+
- uses: julia-actions/cache@v1
35+
- name: Instantiate wrapper generation environment
36+
working-directory: ${{ github.workspace }}/deps
37+
run: |
38+
julia --project=. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
39+
- name: Generate source code of libpoplar wrapper
40+
working-directory: ${{ github.workspace }}/deps
41+
shell: julia --project=. --color=yes {0}
42+
run: |
43+
include(joinpath(pwd(), "generate_wrapper.jl"))
44+
generate_wrapper()
45+
env:
46+
CXX: g++
47+
- name: Instantiate build environment
48+
working-directory: ${{ github.workspace }}/deps/bb_recipe
49+
run: |
50+
julia --project=. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
51+
- name: Compile libpoplar wrapper
52+
working-directory: ${{ github.workspace }}/deps/bb_recipe
53+
run: |
54+
julia --project=. --color=yes build_tarballs.jl --verbose
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: products
58+
path: ${{ github.workspace }}/deps/bb_recipe/products

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: "main"
66
tags: ["*"]
7-
pull_request:
7+
# pull_request:
88
release:
99

1010
# Note: ideally we'd have one job for running the tests and another for building

deps/Project.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[deps]
2+
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
3+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
4+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5+
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
6+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
7+
libcxxwrap_julia_jll = "3eaa8342-bff7-56a5-9981-c04077f7cee7"
8+
9+
[compat]
10+
Clang = "0.14, 0.17.4"
11+
JSON = "0.21.4"
12+
Pkg = "1"
13+
Scratch = "1.1"
14+
UUIDs = "1"
15+
libcxxwrap_julia_jll = "0.11"
16+
julia = "1.7"

deps/bb_recipe/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
BinaryBuilder = "12aac903-9f7c-5d81-afc2-d9565ea332ae"
3+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

deps/bb_recipe/build_tarballs.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using BinaryBuilder
2+
using Pkg
3+
4+
name = "libpoplar_wrapper"
5+
version = v"1.0"
6+
7+
# `POPLAR_SDK_ENABLED` should point to where the Poplar SDK is installed,
8+
# otherwise fallback to `/opt/poplar` (default dir in Graphcore Docker
9+
# containers).
10+
poplar_dir = get(ENV, "POPLAR_SDK_ENABLED", "/opt/poplar")
11+
12+
sources = [
13+
# The generated wrappers
14+
DirectorySource("../wrapper"),
15+
DirectorySource(dirname(poplar_dir)),
16+
]
17+
18+
script = "POPLAR_DIR=$(basename(poplar_dir))\n" * raw"""
19+
cd ${WORKSPACE}/srcdir/
20+
21+
mkdir -p "${libdir}"
22+
23+
c++ \
24+
-O0 \
25+
-std=c++17 \
26+
-fPIC \
27+
-shared \
28+
-I${POPLAR_DIR}/include \
29+
-I${includedir} \
30+
-I${includedir}/julia \
31+
-I. \
32+
-o "${libdir}/libpoplar_julia.${dlext}" \
33+
template.cpp \
34+
-L${POPLAR_DIR}/lib \
35+
-L${libdir} \
36+
-lpopops \
37+
-lpoplar \
38+
-lcxxwrap_julia \
39+
-ljulia
40+
41+
install_license /usr/share/licenses/MIT
42+
"""
43+
44+
platforms = [
45+
Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11", julia_version="1.10.0"),
46+
]
47+
48+
products = [
49+
LibraryProduct("libpoplar_julia", :libpoplar_julia; dont_dlopen=true),
50+
]
51+
52+
dependencies = [
53+
BuildDependency(PackageSpec(;name="libjulia_jll", version=v"1.10.9")),
54+
Dependency("libcxxwrap_julia_jll"; compat = "~0.11.2"),
55+
]
56+
57+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
58+
julia_compat="1.9", preferred_gcc_version=v"10", dont_dlopen=true)

0 commit comments

Comments
 (0)