Skip to content

Commit 88a9846

Browse files
author
Henry Linjamäki
authored
Merge branch 'main' into dbk-pr
2 parents 2561b31 + 239d536 commit 88a9846

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+568
-100
lines changed

.github/workflows/build_full_cts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ permissions:
77
on:
88
workflow_dispatch:
99
schedule:
10-
# at 14:01 every friday
11-
- cron: '01 14 * * 5'
10+
# at 12:17 UTC every friday
11+
- cron: '17 12 * * 5'
1212

1313
jobs:
1414
cpu_cts:

.github/workflows/build_linux_gh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
sudo ln -s /opt/libjpeg-turbo/lib64 /opt/libjpeg-turbo/lib &&
108108
sudo ln -s /opt/onnx/lib /opt/onnx/lib64 &&
109109
sudo mv /opt/onnx/include /opt/onnxruntime && sudo mkdir /opt/onnx/include && sudo mv /opt/onnxruntime /opt/onnx/include/ &&
110-
sudo bash -c 'mkdir /opt/source && cd /opt/source && git clone https://github.com/libxsmm/libxsmm.git && cd libxsmm && make -j3 STATIC=0 FORTRAN=0 AVX=2 install DESTDIR=/opt/xsmm'
110+
sudo bash -c 'mkdir /opt/source && cd /opt/source && git clone https://github.com/libxsmm/libxsmm.git && cd libxsmm && echo "unstable-1.17.1" > version.txt && make -j3 STATIC=0 FORTRAN=0 AVX=2 install DESTDIR=/opt/xsmm'
111111
112112
- name: CMake
113113
id: cmake

