Skip to content
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

Unconstrained definition of swap breaks types that pull in other namespaces with swap #1984

Open
miscco opened this issue Dec 12, 2024 · 3 comments

Comments

@miscco
Copy link

miscco commented Dec 12, 2024

Using an unconstrained swap function is problematic when interfacing with types that pull in multiple swaps from associated namespaces

consider this godbolt

This is breaking because both swap functions pulled in are ambigous.

One simple way to break this ambiguity is by adding a tie breaking in the form of std::type_identity_t. See this godbolt

@bernhardmgruber
Copy link

To elaborate, the problem is here: https://github.com/NVIDIA/cutlass/blob/main/include/cutlass/fast_math.h#L58

If an unqualified call to swap has arguments from both namespace std and cutlass, the compiler will see both std::swap and cutlass::swap, which is ambiguous.

@bernhardmgruber
Copy link

One solution, if you consume libcu++, is to just replace your swap with:

namespace cutlass {
  using ::cuda::std::swap;
}

Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants