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

Replace tag dispatch #375

Open
jk-jeon opened this issue Feb 14, 2023 · 1 comment
Open

Replace tag dispatch #375

jk-jeon opened this issue Feb 14, 2023 · 1 comment

Comments

@jk-jeon
Copy link
Contributor

jk-jeon commented Feb 14, 2023

There are many functions that are likely end up as function call boundaries. Tag dispatch is not a zero-cost abstraction unless inlining takes place, and I think tag dispatch should be generally only used for simple forwarding functions. It is hardly likely that those little added overhead will cause any measurable slowdown of course, but I see no reason to insist on tag dispatches either, so why not.

It seems to be not so simple to turn the current instances of tag dispatches into forwarding, but you can also replace tag dispatches by template specializations anyway. Of course you can't partially specialize function templates, but you can simply move those functions inside a dummy class templates and specialize the template parameters for those dummy class templates instead.

@beached
Copy link
Owner

beached commented Mar 7, 2023

There are two major places that use it, one is always inlined and does a if constexpr over the tag to dispatch to the others. It could probably be switched to a template param and drop the function parameter but probably doesn't cost much at runtime. Probably should be remove that func param though.

The other, the exec tag uses a small linear hierarchy of to find the best overload where a simd exec tag is a runtime exec tag is a constexpr exec tag. This is/has been used to work around optimization possibilities in constexpr code and gracefully fallback when there is no alternative. When/if C++20 becomes the minimum a bunch of this is simplified though.

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

No branches or pull requests

2 participants