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
4 changes: 1 addition & 3 deletions .github/workflows/array_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ jobs:
python -m pip install --upgrade pip
python -m pip install --upgrade numpy mypy==1.0.1 cmake pytest pybind11 scikit-build patchelf tqdm
- name: Install pykokkos-base
working-directory: base
run: |
cd /tmp
git clone https://github.com/kokkos/pykokkos-base.git
cd pykokkos-base
python setup.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DENABLE_VIEW_RANKS=5
- name: Install pykokkos
run: |
Expand Down
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
4 changes: 1 addition & 3 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ jobs:
python -m pip install --upgrade pip
python -m pip install --upgrade numpy mypy==1.0.1 cmake pytest pybind11 scikit-build patchelf
- name: Install pykokkos-base
working-directory: base
run: |
cd /tmp
git clone https://github.com/kokkos/pykokkos-base.git
cd pykokkos-base
python setup.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DENABLE_VIEW_RANKS=5
- name: Install pykokkos
run: |
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ jobs:
cmake --build .
cmake --install .
- name: Install pykokkos-base
working-directory: base
run: |
cd /tmp
git clone https://github.com/kokkos/pykokkos-base.git
cd pykokkos-base
python setup.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DKokkos_DIR=/tmp/kokkos_install/lib/cmake/Kokkos/ -DENABLE_INTERNAL_KOKKOS=OFF
- name: Install pykokkos
run: |
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,38 @@ https://kokkos.github.io/pykokkos/index.html

## Installation

Please follow the instructions at:
### Quick Start

PyKokkos consists of two components that need to be installed separately:

1. **pykokkos-base** (C++ bindings to Kokkos)
2. **pykokkos** (Python translation layer)

#### Installing pykokkos-base

```bash
# Clone the repository
git clone https://github.com/kokkos/pykokkos.git
cd pykokkos/

# Create and activate conda environment
conda create --name pyk --file base/requirements.txt python=3.11
conda activate pyk

# Install pykokkos-base from the root directory
python install_base.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DENABLE_VIEW_RANKS=3 -DENABLE_CUDA=ON -DENABLE_THREADS=OFF -DENABLE_OPENMP=ON
```

#### Installing pykokkos

After installing pykokkos-base:

```bash
# Install pykokkos (ensure you're in the pyk environment)
pip install -e .
```

For more detailed installation instructions, please visit:
https://kokkos.github.io/pykokkos/installation.html

## Citation
Expand Down
Loading