Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lncfg, lnbuild and lnrun scripts #281

Merged
merged 5 commits into from
Apr 6, 2024
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
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ on:
required: false
default: false
env:
# Increase to reset cache manually
CACHE_NUMBER: 0
LIBNOMP_ENV: /usr/share/miniconda/envs/libnomp
INSTALLDIR: install
POCL_CACHE_NUMBER: 0
NOMP_CONDA_ENV: /usr/share/miniconda/envs/libnomp
NOMP_INSTALL_DIR: ${{ github.workspace }}/install
NOMP_CACHE_NUMBER: 0 # Increase to reset cache manually.
POCL_CACHE_NUMBER: 0 # Increase to reset cache manually.
jobs:
ci:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,8 +45,8 @@ jobs:
uses: actions/cache@v3
id: cache
with:
path: ${{ env.LIBNOMP_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ hashFiles('requirements.txt') }}-${{ env.CACHE_NUMBER }}
path: ${{ env.NOMP_CONDA_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ hashFiles('requirements.txt') }}-${{ env.NOMP_CACHE_NUMBER }}
- name: Update conda environment
id: update_env
run: |
Expand All @@ -56,7 +55,7 @@ jobs:
- uses: actions/cache@v3
id: pocl_cache
with:
path: ${{ env.LIBNOMP_ENV }}/lib/pocl
path: ${{ env.NOMP_CONDA_ENV }}/lib/pocl
key: ${{ runner.os }}-build-pocl-${{ env.POCL_CACHE_NUMBER }}
- name: Install pocl
id: install_pocl
Expand All @@ -67,15 +66,15 @@ jobs:
id: build_libnomp
run: |
./lncfg --cc ${CC} \
--install-prefix ${INSTALLDIR} \
--install-prefix ${NOMP_INSTALL_DIR} \
--prefix-path ${CONDA_PREFIX} \
--enable-opencl --opencl-lib ${CONDA_PREFIX}/lib/libOpenCL.so \
--enable-tests
./lnbuild --install --update-shell
./lnbuild --install
- name: Run libnomp tests
id: run_libnomp
run: |
${INSTALLDIR}/bin/lnrun test --backend opencl
${NOMP_INSTALL_DIR}/bin/lnrun --test backend=opencl
- name: Block to allow inspecting failures
run: sleep 30m
if: ${{ failure() && inputs.debug_enabled }}
18 changes: 9 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
required: false
default: false
env:
# Increase to reset cache manually
CACHE_NUMBER: 0
LIBNOMP_ENV: /usr/share/miniconda/envs/libnomp-dev
INSTALLDIR: install
NOMP_CONDA_ENV: /usr/share/miniconda/envs/libnomp-dev
NOMP_INSTALL_DIR: ${{ github.workspace }}/install
NOMP_CACHE_NUMBER: 0 # Increase to reset cache manually.
POCL_CACHE_NUMBER: 0 # Increase to reset cache manually.
jobs:
docs:
runs-on: ubuntu-latest
Expand All @@ -39,8 +39,8 @@ jobs:
- name: Cache conda environment
uses: actions/cache@v3
with:
path: ${{ env.LIBNOMP_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.CACHE_NUMBER }}
path: ${{ env.NOMP_CONDA_ENV }}
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,21 +50,21 @@ jobs:
- name: Build documentation
id: build_docs
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX} --enable-docs
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX} --enable-docs
./lnbuild --install --update-shell
- name: Bypass Jekyll
id: bypass_jekyll
if: ${{ fromJSON(env.PUSH_ON_MAIN) }}
run: |
cd ${INSTALLDIR}/docs && touch .nojekyll
cd ${NOMP_INSTALL_DIR}/docs && touch .nojekyll
- name: Deploy to gh-pages
id: deploy
if: ${{ fromJSON(env.PUSH_ON_MAIN) }}
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ${{ env.INSTALLDIR }}/docs
FOLDER: ${{ env.NOMP_INSTALL_DIR }}/docs
- name: Block to allow inspecting failures
run: sleep 30m
if: ${{ failure() && inputs.debug_enabled }}
23 changes: 11 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ on:
required: false
default: false
env:
# Increase to reset cache manually
CACHE_NUMBER: 0
LIBNOMP_ENV: /usr/share/miniconda/envs/libnomp-dev
INSTALLDIR: install
NOMP_CONDA_ENV: /usr/share/miniconda/envs/libnomp-dev
NOMP_INSTALL_DIR: ${{ github.workspace }}/install
NOMP_CACHE_NUMBER: 0 # Increase to reset cache manually.
jobs:
lint-check:
runs-on: ubuntu-latest
Expand All @@ -37,8 +36,8 @@ jobs:
- name: Cache conda environment
uses: actions/cache@v3
with:
path: ${{ env.LIBNOMP_ENV }}
key: conda-${{ runner.os }}-${{ hashFiles('environment-dev.yml') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ env.CACHE_NUMBER }}
path: ${{ env.NOMP_CONDA_ENV }}
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 @@ -47,26 +46,26 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
- name: Run clang-format check
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --format-check
- name: Run clang-tidy check
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./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 ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --pylint-check
- name: Run black check
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --black-check
- name: Run isort check
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --isort-check
- name: Run flake8 check
run: |
./lncfg --install-prefix ${INSTALLDIR} --prefix-path ${CONDA_PREFIX}
./lncfg --install-prefix ${NOMP_INSTALL_DIR} --prefix-path ${CONDA_PREFIX}
./lnbuild --flake8-check
28 changes: 16 additions & 12 deletions lnbuild
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,22 @@ fi

function print_help() {
echo -e "Usage: ${0} [options]\n" \
"${cyan}--help:${reset} Print help for lnbuild script.\n" \
"${cyan}--install ${reset} Install libnomp.\n" \
"${cyan}--format ${reset} Format C code using clang-format.\n" \
"${cyan}--format-check ${reset} Check if C code is formatted correctly.\n" \
"${cyan}--tidy-check ${reset} Run clang-tidy to perform static analysis on C source.\n" \
"${cyan}--black ${reset} Format python code using black.\n" \
"${cyan}--black-check ${reset} Check if python code is formatted correctly.\n" \
"${cyan}--isort ${reset} Run isort to format python imports.\n" \
"${cyan}--isort-check ${reset} Check if python imports are formatted correctly.\n" \
"${cyan}--flake8-check ${reset} Run flake8 tests on python source.\n" \
"${cyan}--pylint-check ${reset} Run pylint to perform static analysis on python source.\n" \
"${cyan}--update-shell ${reset} Update shell configuration file.\n"
"${cyan}--help ${reset}\tPrint help for lnbuild script.\n" \
"${cyan}--install ${reset}\tInstall libnomp.\n" \
"${cyan}--format ${reset}\tFormat C code using clang-format.\n" \
"${cyan}--format-check ${reset}\tCheck if C code is formatted correctly.\n" \
"${cyan}--tidy-check ${reset}\tRun clang-tidy to perform static" \
"analysis on C source.\n" \
"${cyan}--black ${reset}\tFormat python code using black.\n" \
"${cyan}--black-check ${reset}\tCheck if python code is formatted" \
"correctly.\n" \
"${cyan}--isort ${reset}\tRun isort to format python imports.\n" \
"${cyan}--isort-check ${reset}\tCheck if python imports are formatted" \
"correctly.\n" \
"${cyan}--flake8-check ${reset}\tRun flake8 tests on python source.\n" \
"${cyan}--pylint-check ${reset}\tRun pylint to perform static analysis" \
"on python source.\n" \
"${cyan}--update-shell ${reset}\tUpdate shell configuration file."
}

# Read in command line arguments.
Expand Down
53 changes: 33 additions & 20 deletions lncfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
: "${NOMP_BUILD_DIR:="${NOMP_SOURCE_DIR}/build"}"
: "${NOMP_INSTALL_DIR:="${HOME}/.nomp/libnomp"}"
: "${NOMP_PREFIX_PATH:=""}"
: "${NOMP_BUILD_TYPE:="RelWithDebInfo"}"
: "${NOMP_BUILD_TYPE:="Release"}"
: "${NOMP_ENABLE_OPENCL:="OFF"}"
: "${NOMP_OPENCL_LIBRARY:=""}"
: "${NOMP_OPENCL_INCLUDE_DIR:=""}"
Expand All @@ -26,26 +26,39 @@ reset=$(tput sgr0)

