Skip to content
Open
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
24 changes: 24 additions & 0 deletions .github/workflows/base-cancelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "[Base] Cancel Builds on Update"
on:
workflow_run:
workflows: ['[Base] Linux CI', '[Base] Python Package']
types: ['requested']

jobs:
cancel-duplicate-workflow-runs:
name: "Cancel duplicate workflow runs"
strategy:
matrix:
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: potiuk/cancel-workflow-runs@master
name: "Cancel duplicate workflow runs"
with:
cancelMode: duplicates
cancelFutureDuplicates: true
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
notifyPRCancel: true
skipEventTypes: '["schedule"]'
201 changes: 201 additions & 0 deletions .github/workflows/base-linux-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: "[Base] Linux CI"

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
paths:
- 'base/**'
- '.github/workflows/base-linux-ci.yml'

env:
BUILD_TYPE: Release

jobs:
cmake-build:
strategy:
matrix:
python-version: [3.11, 3.12, 3.13]
kokkos-branch: ['release-candidate-4.7.01']
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Update container
run:
sudo apt-get update &&
sudo apt-get install -y build-essential gcc g++ ninja-build &&
python -m pip install --upgrade pip &&
python -m pip install 'cmake==3.22.0'

- name: Install Kokkos
run:
git clone -b ${{ matrix.kokkos-branch }} https://github.com/kokkos/kokkos.git /tmp/kokkos-source &&
cmake -B /tmp/kokkos-build
-DKokkos_ENABLE_SERIAL=ON
-DKokkos_ENABLE_OPENMP=OFF
-DBUILD_SHARED_LIBS=ON
/tmp/kokkos-source &&
cmake --build /tmp/kokkos-build --target all --parallel 2 &&
sudo cmake --build /tmp/kokkos-build --target install --parallel 2

- name: Configure CMake
run:
python -m pip install -r base/requirements.txt &&
python -m pip install pytest &&
cmake -B ${{github.workspace}}/base/build
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DENABLE_LAYOUTS=OFF
-DENABLE_MEMORY_TRAITS=OFF
-DENABLE_EXAMPLES=ON
-DENABLE_WERROR=ON
-DENABLE_PRECOMPILED_HEADERS=ON
-DPython3_EXECUTABLE=$(which python)
${{github.workspace}}/base

- name: Build
run:
cmake --build ${{github.workspace}}/base/build --target all --parallel 2 &&
sudo cmake --build ${{github.workspace}}/base/build --target install --parallel 2

- name: Import Test
working-directory: ${{github.workspace}}/base/build
run:
mkdir -p scratch &&
cd scratch &&
export PYTHONPATH=/usr/local/lib/python${{ matrix.python-version }}/site-packages:${PYTHONPATH} &&
DEBUG_OUTPUT=ON python -c "import kokkos; print(kokkos.__file__)"

- name: Test
working-directory: ${{github.workspace}}/base/build
run:
export PYTHONPATH=${PWD}:/usr/local/lib/python${{ matrix.python-version }}/site-packages:${PYTHONPATH} &&
ls &&
pytest . &&
python ./ex-numpy.py

pip-build:
strategy:
matrix:
python-version: [3.11, 3.12, 3.13]
kokkos-branch: ['release-candidate-4.7.01']
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
defaults:
run:
working-directory: base
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Update container
run:
sudo apt-get update &&
sudo apt-get install -y build-essential gcc g++ ninja-build &&
python -m pip install --upgrade pip &&
python -m pip install 'cmake==3.22.0'

- name: Install Kokkos
run:
git clone -b ${{ matrix.kokkos-branch }} https://github.com/kokkos/kokkos.git /tmp/kokkos-source &&
cmake -B /tmp/kokkos-build
-DKokkos_ENABLE_SERIAL=ON
-DKokkos_ENABLE_THREADS=ON
-DCMAKE_CXX_STANDARD=20
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
/tmp/kokkos-source &&
cmake --build /tmp/kokkos-build --target all --parallel 2 &&
sudo cmake --build /tmp/kokkos-build --target install --parallel 2

- name: Build
run:
python -m pip install -r requirements.txt &&
python -m pip install pytest &&
CMAKE_BUILD_PARALLEL_LEVEL=2 PYKOKKOS_BASE_SETUP_ARGS="-DENABLE_WERROR=ON -DENABLE_MEMORY_TRAITS=ON -DENABLE_LAYOUTS=ON -DENABLE_VIEW_RANKS=2 -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_THREADS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF"
python -m pip install -v --user --no-deps .

- name: Import Test
run:
mkdir -p scratch &&
cd scratch &&
DEBUG_OUTPUT=ON python -c "import kokkos; print(kokkos.__file__)"

- name: Test
working-directory: base/scratch
run:
python -m kokkos.test

