Skip to content

Commit 0cf3090

Browse files
committed
ci : add windows mingw multiple cpu release
1 parent 917786f commit 0cf3090

File tree

3 files changed

+119
-209
lines changed

3 files changed

+119
-209
lines changed

.github/workflows/build.yml

Lines changed: 105 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,22 +1234,110 @@ jobs:
12341234
12351235
./gradlew build --no-daemon
12361236
1237-
# freeBSD-latest:
1238-
# runs-on: macos-12
1239-
# steps:
1240-
# - name: Clone
1241-
# uses: actions/checkout@v4
1242-
#
1243-
# - name: Build
1244-
# uses: cross-platform-actions/action@v0.19.0
1245-
# with:
1246-
# operating_system: freebsd
1247-
# version: '13.2'
1248-
# hypervisor: 'qemu'
1249-
# run: |
1250-
# sudo pkg update
1251-
# sudo pkg install -y gmake automake autoconf pkgconf llvm15 openblas
1252-
# gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
1237+
windows-latest-mingw-cpu-x64:
1238+
runs-on: windows-latest
1239+
1240+
strategy:
1241+
fail-fast: false
1242+
matrix:
1243+
arch: [sse, avx, avx2, avx512]
1244+
include:
1245+
- { arch: sse, defines: '-DGGML_FMA=OFF -DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_AVX_VNNI=OFF -DGGML_F16C=OFF -DGGML_AVX512=OFF -DGGML_AVX512_VNNI=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
1246+
- { arch: avx, defines: '-DGGML_FMA=ON -DGGML_AVX=ON -DGGML_AVX2=OFF -DGGML_AVX_VNNI=OFF -DGGML_F16C=ON -DGGML_AVX512=OFF -DGGML_AVX512_VNNI=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
1247+
- { arch: avx2, defines: '-DGGML_FMA=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX_VNNI=OFF -DGGML_F16C=ON -DGGML_AVX512=OFF -DGGML_AVX512_VNNI=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
1248+
- { arch: avx512, defines: '-DGGML_FMA=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX_VNNI=ON -DGGML_F16C=ON -DGGML_AVX512=ON -DGGML_AVX512_VNNI=ON -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
1249+
#- { arch: amx, defines: '-DGGML_FMA=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX_VNNI=ON -DGGML_F16C=ON -DGGML_AVX512=ON -DGGML_AVX512_VNNI=ON -DGGML_AMX_TILE=ON -DGGML_AMX_INT8=ON' }
1250+
1251+
steps:
1252+
- name: Clone
1253+
uses: actions/checkout@v4
1254+
1255+
- name: Install Ninja
1256+
run: |
1257+
choco install ninja
1258+
1259+
- name: Build using CMake
1260+
run: |
1261+
cmake -B build -G "Ninja Multi-Config" -DGGML_NATIVE=OFF -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON -DGGML_OPENMP=OFF ${{ matrix.defines }}
1262+
cmake --build build --config Release -t ggml-cpu
1263+
1264+
- name: Rename artifacts
1265+
run: mv build/bin/Release/ggml-cpu.dll ggml-cpu-${{ matrix.arch }}.dll
1266+
1267+
- name: Upload artifacts
1268+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
1269+
uses: actions/upload-artifact@v4
1270+
with:
1271+
path: ggml-cpu-${{ matrix.arch }}.dll
1272+
name: ggml-cpu-${{ matrix.arch }}.dll
1273+
1274+
windows-latest-mingw-x64:
1275+
runs-on: windows-latest
1276+
1277+
needs:
1278+
- windows-latest-mingw-cpu-x64
1279+
1280+
steps:
1281+
- name: Clone
1282+
uses: actions/checkout@v4
1283+
with:
1284+
fetch-depth: 0
1285+
1286+
- name: Install Ninja
1287+
run: |
1288+
dir c:/mingw64
1289+
dir c:/mingw64/bin
1290+
choco install ninja
1291+
1292+
- name: Download curl for Windows
1293+
run: |
1294+
curl.exe -O https://curl.se/windows/dl-8.11.0_4/curl-8.11.0_4-win64-mingw.zip
1295+
7z x curl-8.11.0_4-win64-mingw.zip -ocurl
1296+
1297+
- name: Build using CMake
1298+
run: |
1299+
cmake -B build -G "Ninja Multi-Config" -DLLAMA_CURL=ON -DLLAMA_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DCURL_INCLUDE_DIR="curl/curl-8.11.0_4-win64-mingw/include/" -DCURL_LIBRARY="curl/curl-8.11.0_4-win64-mingw/lib/libcurl.dll.a"
1300+
cmake --build build --config Release -t llama-bench -t llama-cli -t llama-gguf-hash -t llama-gguf-split -t llama-imatrix -t llama-perplexity -t llama-quantize -t llama-simple -t llama-simple-chat -t llama-tokenize
1301+
cp curl/curl-8.11.0_4-win64-mingw/bin/libcurl-x64.dll build/bin/Release
1302+
cp c:/mingw64/bin/libwinpthread-1.dll build/bin/Release
1303+
cp c:/mingw64/bin/libstdc++-6.dll build/bin/Release
1304+
cp c:/mingw64/bin/libgcc_s_seh-1.dll build/bin/Release
1305+
# cp c:/mingw64/bin/libgomp-1.dll build/bin/Release
1306+
1307+
- name: Download CPU backend artifacts
1308+
uses: actions/download-artifact@v4
1309+
with:
1310+
pattern: 'ggml-cpu-*.dll'
1311+
path: build/bin/Release
1312+
merge-multiple: true
1313+
1314+
- name: Determine tag name
1315+
id: tag
1316+
shell: bash
1317+
run: |
1318+
BUILD_NUMBER="$(git rev-list --count HEAD)"
1319+
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
1320+
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
1321+
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
1322+
else
1323+
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
1324+
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
1325+
fi
1326+
1327+
- name: Pack artifacts
1328+
id: pack_artifacts
1329+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
1330+
run: |
1331+
Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
1332+
7z a llama-${{ steps.tag.outputs.name }}-bin-mingw-cpu.zip .\build\bin\Release\*
1333+
1334+
- name: Upload artifacts
1335+
id: upload_artifacts
1336+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
1337+
uses: actions/upload-artifact@v4
1338+
with:
1339+
path: llama-${{ steps.tag.outputs.name }}-bin-mingw-cpu.zip
1340+
name: llama-${{ steps.tag.outputs.name }}-bin-mingw-cpu.zip
12531341

12541342
release:
12551343
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
@@ -1266,6 +1354,7 @@ jobs:
12661354
- windows-latest-cmake-hip-release
12671355
- macOS-latest-cmake-arm64
12681356
- macOS-latest-cmake-x64
1357+
- windows-latest-mingw-x64
12691358

12701359
steps:
12711360
- name: Clone
@@ -1326,196 +1415,3 @@ jobs:
13261415
});
13271416
}
13281417
}
1329-
1330-
# ubuntu-latest-gcc:
1331-
# runs-on: ubuntu-latest
1332-
#
1333-
# strategy:
1334-
# matrix:
1335-
# build: [Debug, Release]
1336-
#
1337-
# steps:
1338-
# - name: Clone
1339-
# uses: actions/checkout@v4
1340-
#
1341-
# - name: Dependencies
1342-
# run: |
1343-
# sudo apt-get update
1344-
# sudo apt-get install build-essential
1345-
# sudo apt-get install cmake
1346-
#
1347-
# - name: Configure
1348-
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
1349-
#
1350-
# - name: Build
1351-
# run: |
1352-
# make
1353-
#
1354-
# ubuntu-latest-clang:
1355-
# runs-on: ubuntu-latest
1356-
#
1357-
# strategy:
1358-
# matrix:
1359-
# build: [Debug, Release]
1360-
#
1361-
# steps:
1362-
# - name: Clone
1363-
# uses: actions/checkout@v4
1364-
#
1365-
# - name: Dependencies
1366-
# run: |
1367-
# sudo apt-get update
1368-
# sudo apt-get install build-essential
1369-
# sudo apt-get install cmake
1370-
#
1371-
# - name: Configure
1372-
# run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
1373-
#
1374-
# - name: Build
1375-
# run: |
1376-
# make
1377-
#
1378-
# ubuntu-latest-gcc-sanitized:
1379-
# runs-on: ubuntu-latest
1380-
#
1381-
# strategy:
1382-
# matrix:
1383-
# sanitizer: [ADDRESS, THREAD, UNDEFINED]
1384-
#
1385-
# steps:
1386-
# - name: Clone
1387-
# uses: actions/checkout@v4
1388-
#
1389-
# - name: Dependencies
1390-
# run: |
1391-
# sudo apt-get update
1392-
# sudo apt-get install build-essential
1393-
# sudo apt-get install cmake
1394-
#
1395-
# - name: Configure
1396-
# run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
1397-
#
1398-
# - name: Build
1399-
# run: |
1400-
# make
1401-
#
1402-
# windows:
1403-
# runs-on: windows-latest
1404-
#
1405-
# strategy:
1406-
# matrix:
1407-
# build: [Release]
1408-
# arch: [Win32, x64]
1409-
# include:
1410-
# - arch: Win32
1411-
# s2arc: x86
1412-
# - arch: x64
1413-
# s2arc: x64
1414-
#
1415-
# steps:
1416-
# - name: Clone
1417-
# uses: actions/checkout@v4
1418-
#
1419-
# - name: Add msbuild to PATH
1420-
# uses: microsoft/setup-msbuild@v1
1421-
#
1422-
# - name: Configure
1423-
# run: >
1424-
# cmake -S . -B ./build -A ${{ matrix.arch }}
1425-
# -DCMAKE_BUILD_TYPE=${{ matrix.build }}
1426-
#
1427-
# - name: Build
1428-
# run: |
1429-
# cd ./build
1430-
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
1431-
#
1432-
# - name: Upload binaries
1433-
# uses: actions/upload-artifact@v4
1434-
# with:
1435-
# name: llama-bin-${{ matrix.arch }}
1436-
# path: build/bin/${{ matrix.build }}
1437-
#
1438-
# windows-blas:
1439-
# runs-on: windows-latest
1440-
#
1441-
# strategy:
1442-
# matrix:
1443-
# build: [Release]
1444-
# arch: [Win32, x64]
1445-
# blas: [ON]
1446-
# include:
1447-
# - arch: Win32
1448-
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
1449-
# s2arc: x86
1450-
# - arch: x64
1451-
# obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
1452-
# s2arc: x64
1453-
#
1454-
# steps:
1455-
# - name: Clone
1456-
# uses: actions/checkout@v4
1457-
#
1458-
# - name: Add msbuild to PATH
1459-
# uses: microsoft/setup-msbuild@v1
1460-
#
1461-
# - name: Fetch OpenBLAS
1462-
# if: matrix.blas == 'ON'
1463-
# run: |
1464-
# C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
1465-
# 7z x blas.zip -oblas -y
1466-
# copy blas/include/cblas.h .
1467-
# copy blas/include/openblas_config.h .
1468-
# echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
1469-
#
1470-
# - name: Configure
1471-
# run: >
1472-
# cmake -S . -B ./build -A ${{ matrix.arch }}
1473-
# -DCMAKE_BUILD_TYPE=${{ matrix.build }}
1474-
# -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
1475-
# -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
1476-
#
1477-
# - name: Build
1478-
# run: |
1479-
# cd ./build
1480-
# msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
1481-
#
1482-
# - name: Copy libopenblas.dll
1483-
# if: matrix.blas == 'ON'
1484-
# run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
1485-
#
1486-
# - name: Upload binaries
1487-
# if: matrix.blas == 'ON'
1488-
# uses: actions/upload-artifact@v4
1489-
# with:
1490-
# name: llama-blas-bin-${{ matrix.arch }}
1491-
# path: build/bin/${{ matrix.build }}
1492-
#
1493-
# emscripten:
1494-
# runs-on: ubuntu-latest
1495-
#
1496-
# strategy:
1497-
# matrix:
1498-
# build: [Release]
1499-
#
1500-
# steps:
1501-
# - name: Clone
1502-
# uses: actions/checkout@v4
1503-
#
1504-
# - name: Dependencies
1505-
# run: |
1506-
# wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
1507-
# tar -xvf master.tar.gz
1508-
# emsdk-master/emsdk update
1509-
# emsdk-master/emsdk install latest
1510-
# emsdk-master/emsdk activate latest
1511-
#
1512-
# - name: Configure
1513-
# run: echo "tmp"
1514-
#
1515-
# - name: Build
1516-
# run: |
1517-
# pushd emsdk-master
1518-
# source ./emsdk_env.sh
1519-
# popd
1520-
# emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
1521-
# make

