Skip to content

Commit 23ac4ee

Browse files
committed
Initial commit with basic functionality and docs
0 parents  commit 23ac4ee

26 files changed

+1916
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
*.egg-info

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# pocky: A Python bridge to OpenCL

doc/_static/fonts/OpenSans-Bold.ttf

128 KB
Binary file not shown.
133 KB
Binary file not shown.

doc/_static/fonts/OpenSans-Italic.ttf

133 KB
Binary file not shown.
128 KB
Binary file not shown.

doc/_templates/base.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{% extends "!base.html" %}
2+
{% block linktags %}
3+
<link href="{{ pathto('_static/fonts/OpenSans-Regular.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
4+
<link href="{{ pathto('_static/fonts/OpenSans-Italic.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
5+
<link href="{{ pathto('_static/fonts/OpenSans-Bold.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
6+
<link href="{{ pathto('_static/fonts/OpenSans-BoldItalic.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
7+
<link href="{{ pathto('_static/fonts/SourceCodePro-Regular.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
8+
<link href="{{ pathto('_static/fonts/SourceCodePro-Italic.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
9+
<link href="{{ pathto('_static/fonts/SourceCodePro-Bold.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
10+
<link href="{{ pathto('_static/fonts/SourceCodePro-BoldItalic.ttf', 1) }}" rel="preload" as="font" type="font/ttf">
11+
{% endblock %}
12+
{% block extra_styles %}
13+
{{ super() }}
14+
<style>
15+
@font-face {
16+
font-family: 'Open Sans';
17+
src: url('{{ pathto('_static/fonts/OpenSans-Regular.ttf', 1) }}');
18+
font-weight: 400;
19+
font-style: normal;
20+
}
21+
@font-face {
22+
font-family: 'Open Sans';
23+
src: url('{{ pathto('_static/fonts/OpenSans-Italic.ttf', 1) }}');
24+
font-weight: 400;
25+
font-style: italic;
26+
}
27+
@font-face {
28+
font-family: 'Open Sans';
29+
src: url('{{ pathto('_static/fonts/OpenSans-Bold.ttf', 1) }}');
30+
font-weight: 700;
31+
font-style: normal;
32+
}
33+
@font-face {
34+
font-family: 'Open Sans';
35+
src: url('{{ pathto('_static/fonts/OpenSans-BoldItalic.ttf', 1) }}');
36+
font-weight: 700;
37+
font-style: italic;
38+
}
39+
.sidebar-brand-text {
40+
display: block;
41+
font-size: 4rem;
42+
}
43+
</style>
44+
{% endblock %}

doc/conf.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
3+
import os
4+
import textwrap
5+
import furiosa
6+
7+
import sys
8+
sys.path.append('../build/src/module')
9+
10+
# -- Project information -----------------------------------------------------
11+
12+
project = 'pocky'
13+
copyright = '2024, Ellen M. Price'
14+
author = '@emprice'
15+
16+
# The full version, including alpha/beta/rc tags
17+
release = '1.0'
18+
19+
# -- General configuration ---------------------------------------------------
20+
21+
# Add any Sphinx extension module names here, as strings. They can be
22+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
23+
# ones.
24+
extensions = ['furiosa', 'breathe', 'exhale', 'sphinx.ext.todo',
25+
'sphinx.ext.autodoc', 'sphinx.ext.napoleon']
26+
27+
root_dir = os.environ['ROOT_DIR']
28+
29+
breathe_projects = { 'pocky' : './doxygen/xml' }
30+
breathe_default_project = 'pocky'
31+
breathe_domain_by_extension = { 'h' : 'c', 'cl' : 'c' }
32+
breathe_implementation_filename_extensions = ['c']
33+
breathe_show_define_initializer = True
34+
breathe_show_enumvalue_initializer = True
35+
breathe_separate_member_pages = False
36+
37+
stdin = textwrap.dedent(f'''\
38+
OUTPUT_LANGUAGE = English
39+
EXTENSION_MAPPING = h=C cl=C
40+
EXCLUDE_PATTERNS += *.txt *.c *.py
41+
INPUT = {root_dir}/src
42+
RECURSIVE = YES
43+
QUIET = YES
44+
PREDEFINED += DOXYGEN_SHOULD_SKIP_THIS
45+
ENABLE_PREPROCESSING = YES
46+
OPTIMIZE_OUTPUT_FOR_C = YES
47+
''')
48+
49+
exhale_args = { 'containmentFolder' : './exhale',
50+
'rootFileName' : 'lowlevel.rst', 'rootFileTitle' : 'Low-level C API',
51+
'createTreeView' : True, 'exhaleExecutesDoxygen' : True,
52+
'contentsDirectives' : False, 'doxygenStripFromPath' : root_dir,
53+
'lexerMapping' : { r'.*\.h' : 'c', r'.*\.cl' : 'c' },
54+
'exhaleDoxygenStdin' : stdin }
55+
56+
smartquotes = True
57+
primary_domain = None
58+
todo_include_todos = True
59+
highlight_language = 'default'
60+
61+
html_title = 'pocky'
62+
63+
bibtex_bibfiles = []
64+
bibtex_default_style = 'unsrt'
65+
bibtex_reference_style = 'label'
66+
67+
templates_path = ['_templates']
68+
exclude_patterns = []
69+
70+
# -- Options for HTML output -------------------------------------------------
71+
72+
html_theme = 'furiosa'
73+
pygments_style = 'nordlight'
74+
pygments_dark_style = 'norddark'
75+
76+
html_static_path = ['_static']
77+
78+
html_theme_options = {
79+
'light_css_variables': {
80+
'font-stack': '\'Open Sans\', sans-serif'
81+
},
82+
'dark_css_variables': {
83+
'font-stack': '\'Open Sans\', sans-serif'
84+
}
85+
}

