-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Reduce gratuitous API calls in current_device::detail::set_() #328
Labels
Comments
eyalroz
added a commit
that referenced
this issue
Jun 20, 2022
* Switched many methods which require a context, and take a `device_t` by value, to taking it by const-reference - to make use of device_t's mutable primary-context cache. * Host memory allocations no longer increase primary context refcounts, nor do their freeing decrease the refcount * The following proxy class instances can now keep primary contexts alive with a reference count unit (depending on how they were constructed): `device_t`, `primary_context_t`, `kernel_t`, `stream_t`, `event_t`, `module_t`. * Some doxygen comment corrections and additions * Added bool aliases regarding whether or not a proxy object should hold a primary context refcount unit. * Dropped: The `scoped_` and `unscoped_` bool-aliases which were used with `device_t::primary_context()`; we now indicate clearly whether the proxy object should or should not hold a refcount unit * Spaces -> tabs fixes in `context.hpp` * Added an alternative method for setting the current device (`device::current::detail_::set_with_aux_info()`) that requires performing less API calls. * The combined behavior of `device_t`, `primary_context_t` and `current_device::detail_::scoped_context_override` was such, that `make_unique()` with no device passed, and with the primary context inactive, would cause a primary context to be activated, then destroyed/deactivated immediately after allocation. This no longer happens. * No longer using `current_device::detail_::scoped_context_override`; now preferring `device_t`'s primary context caching mechanism + delegating to methods which take a (not necessarily primary) context. * The scoped context override gadget now has two flags: One for popping the context, another for reducing the primary context refcount; the logic for using them has been updated. * `device_t` now uses an explicit flag for when it's holding a primary context refcount unit; this allows in-context copies of a `device_t` to know the primary context without holding a refcount unit. * Spacing tweaks * Corrected an exception message in `stream.hpp`. * CAVEAT: Some DRY in the code handling refcount units in the various proxy class.
eyalroz
added a commit
that referenced
this issue
Jun 20, 2022
* Switched many methods which require a context, and take a `device_t` by value, to taking it by const-reference - to make use of device_t's mutable primary-context cache. * Host memory allocations no longer increase primary context refcounts, nor do their freeing decrease the refcount * The following proxy class instances can now keep primary contexts alive with a reference count unit (depending on how they were constructed): `device_t`, `primary_context_t`, `kernel_t`, `stream_t`, `event_t`, `module_t`. * Some doxygen comment corrections and additions * Added bool aliases regarding whether or not a proxy object should hold a primary context refcount unit. * Dropped: The `scoped_` and `unscoped_` bool-aliases which were used with `device_t::primary_context()`; we now indicate clearly whether the proxy object should or should not hold a refcount unit * Spaces -> tabs fixes in `context.hpp` * Added an alternative method for setting the current device (`device::current::detail_::set_with_aux_info()`) that requires performing less API calls. * The combined behavior of `device_t`, `primary_context_t` and `current_device::detail_::scoped_context_override` was such, that `make_unique()` with no device passed, and with the primary context inactive, would cause a primary context to be activated, then destroyed/deactivated immediately after allocation. This no longer happens. * No longer using `current_device::detail_::scoped_context_override`; now preferring `device_t`'s primary context caching mechanism + delegating to methods which take a (not necessarily primary) context. * The scoped context override gadget now has two flags: One for popping the context, another for reducing the primary context refcount; the logic for using them has been updated. * `device_t` now uses an explicit flag for when it's holding a primary context refcount unit; this allows in-context copies of a `device_t` to know the primary context without holding a refcount unit. * Spacing tweaks * Corrected an exception message in `stream.hpp`. * CAVEAT: Some DRY in the code handling refcount units in the various proxy class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
current_device::detail::set_()
gets called a lot (well, if your code is runtime-API-style). But - it is often called when sufficient information is available to preclude it from making a bunch of checks itself: Whether the driver was initialized or not; what the current context is; etc.We should have another version of this function which takes some subset of this auxiliary information, to avoid making the API calls necessary to divine it within the function itself.
The text was updated successfully, but these errors were encountered: