Skip to content

Commit 37dd16a

Browse files
committed
init
0 parents  commit 37dd16a

File tree

17 files changed

+1348
-0
lines changed

17 files changed

+1348
-0
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
build_wheels:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-14]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install system dependencies (Linux)
23+
if: runner.os == 'Linux'
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y cmake build-essential libopenblas-dev
27+
28+
- name: Install system dependencies (Windows)
29+
if: runner.os == 'Windows'
30+
run: |
31+
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' --yes
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
37+
38+
- name: Install uv
39+
if: runner.os == 'macOS' || runner.os == 'Windows'
40+
run: python -m pip install uv
41+
42+
- name: Install cibuildwheel
43+
run: python -m pip install --upgrade pip cibuildwheel
44+
45+
- name: Build wheels
46+
run: python -m cibuildwheel --output-dir wheelhouse
47+
env:
48+
CIBW_BUILD: "cp310-* cp311-* cp312-*"
49+
CIBW_ARCHS_LINUX: "x86_64"
50+
CIBW_SKIP: "*musllinux*"
51+
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '14.0' || '13.0' }}
52+
CIBW_ARCHS_WINDOWS: "AMD64"
53+
CIBW_TEST_COMMAND: ""
54+
- name: Upload wheels as artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: wheels-${{ matrix.os }}
58+
path: wheelhouse/*.whl

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install build dependencies
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y cmake build-essential
30+
31+
- name: Install Python dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r requirements.txt
35+
36+
- name: Build and install the package
37+
run: |
38+
pip install .
39+
40+
- name: Run tests
41+
run: |
42+
pytest

.gitignore

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Using https://github.com/github/gitignore/blob/master/Python.gitignore
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
share/python-wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
*.py,cover
52+
.hypothesis/
53+
.pytest_cache/
54+
cover/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
docs/_generate/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
101+
__pypackages__/
102+
103+
# Celery stuff
104+
celerybeat-schedule
105+
celerybeat.pid
106+
107+
# SageMath parsed files
108+
*.sage.py
109+
110+
# Environments
111+
.env
112+
.venv
113+
env/
114+
venv/
115+
ENV/
116+
env.bak/
117+
venv.bak/
118+
119+
# Spyder project settings
120+
.spyderproject
121+
.spyproject
122+
123+
# Rope project settings
124+
.ropeproject
125+
126+
# mkdocs documentation
127+
/site
128+
129+
# mypy
130+
.mypy_cache/
131+
.dmypy.json
132+
dmypy.json
133+
134+
# Pyre type checker
135+
.pyre/
136+
137+
# pytype static type analyzer
138+
.pytype/
139+
140+
# Cython debug symbols
141+
cython_debug/
142+
143+
_skbuild/
144+
.pyodide-xbuildenv/
145+
146+
CMakeFiles/
147+
.DS_Store
148+
venv/
149+
bin/
150+
share/
151+
lib/
152+
include/
153+
lib64/

CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.15...3.27)
2+
set(CMAKE_CXX_STANDARD 17)
3+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
5+
project(${SKBUILD_PROJECT_NAME}
6+
VERSION ${SKBUILD_PROJECT_VERSION}
7+
LANGUAGES CXX)
8+
9+
find_package(CUDAToolkit)
10+
if(CUDAToolkit_FOUND)
11+
enable_language(CUDA)
12+
set(USE_CUDA ON)
13+
message(STATUS "CUDA enabled")
14+
else()
15+
set(USE_CUDA OFF)
16+
message(STATUS "CUDA not found, building without CUDA support")
17+
endif()
18+
19+
# Find Python, pybind11, and TBB
20+
find_package(Python 3.12 REQUIRED COMPONENTS Interpreter Development.Module)
21+
find_package(pybind11 CONFIG REQUIRED)
22+
23+
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
24+
25+
# Determine the XLA include directory via Python
26+
# set(Python_EXECUTABLE /opt/anaconda3/envs/perm/bin/python3.12)
27+
execute_process(
28+
COMMAND "${Python_EXECUTABLE}" "-c" "from jax import ffi; print(ffi.include_dir())"
29+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE XLA_DIR)
30+
message(STATUS "XLA include directory: ${XLA_DIR}")
31+
32+
#Create the Python module using the collected sources
33+
python_add_library(_core MODULE src/main.cpp WITH_SOABI)
34+
# target_link_libraries(_core PUBLIC TBB::tbb)
35+
target_link_libraries(_core PRIVATE pybind11::headers)
36+
37+
# Include XLA headers and pass in the version info
38+
target_include_directories(_core PUBLIC ${XLA_DIR})
39+
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
40+
41+
# #Install the module to the desired output directory
42+
install(TARGETS _core DESTINATION sooki)
43+
44+
if(USE_CUDA)
45+
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
46+
pybind11_add_module(
47+
gpu_ops
48+
${CMAKE_CURRENT_LIST_DIR}/src/kernels.cc.cu
49+
${CMAKE_CURRENT_LIST_DIR}/src/gpu_ops.cc)
50+
target_include_directories(gpu_ops PRIVATE ${XLA_DIR})
51+
install(TARGETS gpu_ops DESTINATION sooki)
52+
endif()

0 commit comments

Comments
 (0)