.github/workflows/build_mingw.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: Windows / MinGW / CPU tests
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
push:
9+
workflow_dispatch:
10+
pull_request:
11+
paths-ignore:
12+
- 'doc/**'
13+
- 'CHANGES'
14+
- 'COPYING'
15+
- 'CREDITS'
16+
- 'LICENSE'
17+
- 'README.*'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
mingw_test_matrix:
25+
name: LLVM ${{ matrix.llvm_version }} - MinGW ${{ matrix.config }}
26+
runs-on: windows-latest
27+
defaults:
28+
run:
29+
shell: msys2 {0}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
llvm_version: [18, 19]
34+
config: [cpu]
35+
36+
steps:
37+
- name: Setup MSYS2
38+
uses: msys2/setup-msys2@d44ca8e88d8b43d56cf5670f91747359d5537f97 # v2.26.0
39+
with:
40+
msystem: MINGW64
41+
update: true
42+
install: >-
43+
mingw-w64-x86_64-gcc
44+
mingw-w64-x86_64-cmake
45+
mingw-w64-x86_64-ninja
46+
mingw-w64-x86_64-hwloc
47+
mingw-w64-x86_64-pkg-config
48+
49+
- name: Checkout PoCL
50+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
51+
52+
- name: Setup Build Environment
53+
run: |
54+
# Convert the Windows workspace path to an MSYS2 compatible one
55+
WORKSPACE=$(cygpath -u "${{ github.workspace }}")
56+
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
57+
58+
- name: Checkout LLVM
59+
id: checkout-llvm
60+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
61+
with:
62+
repository: llvm/llvm-project
63+
ref: release/${{ matrix.llvm_version }}.x
64+
path: llvm-project
65+
66+
- name: Restore Cached LLVM
67+
id: cache-llvm
68+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
69+
with:
70+
path: install-llvm
71+
key: llvm-mingw-${{ matrix.llvm_version }}-${{ runner.os }}
72+
73+
- if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' }}
74+
name: Configure LLVM
75+
run: |
76+
cmake -S llvm-project/llvm -B build-llvm \
77+
-DCMAKE_BUILD_TYPE=Release \
78+
-DLLVM_ENABLE_PROJECTS=clang \
79+
-DLLVM_TARGETS_TO_BUILD=host \
80+
-DCMAKE_INSTALL_PREFIX=${{ env.WORKSPACE }}/install-llvm \
81+
-DLLVM_BUILD_LLVM_DYLIB=ON \
82+
-DLLVM_LINK_LLVM_DYLIB=ON \
83+
-G "Ninja"
84+
# XXX: DYLIBs are necessary to work around export ordinal overflows
85+
86+
- if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' }}
87+
name: Build LLVM
88+
run: |
89+
cmake --build build-llvm
90+
cmake --install build-llvm
91+
92+
- if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' }}
93+
name: Save LLVM
94+
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a
95+
with:
96+
path: install-llvm
97+
key: llvm-mingw-${{ matrix.llvm_version }}-${{ runner.os }}
98+
99+
- name: Load Env vars
100+
id: load-env
101+
run: |
102+
cat ${{ env.WORKSPACE }}/.github/variables.txt >> $GITHUB_ENV
103+
104+
- name: Configure PoCL
105+
run: |
106+
cmake -S ${{ env.WORKSPACE }} -B ${{ env.WORKSPACE }}/build-pocl \
107+
-DCMAKE_BUILD_TYPE=Release \
108+
-DCMAKE_INSTALL_PREFIX=${{ env.WORKSPACE }}/install-pocl \
109+
-DWITH_LLVM_CONFIG=${{ env.WORKSPACE }}/install-llvm/bin/llvm-config.exe \
110+
-DBUILD_SHARED_LIBS=OFF \
111+
-DENABLE_ICD=OFF \
112+
-DENABLE_LOADABLE_DRIVERS=OFF \
113+
-G "Ninja"
114+
# XXX: ENABLE_ICD=OFF because ocl-icd doesn't support Windows,
115+
# and PoCL doesn't support Khronos' ICD loader
116+
# XXX: BUILD_SHARED_LIBS=OFF because the CI workers have OpenCL.dll
117+
# in System32 which takes preference over our version.
118+
# XXX: ENABLE_LOADABLE_DRIVERS=OFF because PoCL doesn't know how to
119+
# find drivers when built with BUILD_SHARED_LIBS=OFF
120+
121+
- name: Build PoCL
122+
run: |
123+
cmake --build ${{ env.WORKSPACE }}/build-pocl
124+
125+
- name: Run Tests
126+
env:
127+
POCL_CACHE_DIR: "${{ runner.temp }}/GH_POCL_CACHE"
128+
timeout-minutes: 120
129+
run: |
130+
rm -rf ${{ env.POCL_CACHE_DIR }}
131+
mkdir -p ${{ env.POCL_CACHE_DIR }}
132+
cd ${{ env.WORKSPACE }}/build-pocl
133+
export PATH=${{ env.WORKSPACE }}/install-llvm/bin:$PATH
134+
${{ env.WORKSPACE }}/tools/scripts/run_cpu_tests mingw $CTEST_FLAGS -j$(nproc)

.github/workflows/build_msvc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Checkout PoCL
39-
uses: actions/checkout@v4
39+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4040

4141
# Source MSVC tools. This is a known way to have the PoCL configuration
4242
# step to pick up MSVC compiler (cl.exe) instead of MinGW's gcc.
@@ -52,15 +52,15 @@ jobs:
5252
# packages doesn't include libraries or llvm-config.exe.
5353
- name: Checkout LLVM
5454
id: checkout-llvm
55-
uses: actions/checkout@v4
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
5656
with:
5757
repository: llvm/llvm-project
5858
ref: release/${{ matrix.llvm_version }}.x
5959
path: llvm-project
6060

