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

Let's deprecate libdivide's unswitch functionality #46

Closed
kimwalisch opened this issue Jun 5, 2019 · 1 comment
Closed

Let's deprecate libdivide's unswitch functionality #46

kimwalisch opened this issue Jun 5, 2019 · 1 comment

Comments

@kimwalisch
Copy link
Collaborator

I have been running libdivide's benchmark program a lot over the past few days and I realized that libdivide's unswitch divider does not provide any performance speedup compared to the branchfull divider for both GCC and Clang (on x64). This is because GCC & Clang are smart enough to move the branches outside the body of the loop when using the default branchfull divider. The unswitch divider only improves performance by about 20% when using the MSVC compiler.

There are many good reasons for deprecating unswitch:

  • I don't think anybody uses it (I found no usages using Google).
  • It has a crazy API (see here).
  • Unswitch requires crazy hacks (e.g. crash divider)
  • Unswitch uses a very large amount of code that slows down compile time (e.g. 66% of the C vector API are functions related to unswitch).
  • By removing unswitch we make it easier to port libdivide to other languages.
  • We have added the branchfree divider which is similar to unswitch.

Please let me know if you agree or have if you have any objections.

@kimwalisch
Copy link
Collaborator Author

I have removed unswitch. I was able to get rid of about 1000 lines of code, 650 lines of code have been removed from libdivide.h. The crazy crash divider hack has been removed from libdivide.h and the C++ template implementation is now pretty clean and well designed.

I hope that using this change it will be easier for other programmers to read and understand the code inside libdivide.h and hopefully more people will contribute improvements.

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

1 participant