subproject:
strategy:
matrix:
python-version: [3.11, 3.12, 3.13]
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Update container
run:
sudo apt-get update &&
sudo apt-get install -y build-essential gcc g++ ninja-build &&
python -m pip install --upgrade pip &&
python -m pip install 'cmake==3.22.0'

- name: Generate CMakeLists.txt
run: |
echo -e "cmake_minimum_required(VERSION 3.22.0 FATAL_ERROR)\nproject(pykokkos-base-as-subproject LANGUAGES CXX)\nadd_subdirectory(base)" > ${{github.workspace}}/CMakeLists.txt
cat ${{github.workspace}}/CMakeLists.txt

- name: Configure CMake
run:
python -m pip install -r base/requirements.txt &&
python -m pip install pytest &&
cmake -B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DENABLE_LAYOUTS=OFF
-DENABLE_MEMORY_TRAITS=OFF
-DENABLE_VIEW_RANKS=1
-DENABLE_EXAMPLES=ON
-DENABLE_WERROR=ON
-DENABLE_SERIAL=ON
-DENABLE_OPENMP=ON
-DBUILD_SHARED_LIBS=ON
-DPYTHON_EXECUTABLE=$(which python)
-DPython3_EXECUTABLE=$(which python)
${{github.workspace}}

- name: Build
run:
cmake --build ${{github.workspace}}/build --target all --parallel 2 &&
sudo cmake --build ${{github.workspace}}/build --target install --parallel 2

- name: Setup PYTHONPATH
run:
echo "PYTHONPATH=/usr/local/lib/python${{ matrix.python-version }}/site-packages:${PYTHONPATH}" >> $GITHUB_ENV

- name: Import Test
run:
DEBUG_OUTPUT=ON python -c "import kokkos; print(kokkos.__file__)"

- name: Test
run:
python -m kokkos.test
89 changes: 89 additions & 0 deletions .github/workflows/base-python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: "[Base] Python Package"

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
paths:
- 'base/**'
- '.github/workflows/base-python-package.yml'

jobs:
linting:
strategy:
matrix:
python-version: [3.11, 3.12, 3.13]
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f base/requirements.txt ]; then pip install -r base/requirements.txt; fi
- name: Lint with flake8
working-directory: base
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# flake8 options are defined in setup.cfg
flake8 . --count --statistics

formatting:
strategy:
matrix:
python-version: [3.13]
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
if [ -f base/requirements.txt ]; then pip install -r base/requirements.txt; fi
# Add LLVM key and install clang-16
sudo apt-get update
sudo apt-get install -y software-properties-common wget gnupg
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb http://apt.llvm.org/${DISTRIB_CODENAME}/ llvm-toolchain-${DISTRIB_CODENAME}-16 main" | sudo tee /etc/apt/sources.list.d/llvm-16.list
if sudo apt-get update 2>&1 | grep -q "llvm-toolchain-${DISTRIB_CODENAME}-16"; then
echo "LLVM repository added successfully"
fi
if sudo apt-get install -y clang-format-16 2>/dev/null; then
echo "Installed clang-format-16"
echo "CLANG_FORMAT=clang-format-16" >> $GITHUB_ENV
fi
- name: black format
working-directory: base
run: |
black --diff --check .
- name: clang-format
working-directory: base
run: |
set +e
FILES=$(find include src examples -type f | egrep '\.hpp$|\.cpp$|\.cpp\.in$')
FORMAT_OUT=$($CLANG_FORMAT -output-replacements-xml ${FILES})
RET=$(echo ${FORMAT_OUT} | grep -c '<replacement ')
if [ "${RET}" -ne 0 ]; then
echo -e "\nError! Code not formatted. Detected ${RET} lines\n"
$CLANG_FORMAT -i ${FILES}
git diff
exit ${RET}
fi
50 changes: 50 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will install Python formatting tool black and check correctness of code format for all python files
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: python-package

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
formatting:
strategy:
matrix:
python-version: [3.13]
os: [ubuntu-latest, ubuntu-22.04]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install black
# - name: black format
# run: |
# black --diff --check .
- name: Check files end with newline
run: |
# Find all files (excluding binary and git files) and check if they end with a newline
EXIT_CODE=0
while IFS= read -r -d '' file; do
# Skip __init__.py files (should not end with newline)
if [[ "$file" == *"__init__.py" ]]; then
continue
fi
# Skip binary files
if file "$file" | grep -q "text"; then
# Check if file ends with a newline
if [ -n "$(tail -c 1 "$file")" ]; then
echo "ERROR: $file does not end with a newline"
EXIT_CODE=1
fi
fi
done < <(find . -type f -not -path '*/\.git/*' -print0)
exit $EXIT_CODE
9 changes: 9 additions & 0 deletions base/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Official Tool: clang-format version 8.0.0
BasedOnStyle: google
SortIncludes: true
IndentPPDirectives: AfterHash
AlignConsecutiveAssignments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
InsertNewlineAtEOF: true
LineEnding: LF
Loading