[PATCH] D77954: [CUDA][HIP] Fix host/device based overload resolution

Eric Christopher via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 23 11:21:39 PDT 2020


echristo added a subscriber: erichkeane.
echristo added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:9749
+  if (isBetterMultiversionCandidate(Cand1, Cand2))
+    return true;
+
----------------
rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > If we move anything below this check, it needs to figure out a tri-state so that it can return false if `Cand2` is a better candidate than `Cand1`.  Now, that only matters if multiversion functions are supported under CUDA, but if you're relying on them not being supported, that should at least be commented on.
> > multiversion host functions is orthogonal to CUDA therefore should be supported. multiversion in device, host device, and global functions are not supported. However this change does not make things worse, and should continue to work if they are supported.
> > 
> > host/device based overloading resolution is mostly for determining viability of a function. If two functions are both viable, other factors should take precedence in preference. This general rule has been taken for cases other than multiversion, I think it should also apply to multiversion.
> > 
> > I will make isBetterMultiversionCandidate three states.
> > This general rule has been taken for cases other than multiversion, I think it should also apply to multiversion.
> 
> Well, but the multiversion people could say the same: that multiversioning is for picking an alternative among otherwise-identical functions, and HD and H functions are not otherwise-identical.
> 
> CC'ing @echristo for his thoughts on the right ordering here.
Adding @erichkeane here as well.

I think this makes sense, but I can see a reason to multiversion a function that will run on host and device. A version of some matrix mult that takes advantage of 3 host architectures and one cuda one? Am I missing something here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77954/new/

https://reviews.llvm.org/D77954





More information about the cfe-commits mailing list