common/common.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#include <windows.h>
4444
#include <fcntl.h>
4545
#include <io.h>
46+
#include <sys/types.h>
47+
#include <sys/stat.h>
4648
#else
4749
#include <sys/ioctl.h>
4850
#include <sys/stat.h>
@@ -1168,8 +1170,13 @@ static bool common_download_file(const std::string & url, const std::string & pa
11681170
#endif
11691171

11701172
// Check if the file already exists locally
1173+
#ifdef _WIN32
1174+
struct _stati64 model_file_info;
1175+
auto file_exists = (_stati64(path.c_str(), &model_file_info) == 0);
1176+
#else
11711177
struct stat model_file_info;
11721178
auto file_exists = (stat(path.c_str(), &model_file_info) == 0);
1179+
#endif
11731180

11741181
// If the file exists, check its JSON metadata companion file.
11751182
std::string metadata_path = path + ".json";

ggml/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ else()
3232
endif()
3333
endif()
3434

35+
# avoid the lib prefix on win32
36+
if (WIN32)
37+
set(CMAKE_STATIC_LIBRARY_PREFIX "")
38+
set(CMAKE_SHARED_LIBRARY_PREFIX "")
39+
set(CMAKE_SHARED_MODULE_PREFIX "")
40+
endif()
41+
3542
option(BUILD_SHARED_LIBS "ggml: build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT})
3643
option(GGML_BACKEND_DL "ggml: build backends as dynamic libraries (requires BUILD_SHARED_LIBS)" OFF)
3744

0 commit comments

Comments
 (0)