6161
- name: Restore Cached LLVM
6262
id: cache-llvm
63-
uses: actions/cache@v4
63+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
6464
with:
6565
path: install-llvm\**
6666
key: llvm-${{ matrix.llvm_version }}-${{ runner.os }}-${{ steps.checkout-llvm.outputs.commit }}
@@ -85,7 +85,7 @@ jobs:
8585
# it in case a PoCL step fail ahead.
8686
- if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' }}
8787
name: Save LLVM
88-
uses: actions/cache/save@v4
88+
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a
8989
with:
9090
path: install-llvm\**
9191
key: llvm-${{ matrix.llvm_version }}-${{ runner.os }}-${{ steps.checkout-llvm.outputs.commit }}

.github/workflows/build_only.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ jobs:
4040
# proxy - proxy driver
4141
# accel - almaif driver
4242
# no_llvm_no_debug - pthread driver + ENABLE_LLVM=0 + POCL_DEBUG_MESSAGES=0
43+
# only_lib - build only libpocl, no examples or binaries
4344
# android is currently disabled, need to check NDK license if we can use it in CI
44-
config: [cross, proxy, accel, no_llvm_no_debug]
45+
config: [cross, proxy, accel, no_llvm_no_debug, only_lib]
4546

4647
steps:
4748
- name: Checkout
@@ -73,6 +74,8 @@ jobs:
7374
runCMake -DENABLE_ALMAIF_DEVICE=1 -DENABLE_ICD=0 -DENABLE_LOADABLE_DRIVERS=0 -DENABLE_LLVM=0 -DENABLE_HOST_CPU_DEVICES=0
7475
elif [ "${{ matrix.config }}" == "no_llvm_no_debug" ]; then
7576
runCMake -DHOST_DEVICE_BUILD_HASH=1234567 -DENABLE_LLVM=0 -DENABLE_ICD=0 -DENABLE_LOADABLE_DRIVERS=0 -DPOCL_DEBUG_MESSAGES:BOOL=OFF
77+
elif [ "${{ matrix.config }}" == "only_lib" ]; then
78+
runCMake -DHOST_DEVICE_BUILD_HASH=1234567 -DENABLE_LLVM=0 -DENABLE_ICD=0 -DENABLE_LLVM=0 -DENABLE_LOADABLE_DRIVERS=0 -DENABLE_EXAMPLES=0 -DENABLE_POCLCC=0
7679
elif [ "${{ matrix.config }}" == "proxy" ]; then
7780
runCMake -DENABLE_PROXY_DEVICE=1 -DENABLE_PROXY_DEVICE_INTEROP=1 -DENABLE_HOST_CPU_DEVICES=0 -DENABLE_LLVM=0 -DENABLE_ICD=0 -DENABLE_LOADABLE_DRIVERS=0 -DVISIBILITY_HIDDEN=0
7881
else

.github/workflows/build_remote.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138

139139
steps:
140140
- name: Checkout
141-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
141+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
142142

143143
- name: Load Env vars
144144
id: load-env
@@ -188,7 +188,7 @@ jobs:
188188

189189
steps:
190190
- name: Checkout
191-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
191+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
192192

193193
- name: Load Env vars
194194
id: load-env

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
# Initializes the CodeQL tools for scanning.
6868
- name: Initialize CodeQL
69-
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88
69+
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195
7070
with:
7171
languages: ${{ matrix.language }}
7272
build-mode: ${{ matrix.build-mode }}
@@ -94,6 +94,6 @@ jobs:
9494
exit 1
9595
9696
- name: Perform CodeQL Analysis
97-
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88
97+
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195
9898
with:
9999
category: "/language:${{matrix.language}}"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ jobs:
6969
# Upload the results to GitHub's code scanning dashboard (optional).
7070
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7171
- name: "Upload to code-scanning"
72-
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88
72+
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195
7373
with:
7474
sarif_file: results.sarif

CMakeLists.txt

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ macro(pass_through_cpack_vars)
107107
endmacro()
108108

