-
Notifications
You must be signed in to change notification settings - Fork 407
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
TeamThreadRange requires begin, end to be the same type #305
Comments
Hi @alanw0 -- I don't agree that this is actually an issue with Kokkos. How is Kokkos supposed to know what index type you meant to use for the loop? Is it Suppose that you wrote the following for loop:
The compiler would rightfully warn about your signed / unsigned comparison. Ditto if you used |
Mark I actually told Alan to put this in, i.e. I was with him when we ran into this. I think we should fix this that it would work, but it might issue the warning you talk about. But just refusing to compile might be a bit harsh. |
Agree with Mark on this one. For clarity we could emit a static_assert when the types don't match. |
Christian understands the issue better than I do. |
Catch error with a static_assert |
Evaluate the two types and choose the appropriate type according to "larger" type rule. |
Investigate use of C++11 std::common_type<intX,intY>::type |
Using std::common_type is the right approach because it does what a user would expect (aka what the C++ language would do). It uses the common type that C++ would implicitly convert multiple types to. If the two types are different sizes, it chooses the type of the larger size. If the two types are of the same size but one is signed and the other is unsigned, it chooses the unsigned type. We had considered making the type be signed if it was 64 bit for performance reasons, but I think it's better to use a built-in C++ feature vs. writing our own. It's also better to do it the way the user would expect. |
TeamThreadRange now allows begin and end to be different types (#305)
error:
The text was updated successfully, but these errors were encountered: