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

Task variant registry #675

Merged
merged 26 commits into from
Apr 13, 2023
Merged

Conversation

magnatelee
Copy link
Contributor

This PR adds a per-library task registry and uses it to check if a given task launch can be performed successfully. As part of the change, the PR also 1) adds an API to register a task without going through the registrar and 2) refactors the task registration logic so that client libraries no longer need to forward a call back to the core. The PR also adds an integration test to exercise new functionalities.

@magnatelee magnatelee added the category:improvement PR introduces an improvement and will be classified as such in release notes label Apr 10, 2023
@magnatelee magnatelee requested a review from jjwilke April 10, 2023 22:13
@magnatelee
Copy link
Contributor Author

@bryevdv Note that I ignored the typing error from the new Cython module and I haven't figured out a way to fix it.

@magnatelee magnatelee mentioned this pull request Apr 11, 2023
Copy link

@jjwilke jjwilke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Some minor suggested renaming.
I'm not really qualified to review the cython bits.
Examples work for me, though, after the refactor.

@@ -85,6 +100,7 @@ class ResourceScope {
{
return base_ <= resource_id && resource_id < base_ + max_;
}
int64_t max() const { return max_ - 1; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of max is a bit confusing here. I would definitely rename the member variable max_ to something like num_ids and change the function from max() to max_valid_id().

You could possible even change ResourceScope to ResourceIdScope.

};

template <typename T, template <typename...> typename SELECTOR, bool HAS_VARIANT>
struct VariantHelperImpl {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can do this with one fewer template classes and remove the VariantHelperImpl:

template <typename T, template <typename...> typename SELECTOR, bool valid = SELECTOR<T>::value>
struct VariantHelper {
  static void record(TaskInfo* task_info,
                     const std::map<LegateVariantCode, VariantOptions>& all_options)
  {
  }
};

template <typename T, template <typename...> typename SELECTOR>
struct VariantHelper<T, SELECTOR, true> {
  static void record(TaskInfo* task_info,
                     const std::map<LegateVariantCode, VariantOptions>& all_options)
  {

# limitations under the License.
#

# distutils: language = c++
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? I believe that specifying CXX in rapids_cython_create_modules is sufficient but I could be wrong.

cdef class Context:
cdef LibraryContext* _context

def __init__(self, str library_name, bool can_fail=False) -> None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use __cinit__, rather than __init__ for C++-level initialization of the object:

https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#initialisation-methods-cinit-and-init


cdef extern from "core/task/task_info.h" namespace "legate" nogil:
cdef cppclass TaskInfo:
bool has_variant(int)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the methods of this class (or any of the below classes) raise C++ exceptions? If so, they should be declared with an except + in order for those C++ exceptions to be translated into Python exceptions when they occur. For example:

bool has_variant(int) except +

If not, please feel free to ignore this comment.

@magnatelee magnatelee requested a review from jjwilke April 12, 2023 18:49
Copy link

@jjwilke jjwilke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@magnatelee magnatelee merged commit 7ec0ac0 into nv-legate:branch-23.05 Apr 13, 2023
@magnatelee magnatelee deleted the registry-pr branch April 13, 2023 04:08
rapids-bot bot pushed a commit to rapidsai/kvikio that referenced this pull request May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:improvement PR introduces an improvement and will be classified as such in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants