build.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. paths: ['.github/workflows/**', 'CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  11. pull_request:
  12. types: [opened, synchronize, edited, reopened, review_requested, ready_for_review]
  13. paths: ['CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  14. env:
  15. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  16. jobs:
  17. ubuntu-latest-make:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Clone
  21. id: checkout
  22. uses: actions/checkout@v1
  23. - name: Dependencies
  24. id: depends
  25. run: |
  26. sudo apt-get update
  27. sudo apt-get install build-essential
  28. - name: Build
  29. id: make_build
  30. run: |
  31. make
  32. ubuntu-latest-cmake:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Clone
  36. id: checkout
  37. uses: actions/checkout@v1
  38. - name: Dependencies
  39. id: depends
  40. run: |
  41. sudo apt-get update
  42. sudo apt-get install build-essential
  43. - name: Build
  44. id: cmake_build
  45. run: |
  46. mkdir build
  47. cd build
  48. cmake ..
  49. cmake --build . --config Release
  50. - name: Test
  51. id: cmake_test
  52. run: |
  53. cd build
  54. ctest --verbose
  55. ubuntu-latest-cmake-sanitizer:
  56. runs-on: ubuntu-latest
  57. continue-on-error: true
  58. strategy:
  59. matrix:
  60. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  61. build_type: [Debug, Release]
  62. accelerate: [ON, OFF]
  63. steps:
  64. - name: Clone
  65. id: checkout
  66. uses: actions/checkout@v1
  67. - name: Dependencies
  68. id: depends
  69. run: |
  70. sudo apt-get update
  71. sudo apt-get install build-essential
  72. - name: Build
  73. id: cmake_build
  74. run: |
  75. mkdir build
  76. cd build
  77. cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DLLAMA_ACCELERATE=${{ matrix.accelerate }}
  78. cmake --build . --config ${{ matrix.build_type }}
  79. - name: Test
  80. id: cmake_test
  81. run: |
  82. cd build
  83. ctest --verbose
  84. macOS-latest-make:
  85. runs-on: macos-latest
  86. steps:
  87. - name: Clone
  88. id: checkout
  89. uses: actions/checkout@v1
  90. - name: Dependencies
  91. id: depends
  92. run: |
  93. brew update
  94. - name: Build
  95. id: make_build
  96. run: |
  97. make
  98. macOS-latest-cmake:
  99. runs-on: macOS-latest
  100. steps:
  101. - name: Clone
  102. id: checkout
  103. uses: actions/checkout@v1
  104. - name: Dependencies
  105. id: depends
  106. run: |
  107. brew update
  108. - name: Build
  109. id: cmake_build
  110. run: |
  111. mkdir build
  112. cd build
  113. cmake -DLLAMA_AVX2=OFF ..
  114. cmake --build . --config Release
  115. - name: Test
  116. id: cmake_test
  117. run: |
  118. cd build
  119. ctest --verbose
  120. windows-latest-cmake:
  121. runs-on: windows-latest
  122. strategy:
  123. matrix:
  124. include:
  125. - build: 'avx2'
  126. defines: ''
  127. - build: 'avx'
  128. defines: '-DLLAMA_AVX2=OFF'
  129. - build: 'avx512'
  130. defines: '-DLLAMA_AVX512=ON'
  131. steps:
  132. - name: Clone
  133. id: checkout
  134. uses: actions/checkout@v1
  135. - name: Build
  136. id: cmake_build
  137. run: |
  138. mkdir build
  139. cd build
  140. cmake .. ${{ matrix.defines }}
  141. cmake --build . --config Release
  142. - name: Check AVX512F support
  143. id: check_avx512f
  144. if: ${{ matrix.build == 'avx512' }}
  145. continue-on-error: true
  146. run: |
  147. cd build
  148. Set-Content -Path .\avx512f.exe -Value ([Convert]::FromBase64String('TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAAClmfXY4fibi+H4m4vh+JuL4fiai+P4m4si98aL4vibi7Xbq4vg+JuLUmljaOH4m4sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQRQAATAEBAGo6H2QAAAAAAAAAAOAADwELAQYAAAIAAAAAAAAAAAAADBAAAAAQAAAAIAAAAABAAAAQAAAAAgAABAAAAAAAAAAEAAAAAAAAAAAgAAAAAgAAAAAAAAMAAAAAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAFQQAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAsgAAAAAQAAAAAgAAAAIAAAAAAAAAAAAAAAAAACAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACUEAAAiBAAAAAAAABVi+xRUVNTuAcAAAAPosHrEGaD4wGJXfxbg0X8MI1F+GoAUI1F/GoBUGr1/xUAEEAAUP8VBBBAAItF/FuDwND32BvAQMnDzMx8EAAAAAAAAAAAAACkEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlBAAAIgQAAAAAAAApANXcml0ZUZpbGUAuQFHZXRTdGRIYW5kbGUAAEtFUk5FTDMyLmRsbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==')) -AsByteStream
  149. .\avx512f.exe && echo " AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo " AVX512F: NO"
  150. - name: Test
  151. id: cmake_test
  152. if: ${{ matrix.build != 'avx512' || env.HAS_AVX512F == '1' }} # Test AVX-512 only when possible
  153. run: |
  154. cd build
  155. ctest -C Release --verbose
  156. - name: Get commit hash
  157. id: commit
  158. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  159. uses: pr-mpt/actions-commit-hash@v2
  160. - name: Pack artifacts
  161. id: pack_artifacts
  162. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  163. run: |
  164. 7z a llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\*
  165. - name: Upload artifacts
  166. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  167. uses: actions/upload-artifact@v3
  168. with:
  169. path: |
  170. llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
  171. release:
  172. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  173. runs-on: ubuntu-latest
  174. needs:
  175. - ubuntu-latest-make
  176. - ubuntu-latest-cmake
  177. - macOS-latest-make
  178. - macOS-latest-cmake
  179. - windows-latest-cmake
  180. steps:
  181. - name: Download artifacts
  182. id: download-artifact
  183. uses: actions/download-artifact@v3
  184. - name: Get commit hash
  185. id: commit
  186. uses: pr-mpt/actions-commit-hash@v2
  187. - name: Create release
  188. id: create_release
  189. uses: anzz1/action-create-release@v1
  190. env:
  191. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  192. with:
  193. tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
  194. - name: Upload release
  195. id: upload_release
  196. uses: actions/github-script@v3
  197. with:
  198. github-token: ${{secrets.GITHUB_TOKEN}}
  199. script: |
  200. const path = require('path');
  201. const fs = require('fs');
  202. const release_id = '${{ steps.create_release.outputs.id }}';
  203. for (let file of await fs.readdirSync('./artifact')) {
  204. if (path.extname(file) === '.zip') {
  205. console.log('uploadReleaseAsset', file);
  206. await github.repos.uploadReleaseAsset({
  207. owner: context.repo.owner,
  208. repo: context.repo.repo,
  209. release_id: release_id,
  210. name: file,
  211. data: await fs.readFileSync(`./artifact/${file}`)
  212. });
  213. }
  214. }
  215. # ubuntu-latest-gcc:
  216. # runs-on: ubuntu-latest
  217. #
  218. # strategy:
  219. # matrix:
  220. # build: [Debug, Release]
  221. #
  222. # steps:
  223. # - name: Clone
  224. # uses: actions/checkout@v1
  225. #
  226. # - name: Dependencies
  227. # run: |
  228. # sudo apt-get update
  229. # sudo apt-get install build-essential
  230. # sudo apt-get install cmake
  231. #
  232. # - name: Configure
  233. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  234. #
  235. # - name: Build
  236. # run: |
  237. # make
  238. #
  239. # ubuntu-latest-clang:
  240. # runs-on: ubuntu-latest
  241. #
  242. # strategy:
  243. # matrix:
  244. # build: [Debug, Release]
  245. #
  246. # steps:
  247. # - name: Clone
  248. # uses: actions/checkout@v1
  249. #
  250. # - name: Dependencies
  251. # run: |
  252. # sudo apt-get update
  253. # sudo apt-get install build-essential
  254. # sudo apt-get install cmake
  255. #
  256. # - name: Configure
  257. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  258. #
  259. # - name: Build
  260. # run: |
  261. # make
  262. #
  263. # ubuntu-latest-gcc-sanitized:
  264. # runs-on: ubuntu-latest
  265. #
  266. # strategy:
  267. # matrix:
  268. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  269. #
  270. # steps:
  271. # - name: Clone
  272. # uses: actions/checkout@v1
  273. #
  274. # - name: Dependencies
  275. # run: |
  276. # sudo apt-get update
  277. # sudo apt-get install build-essential
  278. # sudo apt-get install cmake
  279. #
  280. # - name: Configure
  281. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  282. #
  283. # - name: Build
  284. # run: |
  285. # make
  286. #
  287. # windows:
  288. # runs-on: windows-latest
  289. #
  290. # strategy:
  291. # matrix:
  292. # build: [Release]
  293. # arch: [Win32, x64]
  294. # include:
  295. # - arch: Win32
  296. # s2arc: x86
  297. # - arch: x64
  298. # s2arc: x64
  299. #
  300. # steps:
  301. # - name: Clone
  302. # uses: actions/checkout@v1
  303. #
  304. # - name: Add msbuild to PATH
  305. # uses: microsoft/setup-msbuild@v1
  306. #
  307. # - name: Configure
  308. # run: >
  309. # cmake -S . -B ./build -A ${{ matrix.arch }}
  310. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  311. #
  312. # - name: Build
  313. # run: |
  314. # cd ./build
  315. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  316. #
  317. # - name: Upload binaries
  318. # uses: actions/upload-artifact@v1
  319. # with:
  320. # name: llama-bin-${{ matrix.arch }}
  321. # path: build/bin/${{ matrix.build }}
  322. #
  323. # windows-blas:
  324. # runs-on: windows-latest
  325. #
  326. # strategy:
  327. # matrix:
  328. # build: [Release]
  329. # arch: [Win32, x64]
  330. # blas: [ON]
  331. # include:
  332. # - arch: Win32
  333. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  334. # s2arc: x86
  335. # - arch: x64
  336. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  337. # s2arc: x64
  338. #
  339. # steps:
  340. # - name: Clone
  341. # uses: actions/checkout@v1
  342. #
  343. # - name: Add msbuild to PATH
  344. # uses: microsoft/setup-msbuild@v1
  345. #
  346. # - name: Fetch OpenBLAS
  347. # if: matrix.blas == 'ON'
  348. # run: |
  349. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  350. # 7z x blas.zip -oblas -y
  351. # copy blas/include/cblas.h .
  352. # copy blas/include/openblas_config.h .
  353. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  354. #
  355. # - name: Configure
  356. # run: >
  357. # cmake -S . -B ./build -A ${{ matrix.arch }}
  358. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  359. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  360. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  361. #
  362. # - name: Build
  363. # run: |
  364. # cd ./build
  365. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  366. #
  367. # - name: Copy libopenblas.dll
  368. # if: matrix.blas == 'ON'
  369. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  370. #
  371. # - name: Upload binaries
  372. # if: matrix.blas == 'ON'
  373. # uses: actions/upload-artifact@v1
  374. # with:
  375. # name: llama-blas-bin-${{ matrix.arch }}
  376. # path: build/bin/${{ matrix.build }}
  377. #
  378. # emscripten:
  379. # runs-on: ubuntu-latest
  380. #
  381. # strategy:
  382. # matrix:
  383. # build: [Release]
  384. #
  385. # steps:
  386. # - name: Clone
  387. # uses: actions/checkout@v1
  388. #
  389. # - name: Dependencies
  390. # run: |
  391. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  392. # tar -xvf master.tar.gz
  393. # emsdk-master/emsdk update
  394. # emsdk-master/emsdk install latest
  395. # emsdk-master/emsdk activate latest
  396. #
  397. # - name: Configure
  398. # run: echo "tmp"
  399. #
  400. # - name: Build
  401. # run: |
  402. # pushd emsdk-master
  403. # source ./emsdk_env.sh
  404. # popd
  405. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  406. # make