Skip to content

Commit cff2ca4

Browse files
authored
Wrote setup.cfg (#11)
- moved some pyproject.toml configuration to setup.cfg - updated README.md - bumped version to 0.0.2
1 parent d0e5fd2 commit cff2ca4

File tree

5 files changed

+136
-66
lines changed

5 files changed

+136
-66
lines changed

README.md

+80-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,84 @@
11
# pykokkos-base
22

3+
This package contains the minimal set of bindings for [Kokkos](https://github.com/kokkos/kokkos)
4+
interoperability with Python:
5+
6+
- `Kokkos::initialize(...)`
7+
- `Kokkos::finalize()`
8+
- `Kokkos::View<...>`
9+
- `Kokkos::DynRankView<...>`
10+
11+
By importing this package in Python, you can pass the supported Kokkos Views and DynRankViews
12+
from C++ to Python and vice-versa. Furthermore, in Python, these bindings provide interoperability
13+
with numpy and cupy arrays:
14+
15+
```python
16+
import kokkos
17+
import numpy as np
18+
19+
view = kokkos.view([2, 2], dtype=kokkos.double, space=kokkos.CudaUVMSpace,
20+
layout=Kokkos.LayoutRight, trait=kokkos.RandomAccess,
21+
dynamic=False)
22+
23+
arr = np.array(view, copy=False)
24+
```
25+
26+
> This package depends on a pre-existing installation of Kokkos
27+
28+
## Writing Kokkos in Python
29+
30+
In order to write native Kokkos in Python, see [pykokkos](https://github.com/kokkos/pykokkos).
31+
32+
## Installation
33+
34+
You can install this package via CMake or Python's `setup.py`. There are two important cmake options:
35+
36+
- `ENABLE_LAYOUTS`
37+
- `ENABLE_MEMORY_TRAITS`
38+
39+
By default, CMake will enable these options if the Kokkos installation was not built with CUDA support.
40+
If Kokkos was built with CUDA support, these options will be disabled by default due to unreasonable
41+
compilation times (> 1 hour).
42+
43+
### Configuring Options via CMake
44+
45+
```console
46+
cmake -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF /path/to/source`
47+
```
48+
49+
### Configuring Options via `setup.py`
50+
51+
There are three ways to configure the options:
52+
53+
1. Via the Python argparse options `--enable-<option>` and `--disable-<option>`
54+
2. Setting the `PYKOKKOS_BASE_SETUP_ARGS` environment variable to the CMake options
55+
3. Passing in the CMake options after a `--`
56+
57+
All three lines below are equivalent:
58+
59+
```console
60+
python setup.py install --enable-layouts --disable-memory-traits
61+
PYKOKKOS_BASE_SETUP_ARGS="-DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF" python setup.py install
62+
python setup.py install -- -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF
63+
```
64+
65+
### Configuring Options via `pip`
66+
67+
Pip does not handle build options well. Thus, it is recommended to use the `PYKOKKOS_BASE_SETUP_ARGS`
68+
environment variable noted above. However, using the `--install-option` for pip is possible but
69+
each "space" must have it's own `--install-option`, e.g. all of the following are equivalent:
70+
All three lines below are equivalent:
71+
72+
```console
73+
pip install pykokkos-base --install-option=--enable-layouts --install-option=--disable-memory-traits
74+
pip install pykokkos-base --install-option=-- --install-option=-DENABLE_LAYOUTS=ON --install-option=-DENABLE_MEMORY_TRAITS=OFF
75+
pip install pykokkos-base --install-option={--enable-layouts,--disable-memory-traits}
76+
pip install pykokkos-base --install-option={--,-DENABLE_LAYOUTS=ON,-DENABLE_MEMORY_TRAITS=OFF}
77+
```
78+
79+
> `pip install pykokkos-base` will build against the latest release in the PyPi repository.
80+
> In order to pip install from this repository, use `pip install --user -e .`
81+
382
## Example
483

584
### Overview
@@ -17,7 +96,7 @@ This example is designed to emulate a work-flow where the user has code using Ko
1796
- This is the implementation of the user's code which returns a `Kokkos::View<double**, Kokkos::HostSpace>`
1897
- [ex-numpy.py](https://github.com/kokkos/kokkos-python/blob/main/examples/ex-numpy.py)
1998
- This is the "main"
20-
99+
21100
#### ex-numpy.py
22101

23102
```python

VERSION

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
0.0.1
2-
1+
0.0.2

pyproject.toml

-63
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,6 @@ requires = [
66
"cmake>=3.16",
77
]
88

9-
[metadata]
10-
name = "pykokkos-base"
11-
url = "http://github.com/kokkos/kokkos-python"
12-
download_url = "http://github.com/kokkos/kokkos-python.git"
13-
project_urls = "http://github.com/kokkos/kokkos-python.git"
14-
author = "Jonathan R. Madsen"
15-
author_email = "[email protected]"
16-
maintainer = "Jonathan R. Madsen"
17-
maintainer_email = "[email protected]"
18-
license = "BSD 3-Clause License"
19-
description = "Python bindings to Kokkos Views for data interop"
20-
keywords = [
21-
"kokkos",
22-
"parallelism",
23-
"performance",
24-
"performance portability",
25-
"gpu",
26-
"cuda",
27-
"hip",
28-
"rocm",
29-
"hpx",
30-
"openmp",
31-
"openmptarget",
32-
"sycl",
33-
"serial",
34-
]
35-
classifiers = [
36-
"Development Status :: 4 - Beta",
37-
"Environment :: GPU",
38-
"Environment :: GPU :: NVIDIA CUDA",
39-
"Intended Audience :: Developers",
40-
"Intended Audience :: Science/Research",
41-
"Natural Language :: English",
42-
"License :: OSI Approved :: BSD-3 License",
43-
"Operating System :: MacOS",
44-
"Operating System :: Microsoft :: Windows",
45-
"Operating System :: POSIX :: Linux",
46-
"Operating System :: POSIX :: BSD",
47-
"Operating System :: Unix",
48-
"Programming Language :: C++",
49-
"Programming Language :: Python :: 3",
50-
"Programming Language :: Python :: 3.6",
51-
"Programming Language :: Python :: 3.7",
52-
"Programming Language :: Python :: 3.8",
53-
"Programming Language :: Python :: 3.9",
54-
"Programming Language :: Python :: 3.10",
55-
"Topic :: Scientific/Engineering",
56-
]
57-
58-
[options]
59-
packages = [
60-
"kokkos",
61-
]
62-
zip_safe = false
63-
include_package_data = false
64-
setup_requires = [
65-
"scikit-build",
66-
"cmake>=3.16",
67-
]
68-
69-
[options.project_urls]
70-
kokkos = "https://github.com/kokkos/kokkos"
71-
729
[tool.black]
7310
line-length = 88
7411
target-version = ['py27', 'py35', 'py36', 'py37', 'py38']

setup.cfg

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[metadata]
2+
name = pykokkos-base
3+
url = http://github.com/kokkos/kokkos-python
4+
download_url = http://github.com/kokkos/kokkos-python.git
5+
project_urls = http://github.com/kokkos/kokkos-python.git
6+
author = Jonathan R. Madsen
7+
author_email = [email protected]
8+
maintainer = Jonathan R. Madsen
9+
maintainer_email = [email protected]
10+
license = BSD 3-Clause License
11+
description = Python bindings to Kokkos Views for data interop
12+
keywords =
13+
kokkos
14+
parallelism
15+
performance
16+
performance portability
17+
gpu
18+
cuda
19+
hip
20+
rocm
21+
hpx
22+
openmp
23+
openmptarget
24+
sycl
25+
serial
26+
classifiers =
27+
Development Status :: 4 - Beta
28+
Environment :: GPU
29+
Environment :: GPU :: NVIDIA CUDA
30+
Intended Audience :: Developers
31+
Intended Audience :: Science/Research
32+
Natural Language :: English
33+
License :: OSI Approved :: BSD License
34+
Operating System :: MacOS
35+
Operating System :: Microsoft :: Windows
36+
Operating System :: POSIX :: Linux
37+
Operating System :: POSIX :: BSD
38+
Operating System :: Unix
39+
Programming Language :: C++
40+
Programming Language :: Python :: 3
41+
Programming Language :: Python :: 3.6
42+
Programming Language :: Python :: 3.7
43+
Programming Language :: Python :: 3.8
44+
Programming Language :: Python :: 3.9
45+
Programming Language :: Python :: 3.10
46+
Topic :: Scientific/Engineering
47+
48+
[options]
49+
packages = kokkos
50+
zip_safe = false
51+
include_package_data = false
52+
setup_requires =
53+
scikit-build
54+
cmake>=3.16

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,5 @@ def gen_packages_items():
251251
long_description=get_long_description(),
252252
long_description_content_type="text/markdown",
253253
install_requires=parse_requirements("requirements.txt"),
254+
project_urls={"kokkos": "https://github.com/kokkos/kokkos"},
254255
)

0 commit comments

Comments
 (0)