From 26eae45749437546790a42396dea598b42b905ac Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Wed, 4 Dec 2024 22:25:15 +0800 Subject: [PATCH 1/3] ARM image --- .devcontainer/devcontainer.json | 31 ----------------- .github/workflows/elixir.yml | 6 ++-- .github/workflows/release.yml | 62 ++++++++++++++++++++++++++++++++- CONTRIBUTING.md | 4 +++ dev-requirements.txt | 4 +-- docker/livebook.dockerfile | 31 +++++++++++++++++ mix.exs | 6 ++-- mix.lock | 12 +++---- native/Makefile | 2 +- scripts/build-for-publish.sh | 1 + 10 files changed, 112 insertions(+), 47 deletions(-) delete mode 100644 .devcontainer/devcontainer.json create mode 100644 docker/livebook.dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 24b76af03..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/cpp -{ - "name": "C++", - "image": "jackalcooper/llvm15_elixir:latest", - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined" - ], - // Set *default* container specific settings.json values on container create. - "settings": {}, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "llvm-vs-code-extensions.vscode-clangd", - "ms-vscode.cmake-tools", - "JakeBecker.elixir-ls", - "llvm-vs-code-extensions.vscode-mlir", - "tiehuis.zig" - ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "gcc -v", - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "root", - "features": { - "git": "os-provided", - "sshd": "os-provided" - } -} diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index dd20394e7..3f71a0775 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -34,14 +34,14 @@ jobs: strategy: fail-fast: false matrix: - runs-on: ["ubuntu-latest"] + runs-on: ["ubuntu-22.04"] otp: ["24.2", "25.0"] elixir: ["1.13.0", "1.16.2", "1.17.2"] exclude: - otp: "24.2" elixir: "1.17.2" include: - - runs-on: "ubuntu-latest" + - runs-on: "ubuntu-22.04" otp: "27.0.1" elixir: "1.17.2" steps: @@ -67,7 +67,7 @@ jobs: otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} - name: Set up Zig - uses: goto-bus-stop/setup-zig@v2 + uses: mlugg/setup-zig@v1 with: version: 0.13.0 - uses: Jimver/cuda-toolkit@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fab02d80..a7d420ec4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - release* tags: - "*" pull_request: @@ -65,7 +66,7 @@ jobs: otp-version: ${{ matrix.job.otp }} # Define the OTP version [required] - run: elixir --eval ":erlang.system_info(:nif_version) |> IO.puts" - name: Set up Zig - uses: goto-bus-stop/setup-zig@v2 + uses: mlugg/setup-zig@v1 with: version: 0.13.0 - uses: Jimver/cuda-toolkit@master @@ -131,3 +132,62 @@ jobs: BEAVER_ARTEFACT_URL: "https://github.com/beaver-lodge/beaver-prebuilt/releases/download/${{ needs.generate_id.outputs.formatted_date }}/@{artefact_filename}" run: | mix run bench/enif_add_benchmark.exs + + arm_docker: + needs: [generate_id] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: + - { + platform: "linux/arm64/v8", + suffix: "arm64", + zig: "https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz" + } + - { + platform: "linux/amd64", + suffix: "amd64", + zig: "https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz" + } + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + if: ${{ matrix.image.platform != 'linux/amd64' }} + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ secrets.DOCKERHUB_USERNAME != '' }} + tags: jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest + cache-from: type=registry,ref=jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest + cache-to: type=inline + platforms: | + ${{ matrix.image.platform }} + file: docker/livebook.dockerfile + target: base + build-args: | + ZIG_URL=${{ matrix.image.zig }} + - uses: actions/checkout@v3 + name: Check-out beaver + with: + repository: beaver-lodge/beaver + path: beaver + - uses: actions/checkout@v3 + name: Check-out kinda + with: + repository: beaver-lodge/kinda + path: kinda + - name: Build ARM + continue-on-error: true + if: ${{ matrix.image.platform == 'linux/arm64/v8' }} + run: docker run --platform ${{ matrix.image.platform }} -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh + - name: Build x86 + if: ${{ matrix.image.platform == 'linux/amd64' }} + run: docker run -v $PWD:/src -w /src/beaver jackalcooper/beaver-livebook-${{ matrix.image.suffix }}:latest bash scripts/build-for-publish.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c46ca8fa9..c04de834c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,6 +104,10 @@ Bindings are the part that provides the interface to the MLIR CAPIs. It is imple - Run CI, which generates the new GitHub release uploaded to https://github.com/beaver-lodge/beaver-prebuilt/releases. - Update release url in [`mix.exs`](/mix.exs) +- Run docker image to build for ARM: + ```bash + docker run -it --rm -v $PWD/..:/src -w /src/beaver --env MIX_BUILD_ROOT='_build/arm' jackalcooper/beaver-livebook-arm64:latest bash scripts/build-for-publish.sh + ``` ### Mac diff --git a/dev-requirements.txt b/dev-requirements.txt index eaae332db..8211ba6ea 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,3 @@ -mlir==20.0.0.2024112701+fad5ed6e; sys_platform != "linux" -mlir==20.0.0.2024112701+cuda.fad5ed6e; sys_platform == "linux" +mlir==20.0.0.2024120301+cuda.814ed93e; sys_platform == "linux" and platform_machine == "x86_64" +mlir==20.0.0.2024120301+814ed93e; sys_platform != "linux" or platform_machine != "x86_64" --find-links https://github.com/makslevental/mlir-wheels/releases/expanded_assets/latest diff --git a/docker/livebook.dockerfile b/docker/livebook.dockerfile new file mode 100644 index 000000000..6f4281d0e --- /dev/null +++ b/docker/livebook.dockerfile @@ -0,0 +1,31 @@ +FROM ghcr.io/livebook-dev/livebook:0.14.5 AS base +RUN apt-get upgrade -y \ + && apt-get update \ + && apt-get install --no-install-recommends -y \ + ninja-build \ + python3-pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +# LLVM +COPY ./dev-requirements.txt /src/dev-requirements.txt +RUN python3 -m pip install -r /src/dev-requirements.txt && python3 -m pip cache purge +RUN ln -s $(python3 -c 'import mlir;print(mlir.__path__[0])') /usr/local/mlir +ENV PATH=/usr/local/mlir/bin:${PATH} +RUN llvm-config --version +# Zig +ARG ZIG_URL="https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz" +RUN wget "${ZIG_URL}" -O "zig-linux.tar.xz" \ + && tar Jxvf "zig-linux.tar.xz" -C /usr/local \ + && mv /usr/local/zig-linux-*-* /usr/local/zig-linux \ + && rm "zig-linux.tar.xz" +ENV PATH=/usr/local/zig-linux:${PATH} +RUN zig version +ENV ERL_FLAGS="+JMsingle true" + +FROM base AS build +COPY . /src +WORKDIR /src +ENV MIX_ENV=prod +ENV ELIXIR_MAKE_CACHE_DIR=. +RUN mix deps.get +RUN mix elixir_make.precompile diff --git a/mix.exs b/mix.exs index df86d145e..d96e0cd7e 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Beaver.MixProject do def project do [ app: :beaver, - version: "0.3.11-dev", + version: "0.4.0", elixir: "~> 1.12", start_permanent: Mix.env() == :prod, elixirc_paths: elixirc_paths(Mix.env()), @@ -19,7 +19,7 @@ defmodule Beaver.MixProject do make_force_build: System.get_env("BEAVER_BUILD_CMAKE") in ["1", "true"], make_precompiler_url: System.get_env("BEAVER_ARTEFACT_URL") || - "https://github.com/beaver-lodge/beaver-prebuilt/releases/download/2024-09-03-0613/@{artefact_filename}", + "https://github.com/beaver-lodge/beaver-prebuilt/releases/download/2024-12-04-0908/@{artefact_filename}", make_precompiler_nif_versions: [ versions: fn opts -> target = opts.target @@ -115,7 +115,7 @@ defmodule Beaver.MixProject do defp deps do [ {:elixir_make, "~> 0.4", runtime: false}, - {:kinda, "~> 0.9.2"}, + {:kinda, "~> 0.9.3"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:benchee, "~> 1.0", only: :dev}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false} diff --git a/mix.lock b/mix.lock index 753fabc30..644e193e6 100644 --- a/mix.lock +++ b/mix.lock @@ -1,16 +1,16 @@ %{ "benchee": {:hex, :benchee, "1.3.1", "c786e6a76321121a44229dde3988fc772bca73ea75170a73fd5f4ddf1af95ccf", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "76224c58ea1d0391c8309a8ecbfe27d71062878f59bd41a390266bf4ac1cc56d"}, "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "credo": {:hex, :credo, "1.7.8", "9722ba1681e973025908d542ec3d95db5f9c549251ba5b028e251ad8c24ab8c5", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cb9e87cc64f152f3ed1c6e325e7b894dea8f5ef2e41123bd864e3cd5ceb44968"}, + "credo": {:hex, :credo, "1.7.10", "6e64fe59be8da5e30a1b96273b247b5cf1cc9e336b5fd66302a64b25749ad44d", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "71fbc9a6b8be21d993deca85bf151df023a3097b01e09a2809d460348561d8cd"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, - "elixir_make": {:hex, :elixir_make, "0.8.4", "4960a03ce79081dee8fe119d80ad372c4e7badb84c493cc75983f9d3bc8bde0f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "6e7f1d619b5f61dfabd0a20aa268e575572b542ac31723293a4c1a567d5ef040"}, - "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, + "elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"}, + "ex_doc": {:hex, :ex_doc, "0.35.1", "de804c590d3df2d9d5b8aec77d758b00c814b356119b3d4455e4b8a8687aecaf", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2121c6402c8d44b05622677b761371a759143b958c6c19f6558ff64d0aed40df"}, "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, - "kinda": {:hex, :kinda, "0.9.2", "d75aaac76810f50b9db91347034f73e4a305a9a6ba405862f4db7342793e265b", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "fd4a8484cd95d6e17de841079466e70ff8d96fe996fbd44bb3d7a6be95ce30ac"}, - "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "kinda": {:hex, :kinda, "0.9.3", "936e1e7a6e54943b078366319af4de4cce5f2ff2a9462e03187fcf762278f93c", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "6661b01420625474ebe1cbb592e8ea450d6434943c6c04800183ccee62fbfbd7"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, diff --git a/native/Makefile b/native/Makefile index 588381aa5..937ebb2ab 100644 --- a/native/Makefile +++ b/native/Makefile @@ -1,4 +1,4 @@ -LLVM_CONFIG_PATH ?= $($(shell echo $$LLVM_CONFIG_PATH), llvm-config) +LLVM_CONFIG_PATH ?= llvm-config LLVM_LIB_DIR := $(shell ${LLVM_CONFIG_PATH} --libdir) LLVM_CMAKE_DIR = $(LLVM_LIB_DIR)/cmake/llvm MLIR_CMAKE_DIR = $(LLVM_LIB_DIR)/cmake/mlir diff --git a/scripts/build-for-publish.sh b/scripts/build-for-publish.sh index 7020d03b7..f6fa4758c 100644 --- a/scripts/build-for-publish.sh +++ b/scripts/build-for-publish.sh @@ -1,4 +1,5 @@ set -e export MIX_ENV=prod export ELIXIR_MAKE_CACHE_DIR=. +mix deps.get mix elixir_make.precompile From 02448df335901b7ea5085b22250c4febaa59d810 Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Wed, 4 Dec 2024 22:33:52 +0800 Subject: [PATCH 2/3] fix lock --- mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index d96e0cd7e..75e5bb73e 100644 --- a/mix.exs +++ b/mix.exs @@ -115,7 +115,7 @@ defmodule Beaver.MixProject do defp deps do [ {:elixir_make, "~> 0.4", runtime: false}, - {:kinda, "~> 0.9.3"}, + {:kinda, "~> 0.9.2"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:benchee, "~> 1.0", only: :dev}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false} diff --git a/mix.lock b/mix.lock index 644e193e6..0ac2a692b 100644 --- a/mix.lock +++ b/mix.lock @@ -8,7 +8,7 @@ "ex_doc": {:hex, :ex_doc, "0.35.1", "de804c590d3df2d9d5b8aec77d758b00c814b356119b3d4455e4b8a8687aecaf", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2121c6402c8d44b05622677b761371a759143b958c6c19f6558ff64d0aed40df"}, "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, - "kinda": {:hex, :kinda, "0.9.3", "936e1e7a6e54943b078366319af4de4cce5f2ff2a9462e03187fcf762278f93c", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "6661b01420625474ebe1cbb592e8ea450d6434943c6c04800183ccee62fbfbd7"}, + "kinda": {:hex, :kinda, "0.9.2", "d75aaac76810f50b9db91347034f73e4a305a9a6ba405862f4db7342793e265b", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "fd4a8484cd95d6e17de841079466e70ff8d96fe996fbd44bb3d7a6be95ce30ac"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, From 6c18e2987bc8a5a5f0be9038573e23065128707c Mon Sep 17 00:00:00 2001 From: Shenghang Tsai Date: Thu, 5 Dec 2024 20:15:02 +0800 Subject: [PATCH 3/3] Update pass_runner.ex --- .github/workflows/release.yml | 1 - CITATION.cff | 2 +- README.md | 2 +- docker/livebook.dockerfile | 10 +--------- guides/your-first-beaver-compiler.livemd | 2 +- lib/beaver/pass_runner.ex | 3 ++- mix.exs | 4 ++-- mix.lock | 2 +- test/pass_test.exs | 14 ++++++-------- 9 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7d420ec4..fc13df1fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -171,7 +171,6 @@ jobs: platforms: | ${{ matrix.image.platform }} file: docker/livebook.dockerfile - target: base build-args: | ZIG_URL=${{ matrix.image.zig }} - uses: actions/checkout@v3 diff --git a/CITATION.cff b/CITATION.cff index 040213551..b5cbc3ef9 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -5,6 +5,6 @@ authors: given-names: "Shenghang" orcid: "https://orcid.org/0009-0003-7397-1203" title: "Beaver: MLIR Toolkit in Elixir and Zig" -version: 0.3.9 +version: 0.4.0 date-released: 2024-07-27 url: "https://github.com/beaver-lodge/beaver" diff --git a/README.md b/README.md index 6f13ce394..cd6bc2c26 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ by adding `beaver` to your list of dependencies in `mix.exs`: ```elixir def deps do [ - {:beaver, "~> 0.3.9"} + {:beaver, "~> 0.4.0"} ] end ``` diff --git a/docker/livebook.dockerfile b/docker/livebook.dockerfile index 6f4281d0e..516f5a70a 100644 --- a/docker/livebook.dockerfile +++ b/docker/livebook.dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/livebook-dev/livebook:0.14.5 AS base +FROM ghcr.io/livebook-dev/livebook:0.14.5 RUN apt-get upgrade -y \ && apt-get update \ && apt-get install --no-install-recommends -y \ @@ -21,11 +21,3 @@ RUN wget "${ZIG_URL}" -O "zig-linux.tar.xz" \ ENV PATH=/usr/local/zig-linux:${PATH} RUN zig version ENV ERL_FLAGS="+JMsingle true" - -FROM base AS build -COPY . /src -WORKDIR /src -ENV MIX_ENV=prod -ENV ELIXIR_MAKE_CACHE_DIR=. -RUN mix deps.get -RUN mix elixir_make.precompile diff --git a/guides/your-first-beaver-compiler.livemd b/guides/your-first-beaver-compiler.livemd index dd3e7554f..5428522cf 100644 --- a/guides/your-first-beaver-compiler.livemd +++ b/guides/your-first-beaver-compiler.livemd @@ -2,7 +2,7 @@ ```elixir Mix.install([ - {:beaver, "~> 0.3"} + {:beaver, "~> 0.4"} ]) ``` diff --git a/lib/beaver/pass_runner.ex b/lib/beaver/pass_runner.ex index 1fd211c28..f6c6a6872 100644 --- a/lib/beaver/pass_runner.ex +++ b/lib/beaver/pass_runner.ex @@ -1,5 +1,6 @@ defmodule Beaver.PassRunner do alias Beaver.MLIR + require Logger @moduledoc """ `GenServer` to run an MLIR pass implemented in Elixir @@ -23,7 +24,7 @@ defmodule Beaver.PassRunner do rescue exception -> MLIR.CAPI.beaver_raw_logical_mutex_token_signal_failure(token_ref) - reraise exception, __STACKTRACE__ + Logger.error("#{Exception.format(:error, exception, __STACKTRACE__)}") end {:noreply, state} diff --git a/mix.exs b/mix.exs index 75e5bb73e..5d8b54bc3 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Beaver.MixProject do def project do [ app: :beaver, - version: "0.4.0", + version: "0.4.1-dev", elixir: "~> 1.12", start_permanent: Mix.env() == :prod, elixirc_paths: elixirc_paths(Mix.env()), @@ -115,7 +115,7 @@ defmodule Beaver.MixProject do defp deps do [ {:elixir_make, "~> 0.4", runtime: false}, - {:kinda, "~> 0.9.2"}, + {:kinda, "~> 0.9.3"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:benchee, "~> 1.0", only: :dev}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false} diff --git a/mix.lock b/mix.lock index 0ac2a692b..644e193e6 100644 --- a/mix.lock +++ b/mix.lock @@ -8,7 +8,7 @@ "ex_doc": {:hex, :ex_doc, "0.35.1", "de804c590d3df2d9d5b8aec77d758b00c814b356119b3d4455e4b8a8687aecaf", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2121c6402c8d44b05622677b761371a759143b958c6c19f6558ff64d0aed40df"}, "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, - "kinda": {:hex, :kinda, "0.9.2", "d75aaac76810f50b9db91347034f73e4a305a9a6ba405862f4db7342793e265b", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "fd4a8484cd95d6e17de841079466e70ff8d96fe996fbd44bb3d7a6be95ce30ac"}, + "kinda": {:hex, :kinda, "0.9.3", "936e1e7a6e54943b078366319af4de4cce5f2ff2a9462e03187fcf762278f93c", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "6661b01420625474ebe1cbb592e8ea450d6434943c6c04800183ccee62fbfbd7"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, diff --git a/test/pass_test.exs b/test/pass_test.exs index 6fe5393f4..2a66722e3 100644 --- a/test/pass_test.exs +++ b/test/pass_test.exs @@ -1,6 +1,5 @@ defmodule PassTest do use Beaver.Case, async: true, diagnostic: :server - import ExUnit.CaptureLog use Beaver alias Beaver.MLIR.Dialect.{Func, Arith} require Func @@ -32,17 +31,16 @@ defmodule PassTest do |> MLIR.verify!() end + @tag capture_log: true test "exception in run/1", %{ctx: ctx, diagnostic_server: diagnostic_server} do ir = example_ir(ctx) assert_raise RuntimeError, ~r"Unexpected failure running passes", fn -> - assert capture_log(fn -> - ir - |> Beaver.Composer.nested("func.func", [ - PassRaisingException - ]) - |> Beaver.Composer.run!() - end) =~ ~r"fail to run a pass" + ir + |> Beaver.Composer.nested("func.func", [ + PassRaisingException + ]) + |> Beaver.Composer.run!() end assert Beaver.Capturer.collect(diagnostic_server) =~