doc/highlevel.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
High-level Python API
2+
=====================
3+
4+
OpenCL interface
5+
----------------
6+
7+
Platforms
8+
^^^^^^^^^
9+
10+
.. autoclass:: pocky.Platform
11+
:members:
12+
13+
14+
.. autofunction:: pocky.list_all_platforms
15+
16+
17+
Devices
18+
^^^^^^^
19+
20+
.. autoclass:: pocky.Device
21+
:members:
22+
23+
24+
.. autofunction:: pocky.list_all_devices
25+
26+
27+
Contexts
28+
^^^^^^^^
29+
30+
.. autoclass:: pocky.Context
31+
:members:
32+
33+
34+
.. autofunction:: pocky.context_default
35+
36+
37+
.. autofunction:: pocky.context_from_devices
38+
39+
40+
Buffers
41+
^^^^^^^
42+
43+
.. autoclass:: pocky.BufferPair
44+
:members:
45+

doc/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pocky
2+
=====
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Contents:
7+
8+
highlevel
9+
exhale/lowlevel
10+
11+
Indices and tables
12+
==================
13+
14+
* :ref:`genindex`
15+
* :ref:`modindex`
16+
* :ref:`search`

doc/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Sphinx
2+
exhale
3+
breathe
4+
furiosa @ git+https://github.com/emprice/furiosa.git@main

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools",
5+
"numpy",
6+
]
7+
8+
[project]
9+
name = "pocky"
10+
version = "1.0"
11+
requires-python = ">=3.10"
12+
13+
[tool.setuptools]
14+
include-package-data = false
15+
16+
[tool.setuptools.packages.find]
17+
namespaces = true
18+
where = ["src"]
19+
20+
[tool.setuptools.package-data]
21+
"pocky.ext" = ["include/*.h"]

setup.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import numpy as np
3+
from setuptools import Extension, setup
4+
5+
source_dir = 'src/pocky/ext'
6+
include_dir = 'src/pocky/ext/include'
7+
8+
source_files = ['pocky.c', 'bufpair.c', 'context.c',
9+
'functions.c', 'helpers.c', 'utils.c']
10+
source_files = [os.path.join(source_dir, fname) for fname in source_files]
11+
12+
header_files = ['pocky.h', 'bufpair.h', 'context.h',
13+
'functions.h', 'helpers.h', 'utils.h']
14+
header_files = [os.path.join(include_dir, fname) for fname in header_files]
15+
16+
ext_modules = [
17+
Extension(name='pocky.ext', sources=source_files, libraries=['OpenCL'],
18+
define_macros=[('CL_TARGET_OPENCL_VERSION', '300')], language='c',
19+
include_dirs=[include_dir, np.get_include()], depends=header_files)
20+
]
21+
setup(ext_modules=ext_modules)

src/pocky/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .ext import *
2+
3+
def get_include():
4+
import os
5+
import pocky.ext as ext
6+
return os.path.join(os.path.dirname(ext.__file__), 'ext/include')

0 commit comments

Comments
 (0)