Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
uses: mxschmitt/action-tmate@v3.13
if: ${{ inputs.debug_enabled }}
- name: Setup conda environment
id: setup_conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: libnomp
Expand All @@ -46,9 +45,13 @@ jobs:
id: cache
with:
path: ${{ env.NOMP_CONDA_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ hashFiles('requirements.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
key: >-
conda-
${{ runner.os }}-
${{ hashFiles('environment.yml') }}-
${{ hashFiles('requirements.txt') }}-
${{ env.NOMP_CACHE_NUMBER }}
- name: Update conda environment
id: update_env
run: |
conda env update -n libnomp -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -58,21 +61,16 @@ jobs:
path: ${{ env.NOMP_CONDA_ENV }}/lib/pocl
key: ${{ runner.os }}-build-pocl-${{ env.POCL_CACHE_NUMBER }}
- name: Install pocl
id: install_pocl
run: |
conda install -c conda-forge pocl
if: (steps.pocl_cache.outputs.cache-hit != 'true') || (steps.cache.outputs.cache-hit != 'true')
if: >-
steps.pocl_cache.outputs.cache-hit != 'true' ||
steps.cache.outputs.cache-hit != 'true'
- name: Build libnomp
id: build_libnomp
run: |
./lncfg --cc ${CC} \
--install-prefix ${NOMP_INSTALL_DIR} \
--prefix-path ${CONDA_PREFIX} \
--enable-opencl --opencl-lib ${CONDA_PREFIX}/lib/libOpenCL.so \
./bin/lnbld --enable-opencl --opencl-lib ${CONDA_PREFIX}/lib/libOpenCL.so \
--enable-tests
./lnbuild --install
- name: Run libnomp tests
id: run_libnomp
run: |
${NOMP_INSTALL_DIR}/bin/lnrun --test backend=opencl
- name: Block to allow inspecting failures
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ env.NOMP_CONDA_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
key: >-
conda-
${{ runner.os }}-
${{ hashFiles('environment-dev.yml') }}-
${{ hashFiles('requirements.txt') }}-
${{ hashFiles('requirements-dev.txt') }}-
${{ env.NOMP_CACHE_NUMBER }}
id: cache
- name: Update conda environment
id: update_env
Expand All @@ -50,8 +56,8 @@ jobs:
- name: Build documentation
id: build_docs
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX} --enable-docs
./lnbuild --install --update-shell
./bin/lnbld --install-dir ${NOMP_INSTALL_DIR} --enable-docs \
-DCMAKE_PREFIX_PATH=${CONDA_PREFIX}
- name: Bypass Jekyll
id: bypass_jekyll
if: ${{ fromJSON(env.PUSH_ON_MAIN) }}
Expand Down
36 changes: 9 additions & 27 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
uses: mxschmitt/action-tmate@v3.13
if: ${{ inputs.debug_enabled }}
- name: Setup conda environment
id: setup_conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: libnomp-dev
Expand All @@ -37,35 +36,18 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ env.NOMP_CONDA_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
key: >-
conda-
${{ runner.os }}-
${{ hashFiles('environment-dev.yml') }}-
${{ hashFiles('requirements.txt') }}-
${{ hashFiles('requirements-dev.txt') }}-
${{ env.NOMP_CACHE_NUMBER }}
id: cache
- name: Update conda environment
id: update_env
run: |
conda env update -n libnomp-dev -f environment-dev.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Run clang-format check
- name: Check formatting
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --format-check
- name: Run clang-tidy check
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
# FIXME: Skipping the clang-tidy checks for now.
# ./lnbuild --tidy-check
- name: Run pylint check
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --pylint-check
- name: Run black check
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --black-check
- name: Run isort check
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --isort-check
- name: Run flake8 check
run: |
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --flake8-check
./bin/lnchk --chk-fmt
62 changes: 2 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(SOURCES src/nomp.c src/loopy.c src/symengine.c src/aux.c src/log.c
src/reduction.c)
set(SOURCES src/nomp.c src/loopy.c src/symengine.c src/aux.c src/log.c src/reduction.c)
if (ENABLE_OPENCL)
find_package(OpenCL REQUIRED)
if (OpenCL_FOUND)
Expand Down Expand Up @@ -117,68 +116,11 @@ if (ENABLE_TESTS)
add_subdirectory(tests)
endif()

# Add clang-format as a custom target if available.
find_program(CLANG_FORMAT NAMES clang-format)
if (CLANG_FORMAT)
add_custom_target(format
COMMAND ${CLANG_FORMAT} -i ${CMAKE_SOURCE_DIR}/*/*.[ch]
COMMENT "Running clang-format ...")
add_custom_target(format-check
COMMAND ${CLANG_FORMAT} --dry-run --Werror -i ${CMAKE_SOURCE_DIR}/*/*.[ch]
COMMENT "Running clang-format check ...")
endif()

# Add clang-tidy as a custom target if available.
find_program(CLANG_TIDY NAMES clang-tidy)
if (CLANG_TIDY)
add_custom_target(tidy
COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/*/*.[ch]
COMMENT "Running clang-tidy ...")
endif()

# Add pylint as a custom target if available.
find_program(PYLINT NAMES pylint)
if (PYLINT)
add_custom_target(pylint
COMMAND ${PYLINT} ${CMAKE_SOURCE_DIR} --recursive yes --rcfile=${CMAKE_SOURCE_DIR}/pyproject.toml
COMMENT "Running pylint ...")
endif()

# Add black as a custom target if available.
find_program(BLACK NAMES black)
if (BLACK)
add_custom_target(black
COMMAND ${BLACK} ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Running black ...")
add_custom_target(black-check
COMMAND ${BLACK} --check ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Running black check ...")
endif()

# Add isort as a custom target if available.
find_program(ISORT NAMES isort)
if (ISORT)
add_custom_target(isort
COMMAND ${ISORT} ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Running isort ...")
add_custom_target(isort-check
COMMAND ${ISORT} --check-only ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Running isort check ...")
endif()

# Add flake8 as a custom target if available.
find_program(FLAKE8 NAMES flake8)
if (FLAKE8)
add_custom_target(flake8
COMMAND ${FLAKE8} ${CMAKE_CURRENT_SOURCE_DIR}/
COMMENT "Running flake8 ...")
endif()

install(TARGETS nomp LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/python DESTINATION ${CMAKE_INSTALL_PREFIX})

install(DIRECTORY scripts/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
install(DIRECTORY bin/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

Expand Down
82 changes: 82 additions & 0 deletions bin/lnbld
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Check for nomp environment variables.
: ${NOMP_BUILD_DIR:=${PWD}/build}
: ${NOMP_INSTALL_DIR:=${PWD}/install}
: ${NOMP_TARGET:=install}
: ${NOMP_ENABLE_OPENCL:="OFF"}
: ${NOMP_OPENCL_LIBRARY:=""}
: ${NOMP_OPENCL_INCLUDE_DIR:=""}
: ${NOMP_ENABLE_CUDA:="OFF"}
: ${NOMP_ENABLE_HIP:="OFF"}
: ${NOMP_ENABLE_DOCS:="OFF"}
: ${NOMP_ENABLE_TESTS:="OFF"}
: ${NOMP_ENABLE_ASAN:="OFF"}

# Terminal output colors.
red=$(tput setaf 1)
green=$(tput setaf 2)
cyan=$(tput setaf 6)
reset=$(tput sgr0)

# Print the options.
function print_help() {
echo -e "Usage: ${0} [--help] [--build-dir <build_dir>] " \
"[--install-dir <install_dir>] [--target <cmake_target>] " \
"[--enable-opencl] [--opencl-lib <opencl_lib_path>] " \
"[--opencl-headers <opencl_header_path>] [--enable-hip] [--enable-cuda] " \
"[--enable-docs] [--enable-tests] [--enable-asan]\n\n" \
"${cyan}--help ${reset}\tPrint this help and exit.\n" \
"${cyan}--build-dir ${reset}\tBuild directory.\n" \
"${cyan}--install-dir ${reset}\tInstall directory.\n" \
"${cyan}--target ${reset}\tCMake target to execute.\n" \
"${cyan}--enable-opencl ${reset}\tBuild with OpenCL backend" \
"${cyan}--opencl-lib ${reset}\tOpenCL library path.\n" \
"${cyan}--opencl-headers${reset}\tOpenCL header path.\n" \
"${cyan}--enable-hip ${reset}\tBuild with HIP backend\n" \
"${cyan}--enable-cuda ${reset}\tBuild with CUDA backend\n" \
"${cyan}--enable-docs ${reset}\tBuild user documentation\n" \
"${cyan}--enable-tests ${reset}\tBuild libnomp unit tests\n" \
"${cyan}--enable-asan ${reset}\tBuild with AddressSanitizer" \
exit 0
}

# Parse the options.
USER_OPTS=
while [ $# -gt 0 ]; do
case $1 in
--help) print_help ;;
--build-dir) shift && NOMP_BUILD_DIR=$1 ;;
--install-dir) shift && NOMP_INSTALL_DIR=$1 ;;
--target) shift && NOMP_TARGET=$1 ;;
--enable-opencl) NOMP_ENABLE_OPENCL="ON" ;;
--opencl-lib) shift && NOMP_OPENCL_LIBRARY=$(realpath "$1") ;;
--opencl-headers) shift && NOMP_OPENCL_INCLUDE_DIR=$(realpath "$1") ;;
--enable-hip) NOMP_ENABLE_HIP="ON" ;;
--enable-cuda) NOMP_ENABLE_CUDA="ON" ;;
--enable-docs) NOMP_ENABLE_DOCS="ON" ;;
--enable-tests) NOMP_ENABLE_TESTS="ON" ;;
--enable-asan) NOMP_ENABLE_ASAN="ON" ;;
*) USER_OPTS+=("$1") && shift ;;
esac
shift
done

# Update the cmake options.
NOMP_CMAKE_OPTS=("-S ${PWD} -B ${NOMP_BUILD_DIR}")
NOMP_CMAKE_OPTS+=("-DCMAKE_INSTALL_PREFIX=${NOMP_INSTALL_DIR}")
NOMP_CMAKE_OPTS+=("-DENABLE_HIP=${NOMP_ENABLE_HIP}")
NOMP_CMAKE_OPTS+=("-DENABLE_CUDA=${NOMP_ENABLE_CUDA}")
NOMP_CMAKE_OPTS+=("-DENABLE_OPENCL=${NOMP_ENABLE_OPENCL}")
[[ -n ${NOMP_OPENCL_LIBRARY} ]] &&
NOMP_CMAKE_OPTS+=("-DOpenCL_LIBRARY=${NOMP_OPENCL_LIBRARY}")
[[ -n ${NOMP_OPENCL_INCLUDE_DIR} ]] &&
NOMP_CMAKE_OPTS+=("-DOpenCL_INCLUDE_DIR=${NOMP_OPENCL_INCLUDE_DIR}")
NOMP_CMAKE_OPTS+=("-DENABLE_ASAN=${NOMP_ENABLE_ASAN}")
NOMP_CMAKE_OPTS+=("-DENABLE_DOCS=${NOMP_ENABLE_DOCS}")
NOMP_CMAKE_OPTS+=("-DENABLE_TESTS=${NOMP_ENABLE_TESTS}")

echo "cmake ${NOMP_CMAKE_OPTS[@]} ${USER_OPTS[@]}"
cmake ${NOMP_CMAKE_OPTS[@]} ${USER_OPTS[@]}
echo "cmake --build ${NOMP_BUILD_DIR} --target ${NOMP_TARGET}"
cmake --build ${NOMP_BUILD_DIR} --target ${NOMP_TARGET}
29 changes: 29 additions & 0 deletions bin/lnchk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e
set -o pipefail

: ${CLANG_FORMAT:=clang-format}

############################
# Don't touch what follows #
############################
CSRC=

if ! command -v $CLANG_FORMAT >/dev/null 2>&1; then
echo "Binary $CLANG_FORMAT not found!"
exit 1
fi

BINDIR=$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")
CSRC=$(find $BINDIR/.. -type f -name "*.[ch]")

if [[ "$1" == "--fmt" ]]; then
$CLANG_FORMAT -i $CSRC
ruff format .
elif [[ "$1" == "--chk-fmt" ]]; then
$CLANG_FORMAT --dry-run --Werror -i $CSRC
ruff format --check .
ruff check .
else
exit 1
fi
File renamed without changes.
Loading
Loading