-
Notifications
You must be signed in to change notification settings - Fork 70
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
Fixing #321 issue #341
Fixing #321 issue #341
Conversation
- Adding logic for dispatch for cunumeric-specific types - Adding logic for the copy operation on cunumeric types (PointN) - Adding logic in advanced indexing for copies with the indirect field of shape (1,)
cunumeric/deferred.py
Outdated
def _convert_future_to_store(self, a): | ||
store = self.context.create_store( | ||
a.dtype, | ||
shape=(1,), |
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.
Is there a reason you don't pass a.shape
here? I suspect doing this could potentially require broadcasting later if the shape was not (1,)
but some other degenerate case (e.g., (1,1,)
).
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.
I have assumed that shape for the Future is always (1,). I will change it to a.shape
cunumeric/deferred.py
Outdated
index_array = self._convert_future_to_store(index_array) | ||
result_store = self.context.create_store( | ||
self.dtype, | ||
shape=(1,), |
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.
same question here: why can't we just use index_array.shape
?
src/cunumeric/utilities/dispatch.h
Outdated
dim1, dim2, std::forward<Functor>(f), std::forward<Fnargs>(args)...); | ||
} | ||
|
||
// template <typename Functor, typename... Fnargs> |
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.
Remove these comments.
src/cunumeric/utilities/dispatch.h
Outdated
return f.template operator()<CuNumericTypeCodes::CUNUMERIC_TYPE_POINT4, DIM>( | ||
std::forward<Fnargs>(args)...); | ||
} | ||
case CuNumericTypeCodes::CUNUMERIC_TYPE_POINT5: { |
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.
I think this dispatch should abide by LEGION_MAX_DIM
and avoid instantiating types that will never arise for a given LEGION_MAX_DIM
. I guess you could check code <= MAX_TYPE_NUMBER
early on so that you can fall back to the core's dispatch more quickly.
src/cunumeric/utilities/dispatch.h
Outdated
#endif | ||
#if LEGION_MAX_DIM >= 2 | ||
case 2: { | ||
return inner_type_dispatch_fn<2>{}(code, f, std::forward<Fnargs>(args)...); |
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.
why is this not cunumeric::inner_type_dispatch_fn
? (same question to other cases)
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.
Yes, it should have cunumeric:: in front.
src/cunumeric/utilities/dispatch.h
Outdated
} | ||
|
||
template <typename Functor, typename... Fnargs> | ||
constexpr decltype(auto) double_dispatch(int dim1, int dim2, Functor f, Fnargs&&... args) |
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.
where are you using this?
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.
I am not using this, but might in the future. Would you recommend removing currently unused functions?
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.
what use case do you have in mind?
src/cunumeric/utilities/dispatch.h
Outdated
// } | ||
|
||
template <typename TypeCode, typename Functor, typename... Fnargs> | ||
constexpr decltype(auto) type_dispatch(TypeCode code, Functor f, Fnargs&&... args) |
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.
is this really used in the code? if so, this has the same issue as the inner dispatch of not abiding by LEGION_MAX_DIM
.
@@ -64,6 +69,32 @@ struct UnaryOpImpl { | |||
{ | |||
assert(false); | |||
} | |||
|
|||
template <CuNumericTypeCodes CODE, int DIM> | |||
void operator()(UnaryOpArgs& args) const |
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.
Can we move this to a separate functor instead of adding it to the existing one? I want use to avoid any accidental instantiations of this template.
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.
Sounds good
@@ -72,7 +103,7 @@ struct UnaryOpDispatch { | |||
void operator()(UnaryOpArgs& args) const | |||
{ | |||
auto dim = std::max(args.in.dim(), 1); | |||
double_dispatch(dim, args.in.code(), UnaryOpImpl<KIND, OP_CODE>{}, args); | |||
cunumeric::double_dispatch(dim, args.in.code(), UnaryOpImpl<KIND, OP_CODE>{}, args); |
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.
I think you can do better than this by checking the op code from the outside and choosing a point copy functor if the op code was COPY
. Then, you don't even need to do this custom double dispatch for all the other ops.
src/cunumeric/utilities/dispatch.h
Outdated
* | ||
*/ | ||
|
||
#pragma once |
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.
If this is used only in the unary op, I rather have it there than here. This hasn't become a general utility yet.
|
||
namespace cunumeric { | ||
|
||
template <CuNumericTypeCodes CODE> |
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.
same here. if you don't use this anywhere other than the unary op, keep this there.
@ipdemes I have added some comments above. I suggest creating a new PR to address them. |
@ipdemes One more thing to note: Clang is throwing some warnings such as:
and
|
Thank you! I will try to fix it today |
This PR takes another approach for fixing Issue #321