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

rationalize pico_float/pico_double libraries #2208

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kilograham
Copy link
Contributor

  • on RP2350 _dcp variant now enables -msoft-float, since if you're using this at all it is likely because you don't want to use the VFP unit at all (to save stack space)
  • implement all float_ and double_ conversion functions in all pico_float_pico_ variants and pico_double_pico on RP2040 and RP2350 (many were missing in some combinations)
  • provide better granularity of what functions are wrapped in each case

* on RP2350 _dcp variant now enables -msoft-float, since if you're using this at all it is likely because you don't want to use the VFP unit at all (to save stack space)
* implement all float_ and double_ conversion functions in all pico_float_pico_ variants and pico_double_pico on RP2040 and RP2350 (many were missing in some combinations)
* provide better granularity of what functions are wrapped in each case
@kilograham kilograham added this to the 2.1.1 milestone Jan 23, 2025
@kilograham
Copy link
Contributor Author

fixes #2160

@kilograham
Copy link
Contributor Author

cc @armandomontanez - i fixed up the main bazel build, but did not attempt to add the new tests

Comment on lines +55 to +56
* On Arm, (replacement) optimized implementations are provided for the following compiler built-ins when
* and math library functions when using `pico_dobule_pico`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Some kind of copy-paste typo? "compiler built-ins when and math library functions"

* note: on `pico_double_vfp` the 32-bit functions are curretly _only_ provided as C macros and must use a compile
* time constant between 1 and 32 for the fixed point position
*
* - Even faster methods versions of divide and square-root that do not round correctly:
Copy link
Contributor

Choose a reason for hiding this comment

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

"methods versions" doesn't sound right?

double mla(double x, double y, double z); // note this is not fused
double sqrt_fast(double f);
double fma_fast(double x, double y, double z); // this is not fused
double mla(double x, double y, double z); // another name for fma_flast
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the fma_flast here supposed to say fma_fast ?

* - __addsf3, __subsf3, __mulsf3
* 1. `pico_float_pico_vfp` - this library leaves basic C single-precision floating point operations to the compiler
* which can use inlined VFP (Arm FPU) code. Custom optimized versions of trigonometric and scientific functions are provided.
* no DCP (RP2350 Double co-processor) instructions are used.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: capital N on no here?

* no DCP (RP2350 Double co-processor) instructions are used.
* 2. `pico_float_pico_dcp` - this library prevents the compiler injecting inlined VFP code, and also implements
* all single-precision floating point operations in optimized DCP or M33 code. This option is not as fast
* as pico_float_pico_vfp, however allows floating point operations without enabling the floating point co-processor
Copy link
Contributor

Choose a reason for hiding this comment

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

"however allows" -> "however it allows" ?

* on the CPU; this can be beneficial in certain circumstances, e.g. where leaving stack in tasks or interrupts
* for the floating point state is undesirable.
*
* Note: `pico_float_pico` is equivalent ot `pico_flot_pico_vfp` on RP2350, as this is the most sensible default
Copy link
Contributor

Choose a reason for hiding this comment

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

"ot" -> "to"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also flot -> float ? 😉

* Note: `pico_float_pico` is equivalent ot `pico_flot_pico_vfp` on RP2350, as this is the most sensible default
* \endif
*
* On Arm, (replacement) optimized implementations are provided for the following compiler built-ins when
Copy link
Contributor

Choose a reason for hiding this comment

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

Same "when and" typo as earlier.

* note: on `pico_float_vfp` the 32-bit functions are also provided as C macros since they can map to inline VFP code
* when the number of fractional bits is a compile time constant between 1 and 32
*
* - Even faster methods versions of divide and square-root that do not round correctly: (`pico_float_pico_dcp` only)
Copy link
Contributor

Choose a reason for hiding this comment

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

"methods versions" again

#define _float2ufix_inline(f, e) _float2ufix_z_inline((f), (e))
#endif

#if LIB_PIC_FLOAT_PICO_VFP
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this supposed to be LIB_PICO_FLOAT_PICO_VFP ?


set(FLOAT_TYPES compiler)
set(DOUBLE_TYPES compiler)
#if (PICO_RP2040)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the commented-out if() here? Would it make sense to remove it?

*
* int2float, uint2float, int642float, uint642float
*
* note: on `pico_float_vfp` the 32-bit functions are also provided as C macros since they map to inline VFP code
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the mentions of pico_float_vfp here (and elsewhere) supposed to be pico_float_pico_vfp ? 🤷

*
* fix2double, ufix2double, fix642double, ufix642double
*
* note: on `pico_double_vfp` the 32-bit functions are curretly _only_ provided as C macros and must use a compile
Copy link
Contributor

Choose a reason for hiding this comment

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

"curretly" -> "currently"
(and also on lines 123 and 130)

*
* __aeabi_dadd, __aeabi_ddiv, __aeabi_dmul, __aeabi_drsub, __aeabi_dsub
*
* - comparison: (except `pico_double_pico_vfp`)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only mention of pico_double_pico_vfp in this PR, and pico_double_vfp also appears 5 times. I've no idea which version is correct! (Perhaps they both are?)

* (Replacement) optimized implementations are provided of the following compiler built-ins
* and math library functions:
* An application can take control of the floating point routines used in the application over and above what is provided by the compiler,
* by depending on the pico_double library. A user might want to do this
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should probably be a colon at the end of this line? (and same in float.h)

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.

2 participants