[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device
Paul Fultz II via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 09:17:31 PDT 2020
pfultz2 added a comment.
> Now, back to the specifics of your example. I'm still not 100% sure I understand what the problem is. Can you boil down the use case to an example on godbolt?
I dont have a specific example, but there could be code like this generic `clip` operator:
template<class F, class T>
void clip(F f,
const T& min_val,
const T& max_val)
{
f([=](auto x) {
return ::min<decltype(x)>(::max<decltype(x)>(min_val, x), max_val);
});
}
Its not clear to the writer of the generic function that it needs to declare the lambda with an explicit HD.
> If Sam decides to incorporate support for capturing lambdas in this patch, we could still do it by restricting the capturing lambda promotion to the ones within a function scope only. I.e. lambdas created in global scope would still be host.
I think that would be acceptable. I dont think global scope capturing lambdas are very common due to possible ODR issues.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78655/new/
https://reviews.llvm.org/D78655
More information about the cfe-commits
mailing list