Skip to content

Commit d3adc98

Browse files
committed
Add transpiler tests to GitHub CI
1 parent b8ccf73 commit d3adc98

File tree

1 file changed

+79
-50
lines changed

1 file changed

+79
-50
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ jobs:
4444
FC: gfortran
4545
OCCA_FORTRAN_ENABLED: 1
4646
useCMake: true
47+
useTranspiler: true
4748

4849
- name: "[Ubuntu] CMake + clang"
4950
os: ubuntu-latest
5051
CC: clang
5152
CXX: clang++
5253
CXXFLAGS: -Wno-uninitialized
5354
useCMake: true
55+
useTranspiler: true
5456

5557
- name: "[Ubuntu] CMake + Intel/LLVM"
5658
os: ubuntu-latest
@@ -62,6 +64,7 @@ jobs:
6264
OCCA_FORTRAN_ENABLED: 1
6365
useCMake: true
6466
useoneAPI: true
67+
useTranspiler: true
6568

6669
runs-on: ${{ matrix.os }}
6770
name: ${{ matrix.name }}
@@ -76,6 +79,9 @@ jobs:
7679
OCCA_COVERAGE: ${{ matrix.OCCA_COVERAGE }}
7780
OCCA_FORTRAN_ENABLED: ${{ matrix.OCCA_FORTRAN_ENABLED }}
7881
FORTRAN_EXAMPLES: ${{ matrix.OCCA_FORTRAN_ENABLED }}
82+
TRANSPILER_VERSION: 1.1
83+
TRANSPILER_CACHE_NUMBER: 0 # Increase to reset cache manually.
84+
7985

8086
steps:
8187
- uses: actions/checkout@v4
@@ -87,7 +93,16 @@ jobs:
8793
- name: Set OCCA install directory
8894
run: echo "OCCA_INSTALL_DIR=${PWD}/install" >> ${GITHUB_ENV}
8995

90-
- name: add oneAPI to apt
96+
- name: Setup environment variables for oneAPI
97+
if: ${{ matrix.useoneAPI }}
98+
run: echo "USE_ONEAPI=1" >> ${GITHUB_ENV}
99+
100+
- name: Setup environment variables for transpiler
101+
if: ${{ matrix.useTranspiler }}
102+
run: |
103+
echo "USE_TRANSPILER=1" >> ${GITHUB_ENV}
104+
105+
- name: Install oneAPI dpcpp compiler
91106
if: ${{ matrix.useoneAPI }}
92107
shell: bash
93108
run: |
@@ -97,38 +112,54 @@ jobs:
97112
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
98113
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
99114
100-
- name: install oneAPI dpcpp compiler
101-
if: ${{ matrix.useoneAPI }}
102-
shell: bash
103-
run: |
104115
sudo apt update
105116
sudo apt install intel-oneapi-compiler-dpcpp-cpp
106117
sudo apt install intel-oneapi-compiler-fortran
107118
108-
- name: Compiler info
119+
- name: Install llvm toolchain for transpiler
120+
if: ${{ matrix.useTranspiler }}
121+
shell: bash
122+
run: |
123+
wget https://raw.githubusercontent.com/opencollab/llvm-jenkins.debian.net/master/llvm.sh
124+
chmod +x llvm.sh
125+
sudo ./llvm.sh 17 all
126+
127+
- name: Cache transpiler install directory
128+
if: ${{ matrix.useTranspiler }}
129+
uses: actions/cache@v3
130+
id: cache
131+
with:
132+
path: occa-transpiler-${{ env.TRANSPILER_VERSION }}/install
133+
key: transpiler-${{ runner.os }}-${{ env.CXX }}-${{ env.CC }}-${{ hashFiles('.github/workflows/build.yml') }}-${{ env.TRANSPILER_CACHE_NUMBER }}
134+
135+
- name: Download and install transpiler
136+
if: ${{ matrix.useTranspiler && (steps.cache.outputs.cache-hit != 'true' ) }}
137+
shell: bash
138+
run: |
139+
if [ ! -z ${USE_ONEAPI+x} ] && [ "${USE_ONEAPI}" -eq 1 ]; then
140+
source /opt/intel/oneapi/setvars.sh
141+
fi
142+
143+
wget https://github.com/libocca/occa-transpiler/releases/download/v${TRANSPILER_VERSION}/occa-transpiler-${TRANSPILER_VERSION}-including-submodules.tar.gz
144+
tar -zxvf occa-transpiler-${TRANSPILER_VERSION}-including-submodules.tar.gz
145+
cd occa-transpiler-${TRANSPILER_VERSION}
146+
mkdir -p build
147+
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install -DCMAKE_CXX_FLAGS="-Wall"
148+
cmake --build build --target install --parallel 8
149+
150+
- name: Print compiler info for GNU Make
109151
if: ${{ !matrix.useCMake }}
110152
run: make PREFIX=${OCCA_INSTALL_DIR} -j 16 info
111153

