-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
tests: line: Use fixed-point arithmetic #107
Conversation
Hi @jserv, I have formatted the code in clang-format-12 and done the changes you proposed above. Please check. Thank you |
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.
Use git rebase -i
to squash and read the article How to Write a Git Commit Message
carefully.
You shall mention the benefits (with measurements) of the proposed changes.
tests/line.c
Outdated
} | ||
|
||
/* return the nonnegative square root of x */ | ||
static inline q_fmt sqrtq(q_fmt x) |
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.
Can you check the following materials accordingly?
I would expect the high-level descriptions for square root implementation.
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 have read the following article, it seems that the fastest algorithm which the article recommended is converting the fixed point value to the floating point value to do 'sqrtf()', and then converting back to the fixed point value result.
Should I change the algorithm into this way? Or just use the original one I made (converging bit by bit)
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.
Always measure if something is in doubt.
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.
Yes, I have already measured the performance between them in my previous term project:
For performing each algorithm 1000 times and compare their clock cycle:
Convert to floating point and call sqrtf(): 228442
My algorithm: 462650
The problem I concern is that our mission is getting rid of floating point arithmetic, this is not a good idea of still using them.
Except for the high-level descriptions for square root implementation, several annotations have been added. For bit-wise operation of signedness, I will squash those commit to one if all adjustments are finished. |
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.
Improve the git commit message. You shall express the motivation and benefits of the proposed changes. Show the numbers.
Thank @maromaSamsa for contributing! |
Thank @jserv let me have an opportunity contributing to this great work. |
Optimize the performance by replacing floating arithmetic with fixed-point arithmetic counterpart, which allows the embedded microprocessors that didn't have floating-point unit (FPU) doing mechanical calculation in high speed and/or low power consumption way. This change will reduce program execution time by 14%. Reference: https://hackmd.io/@maromaSamsa/HkjefPbFs
Replace floating-point arithmetic with its fixed-point equivalent to apermit microprocessors without a floating-point unit (FPU) to perform practical calculations efficiently. The improvement will result in a 14% faster program execution time.
Instructions: https://hackmd.io/@maromaSamsa/HkjefPbFs
Optimize the performance by replacing floating arithmetic with fixed-point arithmetic counterpart.