Skip to content

Commit

Permalink
WIP build: metal
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Nov 21, 2023
1 parent fd21e30 commit a2917c4
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,37 @@ jobs:
draft: true
files: ${{ steps.precompile.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/')

build_metal:
name: metal / ${{ matrix.target }} / ${{ matrix.os }}
runs-on: macos-13
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-13

steps:
- uses: actions/checkout@v4
- run: rustup target add ${{ matrix.target }}

- uses: philss/rustler-precompiled-action@main
id: precompile
with:
project-dir: ${{ env.PROJECT_DIR }}
project-name: ${{ env.PROJECT_NAME }}
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.target }}
use-cross: null
nif-version: ${{ env.NIF_VERSION }}
variant: metal
cargo-args: "--features metal"

- uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ steps.precompile.outputs.file-path }}
if: startsWith(github.ref, 'refs/tags/')
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ only the host CPU.
| --- | --- |
| cpu | |
| cuda | CUDA 12.x |
| metal | Metal ? |

To use Candlex with NVidia GPU you need [CUDA](https://developer.nvidia.com/cuda-downloads) compatible with your
GPU drivers.
Expand Down
4 changes: 3 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Config

config :candlex, use_cuda: System.get_env("CANDLEX_NIF_TARGET") == "cuda"
config :candlex,
use_cuda: System.get_env("CANDLEX_NIF_TARGET") == "cuda",
use_metal: System.get_env("CANDLEX_NIF_TARGET") == "metal"
1 change: 1 addition & 0 deletions lib/candlex/native.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ defmodule Candlex.Native do
"x86_64-unknown-linux-gnu"
],
variants: %{
"aarch64-apple-darwin" => [metal: fn -> Application.compile_env(:candlex, :use_metal) end],
"x86_64-unknown-linux-gnu" => [cuda: fn -> Application.compile_env(:candlex, :use_cuda) end]
}

Expand Down
168 changes: 167 additions & 1 deletion native/candlex/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions native/candlex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ anyhow = "1.0.75"

[features]
cuda = ["candle-core/cuda"]
metal = ["candle-core/metal"]

0 comments on commit a2917c4

Please sign in to comment.