Skip to content

Commit e129551

Browse files
authored
CI: add Windows CLBlast and OpenBLAS builds (#1277)
* Add OpenCL and CLBlast support * Add OpenBLAS support * Remove testing from matrix * change build name to 'clblast'
1 parent 1b0fd45 commit e129551

File tree

1 file changed

+65
-8
lines changed

1 file changed

+65
-8
lines changed

.github/workflows/build.yml

+65-8
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
make
121121
122122
macOS-latest-cmake:
123-
runs-on: macOS-latest
123+
runs-on: macos-latest
124124

125125
steps:
126126
- name: Clone
@@ -148,29 +148,86 @@ jobs:
148148
149149
windows-latest-cmake:
150150
runs-on: windows-latest
151+
env:
152+
OPENBLAS_VERSION: 0.3.23
153+
OPENCL_VERSION: 2023.04.17
154+
CLBLAST_VERSION: 1.5.3
151155

152156
strategy:
153157
matrix:
154158
include:
155-
- build: 'avx2'
156-
defines: ''
157-
- build: 'avx'
158-
defines: '-DLLAMA_AVX2=OFF'
159-
- build: 'avx512'
160-
defines: '-DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
159+
- build: 'avx2'
160+
defines: ''
161+
- build: 'avx'
162+
defines: '-DLLAMA_AVX2=OFF'
163+
- build: 'avx512'
164+
defines: '-DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
165+
- build: 'clblast'
166+
defines: '-DLLAMA_CLBLAST=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/clblast"'
167+
- build: 'openblas'
168+
defines: '-DLLAMA_OPENBLAS=ON -DBLAS_LIBRARIES="/LIBPATH:$env:RUNNER_TEMP/openblas/lib" -DOPENBLAS_INC="$env:RUNNER_TEMP/openblas/include"'
161169

162170
steps:
163171
- name: Clone
164172
id: checkout
165173
uses: actions/checkout@v1
166174

175+
- name: Download OpenCL SDK
176+
id: get_opencl
177+
if: ${{ matrix.build == 'clblast' }}
178+
run: |
179+
curl.exe -o $env:RUNNER_TEMP/opencl.zip -L "https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v${env:OPENCL_VERSION}/OpenCL-SDK-v${env:OPENCL_VERSION}-Win-x64.zip"
180+
mkdir $env:RUNNER_TEMP/opencl
181+
tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl
182+
183+
- name: Download CLBlast
184+
id: get_clblast
185+
if: ${{ matrix.build == 'clblast' }}
186+
run: |
187+
curl.exe -o $env:RUNNER_TEMP/clblast.zip -L "https://github.com/CNugteren/CLBlast/releases/download/${env:CLBLAST_VERSION}/CLBlast-${env:CLBLAST_VERSION}-Windows-x64.zip"
188+
curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE"
189+
mkdir $env:RUNNER_TEMP/clblast
190+
tar.exe -xvf $env:RUNNER_TEMP/clblast.zip -C $env:RUNNER_TEMP/clblast
191+
foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) {
192+
$txt = Get-Content -Path $f -Raw
193+
$txt.Replace('C:/dependencies/opencl/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8
194+
}
195+
196+
- name: Download OpenBLAS
197+
id: get_openblas
198+
if: ${{ matrix.build == 'openblas' }}
199+
run: |
200+
curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
201+
curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
202+
mkdir $env:RUNNER_TEMP/openblas
203+
tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
204+
$vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
205+
$msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
206+
$lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
207+
& $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
208+
167209
- name: Build
168210
id: cmake_build
169211
run: |
170212
mkdir build
171213
cd build
172214
cmake .. ${{ matrix.defines }}
173215
cmake --build . --config Release
216+
cp ../LICENSE ./bin/Release/llama.cpp.txt
217+
218+
- name: Add clblast.dll
219+
id: add_clblast_dll
220+
if: ${{ matrix.build == 'clblast' }}
221+
run: |
222+
cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release
223+
cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt
224+
225+
- name: Add libopenblas.dll
226+
id: add_libopenblas_dll
227+
if: ${{ matrix.build == 'openblas' }}
228+
run: |
229+
cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
230+
cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
174231
175232
- name: Check AVX512F support
176233
id: check_avx512f
@@ -187,7 +244,7 @@ jobs:
187244
188245
- name: Test
189246
id: cmake_test
190-
if: ${{ matrix.build != 'avx512' || env.HAS_AVX512F == '1' }} # Test AVX-512 only when possible
247+
if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # Test AVX-512 only when possible
191248
run: |
192249
cd build
193250
ctest -C Release --verbose

0 commit comments

Comments
 (0)