Skip to content
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

Change kernel_t construction pattern to fit other wrapper classes #285

Closed
eyalroz opened this issue Dec 10, 2021 · 1 comment
Closed

Change kernel_t construction pattern to fit other wrapper classes #285

eyalroz opened this issue Dec 10, 2021 · 1 comment

Comments

@eyalroz
Copy link
Owner

eyalroz commented Dec 10, 2021

Most of our wrappers aren't directly constructible, and use a wrap() function for construction from simpler/lower-level values. We should do this for kernel_t's as well. This will, in particular, clarify that such construction does not involve any API calls or other work.

@eyalroz eyalroz added the task label Dec 10, 2021
@eyalroz eyalroz self-assigned this Dec 10, 2021
eyalroz added a commit that referenced this issue Dec 11, 2021
* For #284: Introduced a grid-and-block-dimensions structure, `grid::complete_dimensions_t`. Using it when returning both grid and block dimensions instead of an `std::pair`; it has equals
* For #285: Changed the construction pattern for `kernel_t`:
  * Dropped the templated, wrapping, direct constructor.
  * Added `kernel::detail_::wrap()` taking a device ID and an arbitrary (function) pointer, and a `kernel::wrap()` taking a device ID and type-erased `const void*` pointer.
  * Made the lower-level `wrap()` a friend of the `kernel_t` class.
* Now using the default destructor for `kernel_t`'s (has nothing to do with the construction changes).
* Spacing tweaks.
* Comment typo fixes.
* Added not-equal operators for launch configurations
* Added some comments to some `#endif`'s, reminding the reader of the condition used in the `#if` of `#ifdef`.
* Made some narrowing casts explicit, to clarify their intentionality to static analysis tool.
* Added two aliases to the sync/async boolean enum in `cuda::stream`
* A bit of comment rephrasing

Example program changes:

* Adapted examples for the use of `grid::complete_dimensions_t`.
* Now creating wrapped kernels using `cuda::kernel::wrap()` rather than by direct construction.
* Spacing tweaks.
* Changes to the `cudaChooseDevice()` function in `helper_cuda.h`; mainly:
  * Now returning a `cuda::device_t`
  * No longer making the returned device current. In particular, that means that `simpleStreams.cu` may now be using a device that's not the current one.
@eyalroz
Copy link
Owner Author

eyalroz commented Dec 11, 2021

Done for the driver-wrappers branch too.

eyalroz added a commit that referenced this issue Dec 13, 2021
* For #284: Introduced a grid-and-block-dimensions structure, `grid::complete_dimensions_t`. Using it when returning both grid and block dimensions instead of an `std::pair`; it has equals
* For #285: Changed the construction pattern for `kernel_t`:
  * Dropped the templated, wrapping, direct constructor.
  * Added `kernel::detail_::wrap()` taking a device ID and an arbitrary (function) pointer, and a `kernel::wrap()` taking a device ID and type-erased `const void*` pointer.
  * Made the lower-level `wrap()` a friend of the `kernel_t` class.
* Now using the default destructor for `kernel_t`'s (has nothing to do with the construction changes).
* Spacing tweaks.
* Comment typo fixes.
* Added not-equal operators for launch configurations
* Added some comments to some `#endif`'s, reminding the reader of the condition used in the `#if` of `#ifdef`.
* Made some narrowing casts explicit, to clarify their intentionality to static analysis tool.
* Added two aliases to the sync/async boolean enum in `cuda::stream`
* A bit of comment rephrasing

Example program changes:

* Adapted examples for the use of `grid::complete_dimensions_t`.
* Now creating wrapped kernels using `cuda::kernel::wrap()` rather than by direct construction.
* Spacing tweaks.
* Changes to the `cudaChooseDevice()` function in `helper_cuda.h`; mainly:
  * Now returning a `cuda::device_t`
  * No longer making the returned device current. In particular, that means that `simpleStreams.cu` may now be using a device that's not the current one.
eyalroz added a commit that referenced this issue Jan 14, 2022
* For #284: Introduced a grid-and-block-dimensions structure, `grid::complete_dimensions_t`. Using it when returning both grid and block dimensions instead of an `std::pair`; it has equals
* For #285: Changed the construction pattern for `kernel_t`:
  * Dropped the templated, wrapping, direct constructor.
  * Added `kernel::detail_::wrap()` taking a device ID and an arbitrary (function) pointer, and a `kernel::wrap()` taking a device ID and type-erased `const void*` pointer.
  * Made the lower-level `wrap()` a friend of the `kernel_t` class.
* Now using the default destructor for `kernel_t`'s (has nothing to do with the construction changes).
* Spacing tweaks.
* Comment typo fixes.
* Added not-equal operators for launch configurations
* Added some comments to some `#endif`'s, reminding the reader of the condition used in the `#if` of `#ifdef`.
* Made some narrowing casts explicit, to clarify their intentionality to static analysis tool.
* Added two aliases to the sync/async boolean enum in `cuda::stream`
* A bit of comment rephrasing

Example program changes:

* Adapted examples for the use of `grid::complete_dimensions_t`.
* Now creating wrapped kernels using `cuda::kernel::wrap()` rather than by direct construction.
* Spacing tweaks.
* Changes to the `cudaChooseDevice()` function in `helper_cuda.h`; mainly:
  * Now returning a `cuda::device_t`
  * No longer making the returned device current. In particular, that means that `simpleStreams.cu` may now be using a device that's not the current one.
@eyalroz eyalroz closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant