Skip to content

Commit

Permalink
Add opencl other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Aug 21, 2024
1 parent 55c6554 commit 0578619
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/R-CMD-check-opencl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
matrix:
config:
- {os: macOS-latest, r: 'release', rtools: ''}
- {os: ubuntu-latest, r: 'release', rtools: ''}
- {os: windows-latest, r: 'release', rtools: '44'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -36,11 +39,6 @@ jobs:
echo "CMDSTAN_PATH=${HOME}/.cmdstan" >> $GITHUB_ENV
shell: bash

- uses: n1hility/cancel-previous-runs@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2.10.1
Expand All @@ -54,9 +52,18 @@ jobs:
with:
extra-packages: any::rcmdcheck, local::.

- name: Install POCL
- name: Install POCL (MacOS)
if: matrix.config.os == 'macOS-latest'
run: brew install pocl

- name: Install POCL (Ubuntu)
if: matrix.config.os == 'ubuntu-latest'
run: sudo apt-get install -y pocl-opencl-icd ocl-icd-opencl-dev

- name: Install POCL (Windows)
if: matrix.config.os == 'windows-latest'
run: choco install pocl

- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
Expand All @@ -65,10 +72,13 @@ jobs:

- name: CmdStan Config OpenCL
run: |
brew_prefix <- system("brew --prefix", intern = TRUE)
ocl_icd_lib <- ""
# MacOS
if (Sys.info()["sysname"] == "Darwin") {
ocl_icd_lib <- "-L/opt/homebrew/opt/opencl-icd-loader/lib"
}
cpp_opts <- list(
STAN_OPENCL = TRUE,
LDLIBS_OPENCL = paste0("-L", brew_prefix, "/opt/opencl-icd-loader/lib -lOpenCL")
LDLIBS_OPENCL = paste0(ocl_icd_lib, " -lOpenCL")
)
cmdstanr::cmdstan_make_local(cpp_options = cpp_opts)
cmdstanr::rebuild_cmdstan(cores = 2)
Expand Down

0 comments on commit 0578619

Please sign in to comment.