109109
# don't allow implicit function declarations
110-
if(UNIX)
110+
if(UNIX OR MINGW)
111111
if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
112112
(CMAKE_C_COMPILER_ID STREQUAL "Clang") OR
113113
(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
@@ -404,10 +404,6 @@ if(ENABLE_LLVM_PLATFORM_SUPPORT)
404404
if(NOT ENABLE_LLVM)
405405
message(FATAL_ERROR "ENABLE_LLVM_PLATFORM_SUPPORT requires also ENABLE_LLVM")
406406
endif()
407-
if(ENABLE_LOADABLE_DRIVERS)
408-
message(WARNING "LLVM dynlibs implementation doesn't support loadable drivers, disabling.")
409-
set(ENABLE_LOADABLE_DRIVERS 0)
410-
endif()
411407
if(ENABLE_PRINTF_IMMEDIATE_FLUSH)
412408
message(WARNING "LLVM dynlibs implementation doesn't support printf() immediate flush, disabling.")
413409
set(ENABLE_PRINTF_IMMEDIATE_FLUSH 0)
@@ -494,11 +490,22 @@ set(COMMAND_USES_TERMINAL USES_TERMINAL)
494490

495491
include(GNUInstallDirs)
496492

497-
# for libpocl.so
498-
set(POCL_INSTALL_PUBLIC_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "POCL public libdir")
493+
# for (lib)pocl.(so|dll|dylib)
494+
if(WIN32)
495+
set(POCL_INSTALL_PUBLIC_LIBDIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "POCL public libdir")
496+
else()
497+
set(POCL_INSTALL_PUBLIC_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "POCL public libdir")
498+
endif()
499+
500+
# for (lib)pocl-devices-*.(so|dll|dylib)
501+
set(POCL_INSTALL_PRIVATE_LIBDIR "${POCL_INSTALL_PUBLIC_LIBDIR}/pocl" CACHE PATH "POCL private libdir")
499502

500-
# for libpocl-devices-*.so
501-
set(POCL_INSTALL_PRIVATE_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}/pocl" CACHE PATH "POCL private libdir")
503+
# for libpocl.(a|dll.a)
504+
if(WIN32)
505+
set(POCL_INSTALL_STATIC_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "POCL public libdir")
506+
else()
507+
set(POCL_INSTALL_STATIC_LIBDIR "${POCL_INSTALL_PUBLIC_LIBDIR}/static" CACHE PATH "POCL public libdir")
508+
endif()
502509

503510
# for pocl.icd
504511
set(POCL_INSTALL_ICD_VENDORDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/OpenCL/vendors" CACHE PATH "POCL ICD file destination")
@@ -742,7 +749,7 @@ endif()
742749

743750
######################################################################################
744751

745-
if(UNIX)
752+
if(UNIX OR MINGW)
746753
include(CheckCSourceCompiles)
747754
include(CheckSymbolExists)
748755

@@ -909,6 +916,10 @@ if(NOT DEFINED DEFAULT_ENABLE_IPO)
909916

910917
if(DEVELOPER_MODE)
911918
set(IPO 0)
919+
elseif(MINGW)
920+
# XXX: IPO on MinGW runs into linker errors (such as `two or more sections
921+
# for .gnu.lto__ZN4llvm12DenseMapInfoIPKNS_8MetadataEvE7isEqualES3_S3_.65576.2f694590`)
922+
set(IPO 0)
912923
else()
913924
include(CheckIPOSupported)
914925
check_ipo_supported(RESULT IPO OUTPUT IPO_OUTPUT)
@@ -1133,14 +1144,17 @@ endif()
11331144
######################################################################################
11341145

11351146
if(ENABLE_HOST_CPU_DEVICES AND PKG_CONFIG_FOUND AND NOT ENABLE_CONFORMANCE)
1147+
# PoCL requires libxsmm to support LIBXSMM_DATATYPE_F16, which was added after the
1148+
# 1.17 release. Until there is a new release, building libxsmm from git and
1149+
# manually updating the version number in version.txt before building is necessary.
11361150
if(BUILD_SHARED_LIBS)
1137-
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm-shared>=1.15)
1151+
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm-shared>1.17.0)
11381152
endif()
11391153
if(NOT LIBXSMM_FOUND)
1140-
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm-static>=1.15)
1154+
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm-static>1.17.0)
11411155
endif()
11421156
if(NOT LIBXSMM_FOUND)
1143-
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm>=1.15)
1157+
pkg_check_modules(LIBXSMM IMPORTED_TARGET libxsmm>1.17.0)
11441158
endif()
11451159