# Print the options.
function print_help() {
echo -e "Usage: ${0} [--help] [--cc <c compiler>] [--cxx <cxx compiler>] " \
"[--build-type <build type>] [--build-dir <build directory>] [--install-prefix <install directory>] " \
"[--prefix-path <cmake prefix path>] [--enable-hip] [--enable-cuda] [--enable-opencl] " \
"[--opencl-lib <opencl library path>] [--opencl-headers <opencl header path>] [--enable-docs]\n\n" \
"${cyan}--help:${reset} Print this help and exit.\n" \
"${cyan}--cc:${reset} C Compiler.\n" \
"${cyan}--cflags:${reset} C Compiler flags.\n" \
"${cyan}--build-type:${reset} Build type (Default: ${NOMP_BUILD_TYPE}, " \
echo -e "Usage: ${0} [--help] --cc <c_compiler> [-cflags <c_flags>]" \
"[--install-prefix <install_directory>]\n" \
"[--build-type <build_type>] [--build-dir <build_directory>]" \
"[--prefix-path <cmake_prefix_path>]\n" \
"[--enable-opencl] [--opencl-lib <opencl_library_path>]" \
"[--opencl-headers <opencl_header_path>]\n" \
"[--enable-hip] [--enable-cuda] [--enable-docs] [--enable-tests]" \
"[--enable-asan]\n\n" \
"${cyan}--help ${reset}\tPrint this help and exit.\n" \
"${cyan}--cc ${reset}\tC Compiler.\n" \
"${cyan}--cflags ${reset}\tC Compiler flags.\n" \
"${cyan}--install-prefix${reset}\tInstall directory" \
"(Default: ${NOMP_INSTALL_DIR}).\n" \
"${cyan}--build-type ${reset}\tBuild type (Default: ${NOMP_BUILD_TYPE}," \
"Allowed: Debug, Release, RelWithDebInfo and MinSizeRel).\n" \
"${cyan}--build-dir:${reset} Build directory (Default: ${NOMP_BUILD_DIR}).\n" \
"${cyan}--install-prefix:${reset} Install directory (Default: ${NOMP_INSTALL_DIR}).\n" \
"${cyan}--prefix-path:${reset} Semicolon separated list of prefix paths for CMake.\n" \
"${cyan}--enable-hip:${reset} Build with HIP backend (Default: ${NOMP_ENABLE_HIP}).\n" \
"${cyan}--enable-cuda:${reset} Build with CUDA backend (Default: ${NOMP_ENABLE_CUDA}).\n" \
"${cyan}--enable-opencl:${reset} Build with OpenCL backend (Default: ${NOMP_ENABLE_OPENCL}).\n" \
"${cyan}--opencl-lib:${reset} OpenCL library path.\n" \
"${cyan}--opencl-headers:${reset} OpenCL header path.\n" \
"${cyan}--enable-asan:${reset} Build user documentation (Default: ${NOMP_ENABLE_ASAN}).\n" \
"${cyan}--enable-docs:${reset} Build user documentation (Default: ${NOMP_ENABLE_DOCS}).\n" \
"${cyan}--enable-tests:${reset} Build libnomp unit tests (Default: ${NOMP_ENABLE_TESTS})."
"${cyan}--build-dir ${reset}\tBuild directory" \
"(Default: ${NOMP_BUILD_DIR}).\n" \
"${cyan}--prefix-path ${reset}\tSemicolon separated list of prefix paths" \
"for CMake.\n" \
"${cyan}--enable-opencl ${reset}\tBuild with OpenCL backend" \
"(Default: ${NOMP_ENABLE_OPENCL}).\n" \
"${cyan}--opencl-lib ${reset}\tOpenCL library path.\n" \
"${cyan}--opencl-headers${reset}\tOpenCL header path.\n" \
"${cyan}--enable-hip ${reset}\tBuild with HIP backend" \
"(Default: ${NOMP_ENABLE_HIP}).\n" \
"${cyan}--enable-cuda ${reset}\tBuild with CUDA backend" \
"(Default: ${NOMP_ENABLE_CUDA}).\n" \
"${cyan}--enable-docs ${reset}\tBuild user documentation" \
"(Default: ${NOMP_ENABLE_DOCS}).\n" \
"${cyan}--enable-tests ${reset}\tBuild libnomp unit tests" \
"(Default: ${NOMP_ENABLE_TESTS}).\n" \
"${cyan}--enable-asan ${reset}\tBuild with AddressSanitizer" \
"(Default: ${NOMP_ENABLE_ASAN})."
exit 0
}

Expand Down
Loading
Loading