112154
- name: CMake configure
113-
if: ${{ matrix.useCMake && !matrix.useoneAPI}}
155+
if: ${{ matrix.useCMake }}
114156
run: |
115-
cmake -S . -B build \
116-
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
117-
-DCMAKE_INSTALL_PREFIX=${OCCA_INSTALL_DIR} \
118-
-DCMAKE_C_COMPILER=${CC} \
119-
-DCMAKE_CXX_COMPILER=${CXX} \
120-
-DCMAKE_Fortran_COMPILER=${FC} \
121-
-DOCCA_ENABLE_TESTS=ON \
122-
-DOCCA_ENABLE_EXAMPLES=ON \
123-
-DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED}
157+
if [ ! -z ${USE_ONEAPI+x} ] && [ "${USE_ONEAPI}" -eq 1 ]; then
158+
source /opt/intel/oneapi/setvars.sh
159+
export OCCA_CC=${{ matrix.CC }}
160+
export OCCA_CXX=${{ matrix.CXX }}
161+
fi
124162
125-
- name: CMake configure
126-
if: ${{ matrix.useCMake && matrix.useoneAPI}}
127-
env:
128-
OCCA_CC: ${{ matrix.CC }}
129-
OCCA_CXX: ${{ matrix.CXX }}
130-
run: |
131-
source /opt/intel/oneapi/setvars.sh
132163
cmake -S . -B build \
133164
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
134165
-DCMAKE_INSTALL_PREFIX=${OCCA_INSTALL_DIR} \
@@ -138,29 +169,26 @@ jobs:
138169
-DOCCA_ENABLE_TESTS=ON \
139170
-DOCCA_ENABLE_EXAMPLES=ON \
140171
-DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED}
141-
142-
- name: CMake build and install
143-
if: ${{ matrix.useCMake && !matrix.useoneAPI}}
144-
run: |
145-
cmake --build build --target install --parallel 16
146-
147-
- name: CMake build and install
148-
if: ${{ matrix.useCMake && matrix.useoneAPI}}
149-
env:
150-
OCCA_CC: ${{ matrix.CC }}
151-
OCCA_CXX: ${{ matrix.CXX }}
152-
run: |
153-
source /opt/intel/oneapi/setvars.sh
154-
cmake --build build --target install --parallel 16
155172
156-
- name: Compile library and install
173+
- name: Build library with GNU Make
157174
if: ${{ !matrix.useCMake }}
158175
run: make -j 16
159176

160-
- name: Compile tests
177+
- name: Build tests with GNU Make
161178
if: ${{ !matrix.useCMake }}
162179
run: make -j 16 tests
163180

181+
- name: Build and install library with CMake
182+
if: ${{ matrix.useCMake }}
183+
run: |
184+
if [ ! -z ${USE_ONEAPI+x} ] && [ "${USE_ONEAPI}" -eq 1 ]; then
185+
source /opt/intel/oneapi/setvars.sh
186+
export OCCA_CC=${{ matrix.CC }}
187+
export OCCA_CXX=${{ matrix.CXX }}
188+
fi
189+
190+
cmake --build build --target install --parallel 16
191+
164192
- name: Run unit tests
165193
if: ${{ !matrix.useCMake }}
166194
run: ./tests/run_tests
@@ -170,20 +198,21 @@ jobs:
170198
run: ./tests/run_examples
171199

172200
- name: Run CTests
173-
if: ${{ matrix.useCMake && !matrix.useoneAPI }}
174-
run: |
175-
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "examples_cpp_arrays-opencl|examples_cpp_for_loops-opencl|examples_cpp_generic_inline_kernel-opencl|examples_cpp_shared_memory-opencl|examples_cpp_nonblocking_streams-opencl|examples_cpp_for_loops-dpcpp|examples_cpp_arrays-dpcpp|examples_cpp_generic_inline_kernel-dpcpp|examples_cpp_nonblocking_streams-dpcpp"
176-
177-
- name: Run CTests
178-
if: ${{ matrix.useCMake && matrix.useoneAPI }}
201+
if: ${{ matrix.useCMake }}
179202
env:
180-
OCCA_CC: ${{ matrix.CC }}
181-
OCCA_CXX: ${{ matrix.CXX }}
182203
OCCA_DPCPP_COMPILER: icpx
183204
run: |
184-
source /opt/intel/oneapi/setvars.sh
185-
export ONEAPI_DEVICE_SELECTOR=*:cpu
186-
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "opencl-*|dpcpp-*"
205+
if [ ! -z ${USE_ONEAPI+x} ] && [ "${USE_ONEAPI}" -eq 1 ]; then
206+
source /opt/intel/oneapi/setvars.sh
207+
export ONEAPI_DEVICE_SELECTOR=*:cpu
208+
export OCCA_CC=${{ matrix.CC }}
209+
export OCCA_CXX=${{ matrix.CXX }}
210+
exclude_list="opencl-*|dpcpp-*"
211+
else
212+
exclude_list="examples_cpp_arrays-opencl|examples_cpp_for_loops-opencl|examples_cpp_generic_inline_kernel-opencl|examples_cpp_shared_memory-opencl|examples_cpp_nonblocking_streams-opencl|examples_cpp_for_loops-dpcpp|examples_cpp_arrays-dpcpp|examples_cpp_generic_inline_kernel-dpcpp|examples_cpp_nonblocking_streams-dpcpp"
213+
fi
214+
215+
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E ${exclude_list}
187216
188217
- name: Upload code coverage
189218
if: ${{ matrix.OCCA_COVERAGE }}

0 commit comments

Comments
 (0)