-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the options data class to program #237
base: main
Are you sure you want to change the base?
Changes from all commits
6d789cb
66ceb85
37a945c
3555e2e
1fc1189
a9ac448
944bc1a
d490af2
0394877
b6e3eac
6790c83
a8f8e3a
401ab75
7d5b894
1789a84
2285fac
bb62048
d43500f
0f0ca9b
47c416d
c41821f
53b8198
58f2b09
7afe54e
653a3e1
5161a43
dfd894e
f461eec
236db71
2f74ca3
710d8e7
9c88ba7
133f6aa
cb06afc
3578f94
261588c
2b9e94a
1abc9f6
d20dcfa
79fad7a
b87044b
6959689
ec9fac1
f55dcdc
dfe194f
b41d119
de588de
2fbca70
b79dccc
d1e4e09
bf32370
85c0e47
34c8780
cc25960
e4786b2
d913e0a
06c68b4
3a747f6
b1345f8
5dc8c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -87,6 +87,13 @@ def check_or_create_options(cls, options, options_description, *, keep_none=Fals | |||||
return options | ||||||
|
||||||
|
||||||
def _handle_boolean_option(option: bool) -> str: | ||||||
""" | ||||||
Convert a boolean option to a string representation. | ||||||
""" | ||||||
return "true" if bool(option) else "false" | ||||||
|
||||||
|
||||||
def precondition(checker: Callable[..., None], what: str = "") -> Callable: | ||||||
""" | ||||||
A decorator that adds checks to ensure any preconditions are met. | ||||||
|
@@ -134,3 +141,17 @@ def get_device_from_ctx(ctx_handle) -> int: | |||||
assert ctx_handle == handle_return(cuda.cuCtxPopCurrent()) | ||||||
handle_return(cuda.cuCtxPushCurrent(prev_ctx)) | ||||||
return device_id | ||||||
|
||||||
|
||||||
def is_list_or_tuple(obj): | ||||||
""" | ||||||
Check if the given object is a sequence (list or tuple). | ||||||
""" | ||||||
return isinstance(obj, (list, tuple)) | ||||||
|
||||||
|
||||||
def is_nested_list_or_tuple(obj): | ||||||
""" | ||||||
Check if the given object is a nested sequence (list or tuple with atleast one list or tuple element). | ||||||
""" | ||||||
return is_list_or_tuple(obj) and any(is_list_or_tuple(elem) for elem in obj) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto, also, it should be
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think perhaps I should take this out of utils and leave it in program if it is too specific, but to handle the case in question it should be any imo, since I would like to support define_macro = ("MY_MACRO", ("MY_OTHER_MACRO", 99)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ CUDA compilation toolchain | |
|
||
:template: dataclass.rst | ||
|
||
ProgramOptions | ||
LinkerOptions | ||
|
||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Release Notes | ||
============= | ||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
release/0.2.0-notes | ||
release/0.1.1-notes | ||
release/0.1.0-notes |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# `cuda.core` v0.1.0 Release notes | ||
``cuda.core`` 0.1.0 Release Notes | ||
================================= | ||
|
||
Released on Nov 8, 2024 | ||
|
||
## Hightlights | ||
Highlights | ||
---------- | ||
|
||
- Initial beta release | ||
- Supports all platforms that CUDA is supported | ||
- Supports all CUDA 11.x/12.x drivers | ||
- Supports all CUDA 11.x/12.x Toolkits | ||
- Pythonic CUDA runtime and other core functionalities | ||
|
||
## Limitations | ||
Limitations | ||
----------- | ||
|
||
- All APIs are currently *experimental* and subject to change without deprecation notice. | ||
Please kindly share your feedbacks with us so that we can make `cuda.core` better! | ||
Please kindly share your feedback with us so that we can make ``cuda.core`` better! | ||
- Source code release only; `pip`/`conda` support is coming in a future release | ||
- Windows TCC mode is [not yet supported](https://github.com/NVIDIA/cuda-python/issues/206) | ||
- Windows TCC mode is `not yet supported <https://github.com/NVIDIA/cuda-python/issues/206>`_ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.. currentmodule:: cuda.core.experimental | ||
|
||
``cuda.core`` 0.1.1 Release Notes | ||
================================= | ||
|
||
Released on Dec 20, 2024 | ||
|
||
Highlights | ||
---------- | ||
|
||
- Add :obj:`~utils.StridedMemoryView` and :func:`~utils.args_viewable_as_strided_memory` that provide a concrete | ||
implementation of DLPack & CUDA Array Interface supports. | ||
- Add :obj:`~Linker` that can link one or multiple :obj:`~_module.ObjectCode` instances generated by :obj:`~Program`. Under | ||
the hood, it uses either the nvJitLink or driver (``cuLink*``) APIs depending on the CUDA version | ||
detected in the current environment. | ||
- Support ``pip install cuda-core``. Please see the Installation Guide for further details. | ||
|
||
New features | ||
------------ | ||
|
||
- Add a :obj:`cuda.core.experiemental.system` module for querying system- or process-wide information. | ||
- Add :obj:`~LaunchConfig.cluster` to support thread block clusters on Hopper GPUs. | ||
|
||
Enhancements | ||
------------ | ||
|
||
- The internal handle held by :obj:`~_module.ObjectCode` is now lazily initialized upon first touch. | ||
- Support TCC devices with a default synchronous memory resource to avoid the use of memory pools. | ||
- Ensure ``"ltoir"`` is a valid code type to :obj:`~_module.ObjectCode`. | ||
- Document the ``__cuda_stream__`` protocol. | ||
- Improve test coverage & documentation cross-references. | ||
- Enforce code formatting. | ||
|
||
Bug fixes | ||
--------- | ||
|
||
- Eliminate potential class destruction issues. | ||
- Fix circular import during handling a foreign CUDA stream. | ||
|
||
Limitations | ||
----------- | ||
|
||
- All APIs are currently *experimental* and subject to change without deprecation notice. | ||
Please kindly share your feedback with us so that we can make ``cuda.core`` better! | ||
- Using ``cuda.core`` with NVRTC or nvJitLink installed from PyPI via `pip install` is currently | ||
not supported. This will be fixed in a future release. | ||
- Some :class:`~LinkerOptions` are only available when using a modern version of CUDA. When using CUDA <12, | ||
the backend is the cuLink API which supports only a subset of the options that nvjitlink does. | ||
Further, some options aren't available on CUDA versions <12.6. | ||
- To use ``cuda.core`` with Python 3.13, it currently requires building ``cuda-python`` from source | ||
prior to `pip install`. This extra step will be fixed soon. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.. currentmodule:: cuda.core.experimental | ||
|
||
``cuda.core`` 0.2.0 Release Notes | ||
================================= | ||
|
||
Released on <TODO>, 2024 | ||
|
||
Highlights | ||
---------- | ||
|
||
- Add :class:`~ProgramOptions` to facilitate the passing of runtime compile options to :obj:`~Program`. | ||
|
||
Limitations | ||
----------- | ||
|
||
- <TODO> | ||
|
||
Breaking Changes | ||
---------------- | ||
|
||
- The :meth:`~Program.compile` method no longer accepts the `options` argument. Instead, you can optionally pass an instance of :class:`~ProgramOptions` to the constructor of :obj:`~Program`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Couldn't we just use
isinstance(obj, Sequence)
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no because a string is a sequence. That's what I originally wanted to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was why I left #237 (comment) and #237 (comment) above.
str
is a nested sequence by our definition, because any of its elements is also astr
. If we checkisinstance(something, str)
first to special case it, the remaining checks can be simplified and not specialized for any known container (list/tuple).