11461160
# libxsmm needs BLAS as fallback
@@ -1155,6 +1169,8 @@ if(LIBXSMM_FOUND AND TARGET BLAS::BLAS)
11551169
else()
11561170
set(HAVE_LIBXSMM 0)
11571171
message(STATUS "libxsmm or libblas not found, XSMM disabled")
1172+
message(STATUS "NOTE: If you meant to use a git build of libxsmm you may have to manually bump "
1173+
"the version in its version.txt before building.")
11581174
endif()
11591175

11601176
function(print_target_properties target)
@@ -1193,7 +1209,9 @@ if(ENABLE_HOST_CPU_DEVICES AND NOT ENABLE_CONFORMANCE)
11931209
set(HAVE_ONNXRT ON)
11941210
endif ()
11951211
else ()
1196-
find_package(onnxruntime QUIET)
1212+
# PoCL requires SetUserLoggingFunction which was introduced in 1.17,
1213+
# search for a version that is compatible with this.
1214+
find_package(onnxruntime 1.17 QUIET)
11971215
set(HAVE_ONNXRT ${onnxruntime_FOUND})
11981216
if (${HAVE_ONNXRT})
11991217
# TODO: this is a hack, just passing onnxruntime::onnxruntime
@@ -2177,9 +2195,11 @@ configure_file("cl_offline_compiler.sh.in.cmake" "cl_offline_compiler.sh.config.
21772195
rename_if_different(
21782196
"${CMAKE_BINARY_DIR}/cl_offline_compiler.sh.config.new"
21792197
"${CMAKE_BINARY_DIR}/cl_offline_compiler.sh.config" 1)
2180-
file(GENERATE
2181-
OUTPUT "${CMAKE_BINARY_DIR}/cl_offline_compiler.sh"
2182-
INPUT "${CMAKE_BINARY_DIR}/cl_offline_compiler.sh.config")
2198+
if(ENABLE_SPIRV)
2199+
file(GENERATE
2200+
OUTPUT "${CMAKE_BINARY_DIR}/cl_offline_compiler.sh"
2201+
INPUT "${CMAKE_BINARY_DIR}/cl_offline_compiler.sh.config")
2202+
endif()
21832203

21842204
include_directories("${CMAKE_BINARY_DIR}")
21852205

@@ -2226,7 +2246,7 @@ endif()
22262246

22272247
##########################################################
22282248

2229-
if(UNIX)
2249+
if(UNIX OR MINGW)
22302250
configure_file("${CMAKE_SOURCE_DIR}/pocl.pc.in.cmake" "${CMAKE_BINARY_DIR}/pocl.pc" @ONLY)
22312251
install(FILES "${CMAKE_BINARY_DIR}/pocl.pc"
22322252
DESTINATION "${POCL_INSTALL_PKGCONFIG_DIR}" COMPONENT "dev")
@@ -2296,7 +2316,7 @@ set(POCLU_LINK_OPTIONS poclu ${OPENCL_LIBS} ${LIBMATH})
22962316
message(STATUS "POCLU LINK OPTS: ${POCLU_LINK_OPTIONS}")
22972317

22982318
# poclcc bin
2299-
if(ENABLE_POCLCC)
2319+
if(ENABLE_POCLCC OR ENABLE_SPIRV)
23002320
add_subdirectory("bin")
23012321
endif()
23022322

0 commit comments

Comments
 (0)