Skip to content

Commit

Permalink
Merge pull request #101 from minyez/main
Browse files Browse the repository at this point in the history
Improve Intel cmake compiler flags
  • Loading branch information
gonzex authored Mar 22, 2024
2 parents 14410ce + fcd819c commit 6134aa7
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 11 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: CI Tests

on: [push, pull_request]

env:
# for cache install
LINUX_ONEAPI_COMPONENTS: intel-oneapi-compiler-fortran:intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic:intel-oneapi-mpi:intel-oneapi-mpi-devel:intel-oneapi-mkl

jobs:
GNU:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -63,3 +67,92 @@ jobs:
# propagate env vars between steps in Github Actions
env:
GX_BUILD_DIR: "/home/runner/work/greenX/greenX/build"

intel-oneapi:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [{cc: icx, cxx: icpx, fc: ifx}, {cc: icc, cxx: icpc, fc: ifort}]
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
FC: ${{ matrix.compiler.fc }}

steps:
- name: Intel Apt repository
timeout-minutes: 1
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
# dump dependencies of oneAPI components
echo "$LINUX_ONEAPI_COMPONENTS" | sed "s/:/ /g" | xargs -n 1 apt-cache depends | tee depends.txt
- name: Cache install
timeout-minutes: 2
id: cache-install
uses: actions/cache@v3
with:
path: /opt/intel/oneapi/
key: install-${{ env.LINUX_ONEAPI_COMPONENTS }}-${{ hashFiles('**/depends.txt') }}

- name: Install Intel oneAPI
timeout-minutes: 5
if: steps.cache-install.outputs.cache-hit != 'true'
run: |
sudo apt-get install $(echo "$LINUX_ONEAPI_COMPONENTS" | sed 's/:/ /g')
- name: Install ninja-build
run: |
sudo apt-get install ninja-build
- name: checkout project code
uses: actions/checkout@v2

- name: Setup Intel oneAPI environment
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- uses: actions/setup-python@v1
with:
python-version: '3.7'

- name: Install Cmake
run: pip3 install cmake

- name: Install python dependencies
run: pip3 install numpy pytest

- name: Install Zofu Test Framework
run: |
mkdir -p external && cd external
git clone https://github.com/acroucher/zofu.git
mkdir zofu/build && cd zofu/build
cmake \
-DCMAKE_BUILD_TYPE=release \
-DCMAKE_INSTALL_PREFIX=/home/runner/work/greenX/greenX/external/zofu/install \
-DZOFU_FORTRAN_MODULE_INSTALL_DIR:PATH=include \
..
make -j 4
make install
- name: Build
run: |
mkdir -p build
cd build
cmake -DENABLE_UNITTESTS=ON -DZOFU_PATH=/home/runner/work/greenX/greenX/external/zofu/install ../
make -j$(nproc) VERBOSE=1
- name: Run Tests
run: |
cd python && pip install -e . && cd ../
cd build
ctest -j1 --output-on-failure
# The build system exports GX_BUILD_DIR, but I do not know how to
# propagate env vars between steps in Github Actions
env:
GX_BUILD_DIR: "/home/runner/work/greenX/greenX/build"
2 changes: 2 additions & 0 deletions GX-AnalyticContinuation/src/test_pade_approximant.f90
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ subroutine test_pade(test)
ref = cmplx(0.5, -0.5, dp)
f_approx = pade(n, x, f, xx)

write(*,'(A6,2F24.16)') " Ref: ", ref
write(*,'(A6,2F24.16)') "Test: ", f_approx
call test%assert(is_close(f_approx, ref, tol=tol), name = 'Test pade ~ -1 / (x - x0)')

end subroutine test_pade
Expand Down
27 changes: 16 additions & 11 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@
# CMake will append CMAKE_Fortran_FLAGS with CMAKE_Fortran_FLAGS_BUILDTYPE
# CMAKE_Fortran_FLAGS_BUILDTYPE may also have predefined values, hence initialise it

# Standard flags to use in all cases
set(STD_FFLAGS
-std='f2008' # Fortran standard set to 2008
-fimplicit-none # Specify that no implicit typing is allowed
-ffree-line-length-0 # No fixed line length
)
string(REPLACE ";" " " STD_FFLAGS "${STD_FFLAGS}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${STD_FFLAGS}")


# GCC
set(GCC_BASE
-std='f2008' # Fortran standard set to 2008
-fimplicit-none # Specify that no implicit typing is allowed
-ffree-line-length-0 # No fixed line length
)
set(GCC_DEBUG
-g # Generate symbols
-fbacktrace # symbolic stack traceback
Expand All @@ -23,10 +18,15 @@ set(GCC_DEBUG
set(GCC_RELEASE -O3) # Level 3 optimisation. Could also consider -fpack-derived

# Intel
set(INTEL_BASE
-stand f08 # Set standard to Fortran 2008 and warn for non-standard language elements
-implicitnone # Set the default type of a variable to undefined
-diag-disable=5268 # Remove warning: Extension to standard: The text exceeds right hand column allowed on the line.
-free # Specify free-fortmat
)
set(INTEL_DEBUG
-g # Generate symbols
-traceback # symbolic stack traceback
-fp # Disables the ebp register in optimizations and sets the ebp register to be used as the frame pointer.
-check all # Checks for all runtime failures.
-check bounds # Generates code to perform runtime checks on array subscript and character substring expressions.
-check-uninit # Enables runtime checking for uninitialized variables.
Expand All @@ -42,10 +42,12 @@ set(INTEL_RELEASE
)

if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(FF_BASE ${GCC_BASE})
set(FF_DEBUG ${GCC_DEBUG})
set(FF_RELEASE ${GCC_RELEASE})

elseif (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(FF_BASE ${INTEL_BASE})
set(FF_DEBUG ${INTEL_DEBUG})
set(FF_RELEASE ${INTEL_RELEASE})

Expand All @@ -54,9 +56,12 @@ else ()
${CMAKE_Fortran_COMPILER_ID}")
endif()

string(REPLACE ";" " " FF_BASE "${FF_BASE}")
string(REPLACE ";" " " FF_DEBUG "${FF_DEBUG}")
string(REPLACE ";" " " FF_RELEASE "${FF_RELEASE}")

# Standard flags to use in all cases
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FF_BASE}")
# Initialise BUILDTYPE flags so we completely define/control
# the compiler settings
set(CMAKE_Fortran_FLAGS_DEBUG "${FF_DEBUG}")
Expand Down

0 comments on commit 6134aa7

Please sign in to comment.