Skip to content

Conversation

@ShriramShastry
Copy link
Contributor

fix point math power function having negative and positive values
of base and exponent as function argument

fix point math base 2 logarithm function using a short lookup
tables

Signed-off-by: ShriramShastry malladi.sastry@intel.com

@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch 2 times, most recently from 3d2046b to 35edda9 Compare November 1, 2021 13:13
@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch 5 times, most recently from f761d25 to e48cf10 Compare November 9, 2021 11:44
Copy link
Contributor

@johnylin76 johnylin76 left a comment

Choose a reason for hiding this comment

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

My only question is why do we need a UUID for power? is it for logging with "power_tr"?

@ShriramShastry
Copy link
Contributor Author

My only question is why do we need a UUID for power? is it for logging with "power_tr"?

yep there does not seem to other way to create a trace than having uuid. Some other library parts also have uuid.

yes it is for power_tr

@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch from 4c89d8a to c46d965 Compare November 25, 2021 11:09
@johnylin76
Copy link
Contributor

Offline synced with Malladi.
I finally realized that this implementation of power function actually cannot be adopted to DRC usage, because it only supports the integer exponent. (I should have realized it earlier...)

For DRC usage, it requires the support of fractional value of both base and exponent. Both of them are always positive.
In our current implementation of power in DRC, we use Q6.26 format for base (but assuming that only positive values are given), and Q2.30 for exponent.

The actual use cases for "exponent" of DRC is =1/(attack_frames); attack_frames represents the number of frames it expects to spend for 10dB drop in attack mode. It is a configurable parameter range from 1 to (sample_rate), but "typically" the value is an integer by the scale of tens to hundreds (the case of thousands is not often to be seen but it exists).

The power function implementation in this PR is not usable for DRC. However I think it would have the use case for some other processing algorithms.

@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch from c46d965 to 9f1049b Compare November 29, 2021 15:36
@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch from 9f1049b to 8d0beed Compare November 30, 2021 13:36
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

My only question is why do we need a UUID for power? is it for logging with "power_tr"?

Thanks for catching this. Sorry for the late request.

Logging is dictionary-based to save memory, so it uses UUID for component names.

I think we don't want a new trace component for each single .c file (or in this case: a single log statement for now!), so I think math_power_tr is too specific. How about math_tr instead? Declare it in some non-optional file, maybe in math/numbers.c?

As another, maybe extreme example ipc_tr is used in more than 20 files and more than 200 statements.

@marc-hb
Copy link
Collaborator

marc-hb commented Nov 30, 2021

As reported by checkpatch, there are still many // C99-comments. Are we allowing these now? Happy to change the checkpatch configuration if we do. If not then please change them to /* */ (and run ./scripts/checkpatch --strict -g HEAD locally)

There are a few more warnings in https://sof-ci.01.org/sofpr/PR4941/build11280/checkpatch/

@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch from 8d0beed to d54e510 Compare December 1, 2021 05:48
fix point math power function having negative and positive values
of base and exponent as function argument. power_int32() support
only integer base and exponential value and it does not support
fractional values for base and exponent.

fix point math base 2 logarithm function using a short lookup
tables

Signed-off-by: ShriramShastry <malladi.sastry@intel.com>
@ShriramShastry ShriramShastry force-pushed the shastry_arithmetic_functions branch from d54e510 to 4cd3e5a Compare December 1, 2021 05:53
@ShriramShastry
Copy link
Contributor Author

As reported by checkpatch, there are still many // C99-comments. Are we allowing these now? Happy to change the checkpatch configuration if we do. If not then please change them to /* */ (and run ./scripts/checkpatch --strict -g HEAD locally)

There are a few more warnings in https://sof-ci.01.org/sofpr/PR4941/build11280/checkpatch/

I did the test and now I don't see additional errors
checkpatch_4941.txt

@marc-hb
Copy link
Collaborator

marc-hb commented Dec 1, 2021

There's an inconsistency between https://sof-ci.01.org/sofpr/PR4941/build11287/checkpatch/ and https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true. One is configured to catch C99 // comments and the other is not. Which is wrong and which is right?

@ShriramShastry
Copy link
Contributor Author

ShriramShastry commented Dec 1, 2021

https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true

https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true , can be ignored since https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true and ./scripts/checkpatch.pl is same in output. . It could be that --strict is not enforced in the later case and executed with --no_strict option.

I ran ./scripts/checkpatch.pl 0001-math-Add-square-root-function-using-lookup-table.patch --strict -g HEAD locally and output is same as https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true

This is my understanding !!

@lgirdwood
Copy link
Member

There's an inconsistency between https://sof-ci.01.org/sofpr/PR4941/build11287/checkpatch/ and https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true. One is configured to catch C99 // comments and the other is not. Which is wrong and which is right?

SPDX // is allowed (and I cant remember the reason), but this also aligns with Linux.

@lgirdwood
Copy link
Member

I think we don't want a new trace component for each single .c file (or in this case: a single log statement for now!), so I think math_power_tr is too specific. How about math_tr instead? Declare it in some non-optional file, maybe in math/numbers.c?

As another, maybe extreme example ipc_tr is used in more than 20 files and more than 200 statements.

Good catch (and we should capture this as a feature cleanup for v2.1), but this should not be a blocker given the direction of travel to Zephyr logging APIs

@lgirdwood
Copy link
Member

lgirdwood commented Dec 1, 2021

CI shows known system level PM timeout (unrelated to this PR as it's not used in test) and only C99 SPDX comments (which are allowed)

@lgirdwood lgirdwood merged commit 1600208 into thesofproject:main Dec 1, 2021
@marc-hb
Copy link
Collaborator

marc-hb commented Dec 1, 2021

SPDX // is allowed (and I cant remember the reason), but this also aligns with Linux.

I meant // in general, not for SPDX specifically. I will submit the change that turns off this warning and we can discuss there.

CI shows ... and only C99 SPDX comments (which are allowed)

Not just in SPDX, see https://github.com/thesofproject/sof/runs/4377441309?check_suite_focus=true or simply look at the source.

Good catch (and we should capture this as a feature cleanup for v2.1), but this should not be a blocker given the direction of travel to Zephyr logging APIs

@ShriramShastry can you please submit a new PR that moves math_power_tr to a higher level math_tr?

Zephyr logging (and any decent logging solution really) have a compoment equivalent: https://docs.zephyrproject.org/latest/reference/logging/index.html#logging-in-a-module-instance

marc-hb added a commit to marc-hb/sof that referenced this pull request Dec 1, 2021
This is a logical revert of eb45907

Based on recently merged thesofproject#4941, C99 comments are now OK. I never found
any rationale or even written down coding style for excluding them in
the first place.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb
Copy link
Collaborator

marc-hb commented Dec 1, 2021

I will submit the change that turns off the C99 comments warning and we can discuss there.

#5046

lgirdwood pushed a commit that referenced this pull request Dec 6, 2021
This is a logical revert of eb45907

Based on recently merged #4941, C99 comments are now OK. I never found
any rationale or even written down coding style for excluding them in
the first place.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
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.

7 participants