-
Notifications
You must be signed in to change notification settings - Fork 13
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
Make float test more accurate, add integer performance tests. #217
base: master
Are you sure you want to change the base?
Conversation
tests/system/hw_math/source/main.c
Outdated
@@ -7,6 +7,82 @@ | |||
|
|||
#include <nds.h> | |||
|
|||
#define TEST_SIZE (1000) | |||
|
|||
u32 dkp_sqrt32(int a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid putting copy-pasted benchmarks for other projects in BlocksDS. Not only can they change the code at any time, which would make the copy paste outdated, it feels in bad taste.
This can be a separate project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with asie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove them then. I could put in a software implementation test instead and rename the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, measuring against a simple C-based implementation sounds like a better idea and provides meaningful information to developers; it can also be used to validate correct outputs from the BlocksDS hardware accelerated implementation.
tests/system/hw_math/source/main.c
Outdated
@@ -7,6 +7,82 @@ | |||
|
|||
#include <nds.h> | |||
|
|||
#define TEST_SIZE (1000) | |||
|
|||
u32 dkp_sqrt32(int a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with asie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really need to try to match the code style of the repository when you contribute to projects.
In the case of this repository, don't leave many empty lines between functions (one is enough), try to match where braces are opened and closed, capitalise comments correctly... Take a look at other PRs and you will see that, for the most part, contributors imitate pre-existing code. I'm not going to complain about one brace here and there not matching other code, but this is too different, and I would just have to clean it up myself.
tests/system/hw_math/source/main.c
Outdated
//which gives the source as | ||
//Square root by abacus algorithm, Martin Guy @ UKC, June 1985. | ||
//From a book on programming abaci by Mr C. Woo. | ||
//assert(("sqrt input should be non-negative", n > 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave this commented assert()
. You should just make the function take unsigned ints as input and return unsigned ints.
I plan to work on this further, I wouldn't consider it finished. I assume to reduce noise/you getting unnecessary notifications it's probably not enough to mark it as a draft and request a review manually when necessary. The option I have here is either to close the PR until it's done, or to split the changes, although then I'm not sure why the draft feature exists to begin with. |
The draft feature is fine; just keep us updated on the status. If you ever feel like the PR is not up to standard, feel free to close it. |
Add software integer square root implementations Add performance tests for integer square roots Add tests for inverse float square root Add assembly 32-bit integer square root and associated tests
I've updated my tests and also added some tests for the inverse sqrt in blocksds/libnds#156 . The file currently needs to be copied from there to run some of the tests. I've modified the integer sqrt implementations for unsigned inputs and added an assembly routine for 32-bit integer sqrts. If you think the speed is good enough you may want the assembly routine as part of libnds, though. In this PR it is included as a separate file. I believe at least for DSi users it outperforms the hardware sqrt unit, but I cannot currently test on DS. I'm also curious if choosing a better starting value with clz for it is possible, but I havent experimented with it, as it already seems to be ridiculously fast. |
…oo long. Change it to a different key.
This doesn't contain an accuracy test for the integer square root functions, but I could add one if needed.