Skip to content

Commit

Permalink
Start playing with building the libpoplar wrapper in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Mar 14, 2024
1 parent ff6ce90 commit 54ea931
Show file tree
Hide file tree
Showing 8 changed files with 760 additions and 628 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_libpoplar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build libpoplar wrapper

on:
push:
branches: "main"
tags: ["*"]
pull_request:
release:

jobs:
build-libpoplar:
runs-on: ubuntu-latest
container:
image: ${{ matrix.docker_image }}
options: --privileged
strategy:
fail-fast: false
matrix:
include:
- docker_image: graphcore/poplar:3.2.0-ubuntu-20.04-20230314
steps:
- name: "Install, g++, jq"
# g++ is needed to build the wrapper, jq for
# the `julia-actions/cache` workflow
run: |
apt-get update -y
apt-get install -y g++ jq
env:
DEBIAN_FRONTEND: noninteractive
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: "1.7"
- uses: julia-actions/cache@v1
- name: Instantiate wrapper generation environment
working-directory: ${{ github.workspace }}/deps
run: julia --project=. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
- name: Generate source code of libpoplar wrapper
working-directory: ${{ github.workspace }}/deps
shell: julia --project=. --color=yes {0}
run: |
include(joinpath(pwd(), "generate_wrapper.jl"))
generate_wrapper()
env:
CXX: g++
- name: Instantiate build environment
working-directory: ${{ github.workspace }}/deps/bb_recipe
run: julia --project=. --color=yes -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
- name: Generate source code of libpoplar wrapper
working-directory: ${{ github.workspace }}/deps/bb_recipe
run: julia --project=. --color=yes build_tarballs.jl --verbose
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Tests and docs

on:
push:
branches: "main"
tags: ["*"]
pull_request:
release:
# push:
# branches: "main"
# tags: ["*"]
# pull_request:
# release:

# Note: ideally we'd have one job for running the tests and another for building
# documentation, but running CI of this package is a bit expensive, the easiest
Expand Down
16 changes: 16 additions & 0 deletions deps/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[deps]
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
libcxxwrap_julia_jll = "3eaa8342-bff7-56a5-9981-c04077f7cee7"

[compat]
Clang = "0.14, 0.17.4"
JSON = "0.21.4"
Pkg = "1"
Scratch = "1.1"
UUIDs = "1"
libcxxwrap_julia_jll = "0.11"
julia = "1.7"
3 changes: 3 additions & 0 deletions deps/bb_recipe/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
BinaryBuilder = "12aac903-9f7c-5d81-afc2-d9565ea332ae"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
48 changes: 48 additions & 0 deletions deps/bb_recipe/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using BinaryBuilder
using Pkg

name = "libpoplar_wrapper"
version = v"1.0"

sources = [
# The generated wrappers
DirectorySource("../wrapper"),
# Poplar SDK is installed in `/opt/poplar`
DirectorySource(dirname(get(ENV, "POPLAR_SDK_ENABLED", "/opt/poplar"))),
]

script = raw"""
cd ${WORKSPACE}/srcdir/
mkdir -p "${libdir}"
c++ \
-O0 \
-std=c++17 \
-fPIC \
-shared \
-Ipoplar/include
-I${includedir} \
-I. \
-o "${libdir}/libpoplar_julia.${dlext}" \
-Lpoplar/lib
-lpopops \
-lpoplar
install_license /usr/share/licenses/MIT
"""

platforms = [
Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11"),
]

products = LibraryProduct[
]

dependencies = [
BuildDependency(PackageSpec(;name="libjulia_jll", version=v"1.10.9")),
Dependency("libcxxwrap_julia_jll"; compat = "~0.11.2"),
]

build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.9", preferred_gcc_version=v"10")
Loading

0 comments on commit 54ea931

Please sign in to comment.