-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Kernel argument order for cooperative launches is reversed #40
Comments
Not seeing this with CUDA 9.1 and a CC 3.0 device, nor with CUDA 8.0 and a CC 6.1 device. But - seeing this with CUDA 9.1 and a CC 6.1 device. Hmm, I have an idea. |
I'd say here is an undefined behaviour. |
@lahwaacz : This is a variation on a common and beloved trick by Sean Parent. But maybe somehow it's reversed... |
Right in the first post he says:
|
@lahwaacz : You're right... So now I have to generate an index sequence and use it to place each parameter in its correct position, all in C++11. Annoying :-( |
What? No you don't... Why people insist on inventing some "cool" one-liners (or "few-liners") all the time instead of writing simple readable code is beyond me. template <class F, class Arg>
void for_each_argument(F f, Arg&& arg) {
f(std::forward<Arg>(arg));
}
template <class F, class Arg, class... Args>
void for_each_argument(F f, Arg&& arg, Args&&... args) {
for_each_argument(f, std::forward<Arg>(arg));
for_each_argument(f, std::forward<Args>(args)...);
} Haven't bothered with trying to compile it, but you get the idea. |
@lahwaacz : Ah, right, ok, I guess I could do that. I was trying to be snazzy and not instantiate recursively all the way. But I guess it's not that critical - until people write kernels with 100 parameters and call them with many different types. |
I bet that after inlining all the lambdas the result will be essentially identical to your original version (which executed in the correct order). As for compilation time, I don't see how you could do less than O(N) instantiations when you actually need to call |
Since you seem obsessed with the number of instantiations, let me point out that your commit message in 46db0c4 is wrong in claiming that "[you] did reduce the number of instantiations to about one per 4 arguments rather than one-per-one". For example, if you call |
I was mostly obsessing about larger number of parameters. But - maybe you're right. I'll go ahead and simplify the code like you suggested. |
* Taking Jakub Klinkovsky's suggestion and simplifying the address collection code a bit; so - not trying to reduce the number of instantiations for super-high number of arguments, but actually reducing them for a smaller number of arguments relative to the previous commit (Not all the way though).
Compile and execute:
Expected output:
Actual output:
The text was updated successfully, but these errors were encountered: