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

Make float test more accurate, add integer performance tests. #217

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kuratius
Copy link

@Kuratius Kuratius commented Nov 1, 2024

This doesn't contain an accuracy test for the integer square root functions, but I could add one if needed.

Add integer square root performance tests
@@ -7,6 +7,82 @@

#include <nds.h>

#define TEST_SIZE (1000)

u32 dkp_sqrt32(int a)
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Author

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.

Copy link
Contributor

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 Show resolved Hide resolved
@@ -7,6 +7,82 @@

#include <nds.h>

#define TEST_SIZE (1000)

u32 dkp_sqrt32(int a)
Copy link
Member

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.

(note that these are signed, I havent found an unsigned version yet)
also speed depends on input size
they can also be optimized with __builtin_clz in some cases,
but wont do that today
Copy link
Member

@AntonioND AntonioND left a 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.


sw_time += cpuEndTiming();

printf("BlocksDS sqrt64 time: %lu (%lu per op)\n", sw_time, sw_time / sw_iterations);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't fit in one line, you should split it into two so that numbers aren't cut in the middle.

//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));
Copy link
Member

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.

}



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add too many spaces, indent blocks correctly.

@@ -49,6 +235,8 @@ int main(int argc, char **argv)
printf("qNaN: 0x%08lX\n", quiet_nan);
printf("\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add (or remove) empty lines for no reason, they just add noise to the git history.

@Kuratius
Copy link
Author

Kuratius commented Nov 4, 2024

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.

@asiekierka
Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

3 participants