Difference between revisions of "emRun"
m |
m |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | [https://www.segger.com/products/development-tools/runtime-library/?mtm_campaign=kb&mtm_kwd=emRun emRun] is the replacement from SEGGER for newlib, newlib-nano, and glibc used in most [[GCC]] toolchains. These libraries have significant disadvantages over professional runtime libraries for embedded systems. emRun converts any [[GCC]]-based toolchain into a professional development choice. |
|
− | In many cases, the ROM-savings of |
+ | In many cases, the ROM-savings of emRun enable the use of a smaller microcontroller with less on-chip memory. This can result in significant cost savings, especially for devices built in large quantities for the mass market. |
− | For detailed information visit the [https://www.segger.com/products/development-tools/runtime-library/ |
+ | For detailed information visit the [https://www.segger.com/products/development-tools/runtime-library/?mtm_campaign=kb&mtm_kwd=emRun product page on segger.com]. |
== Who benefits from this product? == |
== Who benefits from this product? == |
||
Line 9: | Line 9: | ||
There are three classes of customer for this product and three variants: |
There are three classes of customer for this product and three variants: |
||
− | * End users that wish to replace newlib, newlib-nano, or some other vendor-supplied library with |
+ | * End users that wish to replace newlib, newlib-nano, or some other vendor-supplied library with emRun in order to reduce code footprint. In this case, the library is already configured for the target architecture and delivered ready for customer integration into the IDE. |
− | * Silicon vendors that wish to license |
+ | * Silicon vendors that wish to license emRun in order to offer it to their customers in place of newlib or newlib-nano as a competitive advantage. In this case, the silicon vendor receives a library configured for the processor architecture and ABI and integrates this into their IDE on behalf of all customers. |
* Processor IP vendors that wish to bring up a processor and associated toolset, for a proprietary architecture, where there is no pre-existing runtime library. In this case, the customer receives an architecture-neutral version of the runtime library, with supporting C functions, and integrates this into the compiler toolchain for their architecture. |
* Processor IP vendors that wish to bring up a processor and associated toolset, for a proprietary architecture, where there is no pre-existing runtime library. In this case, the customer receives an architecture-neutral version of the runtime library, with supporting C functions, and integrates this into the compiler toolchain for their architecture. |
||
== What does the library contain? == |
== What does the library contain? == |
||
− | + | emRun contains implementations of all Embedded C Subset functions required by the ISO standard. In addition it contains some functions that you will find in POSIX.1 and Linux that extend the C library with useful functionality. |
|
− | However, an implementation of the user-facing C library API is not all that is required to run a C program on a microcontroller. All C operations that do not directly map to machine instructions must be emulated in software. Therefore |
+ | However, an implementation of the user-facing C library API is not all that is required to run a C program on a microcontroller. All C operations that do not directly map to machine instructions must be emulated in software. Therefore emRun contains implementations of basic floating point operations, floating point conversions, and integer operations such as multiply, divide, and long shifts which use only fundamental integer data types, addition, subtraction, and shifting. |
== What parts of the library are machine specific? == |
== What parts of the library are machine specific? == |
||
− | Although |
+ | Although emRun has C implementations of the required C API and runtime API, implementation of <code>setjmp()</code> and <code>longjmp()</code> are highly compiler, ABI, and machine specific. The SEGGER Runtime Library contains implementations for Arm and RISC-V using standard ABIs, but if you are bringing up the library on a different processor, or using a nonstandard ABI, you will need to implement both <code>setjmp()</code> and <code>longjmp()</code> yourself. |
== What ports exist for the library? == |
== What ports exist for the library? == |
||
− | + | emRun is already widely deployed and is built into SEGGER's Embedded Studio for both Arm and RISC-V processor architectures. |
|
=== Arm port === |
=== Arm port === |
||
Line 38: | Line 38: | ||
The architecture-neutral distribution contains functions written in C that allow toolset bootstrapping. The requirements made of the compiler are rudimentary, all that is required is basic integer and unsigned operations, up to 32 bits in width, to be provided. For machines without multiply or divide instructions, runtime support is emulated in plain C. IEEE single-precision and double-precision floating-point and 64-bit arithmetic is written in C. Once basic functionality is attained, the compiler and runtime system can be enhanced by replacing runtime support in C with runtime support in assembly language, one function at a time. |
The architecture-neutral distribution contains functions written in C that allow toolset bootstrapping. The requirements made of the compiler are rudimentary, all that is required is basic integer and unsigned operations, up to 32 bits in width, to be provided. For machines without multiply or divide instructions, runtime support is emulated in plain C. IEEE single-precision and double-precision floating-point and 64-bit arithmetic is written in C. Once basic functionality is attained, the compiler and runtime system can be enhanced by replacing runtime support in C with runtime support in assembly language, one function at a time. |
||
+ | |||
+ | == Performance Benchmark == |
||
+ | |||
+ | emRun is designed for fast and efficient execution. A summary of performance numbers and comparison with gcclib / newlib is available at http://www.segger.com/emrun. |
||
+ | |||
+ | This is the description for the test projects. |
||
+ | The test projects have been designed to measure the performance of C library functions as well as low-level runtime ABI functions. |
||
+ | |||
+ | The complete test source is included in the emRun source distribution. |
||
+ | |||
+ | === Floating-Point Arithmetic === |
||
+ | |||
+ | Test the arithmetic functions of the IEEE-754 floating-point emulation. |
||
+ | These functions are used for low-level floating point operations which cannot be done in hardware, e.g. due to missing floating-point unit. |
||
+ | |||
+ | Each function is tested with a set of inputs throughout the range of valid parameters. |
||
+ | |||
+ | <source> |
||
+ | IEEE-754 Floating-point Library Benchmarks |
||
+ | Copyright (c) 2018-2022 SEGGER Microcontroller GmbH. |
||
+ | |||
+ | System: emRun v4.22.0 + emFloat v2.8.0 |
||
+ | System: Compiled with GNU C Compiler 12.2.0 |
||
+ | Target: RV32IMAC |
||
+ | Target: Little-endian byte order |
||
+ | Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size |
||
+ | Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point |
||
+ | Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers |
||
+ | Config: With assembly-coded FP acceleration |
||
+ | Config: With fully conformant NaNs |
||
+ | Config: With assembly-coded string acceleration |
||
+ | |||
+ | ====================== |
||
+ | GNU libgcc API |
||
+ | ====================== |
||
+ | |||
+ | Function Min Max Avg Description |
||
+ | -------------- ------ ------ ------ ----------------------------------------- |
||
+ | __addsf3 37 46 41.8 Random distribution over (0, 1), operands differ |
||
+ | __subsf3 32 51 44.8 Random distribution over (0, 1), operands differ |
||
+ | __mulsf3 32 37 34.3 Random distribution over (0, 1), operands differ |
||
+ | __divsf3 65 65 65.0 Random distribution over (0, 1), operands differ |
||
+ | __ltsf2 11 11 11.0 Random distribution over (0, 1), operands differ |
||
+ | __lesf2 10 10 10.0 Random distribution over (0, 1), operands differ |
||
+ | __gtsf2 10 10 10.0 Random distribution over (0, 1), operands differ |
||
+ | __gesf2 11 11 11.0 Random distribution over (0, 1), operands differ |
||
+ | __eqsf2 10 10 10.0 Random distribution over (0, 1), operands differ |
||
+ | __nesf2 10 10 10.0 Random distribution over (0, 1), operands differ |
||
+ | -------------- ------ ------ ------ ----------------------------------------- |
||
+ | __adddf3 43 64 53.4 Random distribution over (0, 1), operands differ |
||
+ | __subdf3 49 94 67.0 Random distribution over (0, 1), operands differ |
||
+ | __muldf3 57 70 62.1 Random distribution over (0, 1), operands differ |
||
+ | __divdf3 188 192 191.2 Random distribution over (0, 1), operands differ |
||
+ | __ltdf2 13 14 13.4 Random distribution over (0, 1), operands differ |
||
+ | __ledf2 13 14 13.4 Random distribution over (0, 1), operands differ |
||
+ | __gtdf2 13 14 13.6 Random distribution over (0, 1), operands differ |
||
+ | __gedf2 13 14 13.6 Random distribution over (0, 1), operands differ |
||
+ | __eqdf2 14 14 14.0 Random distribution over (0, 1), operands differ |
||
+ | __eqdf2 14 14 14.0 Random distribution over (0, 1), operands differ |
||
+ | -------------- ------ ------ ------ ----------------------------------------- |
||
+ | __fixsfsi 14 14 14.0 Random distribution over (-2^31.., 1..2^31) |
||
+ | __fixdfsi 6 16 13.3 Random distribution over (-2^31.., 1..2^31) |
||
+ | __fixsfdi 15 21 18.0 Random distribution over (-2^63..1, 1..2^63) |
||
+ | __fixdfdi 7 28 23.7 Random distribution over (-2^63..1, 1..2^63) |
||
+ | __fixunssfsi 12 12 12.0 Random distribution over (1..2^31) |
||
+ | __fixunsdfsi 5 13 9.7 Random distribution over (1..2^31) |
||
+ | __fixunssfdi 14 18 16.0 Random distribution over (-2^63..2^63) |
||
+ | __fixunsdfdi 7 23 20.3 Random distribution over (-2^63..2^63) |
||
+ | -------------- ------ ------ ------ ----------------------------------------- |
||
+ | __floatsisf 26 34 29.5 Random distribution over (-2^31.., 1..2^31) |
||
+ | __floatdisf 26 45 35.7 Random distribution over (-2^63..1, 1..2^63) |
||
+ | __floatsidf 22 30 25.2 Random distribution over (-2^31.., 1..2^31) |
||
+ | __floatdidf 19 51 34.5 Random distribution over (-2^63..1, 1..2^63) |
||
+ | __floatunsisf 21 29 24.5 Random distribution over (1..2^31) |
||
+ | __floatundisf 23 38 30.7 Random distribution over (-2^63..2^63) |
||
+ | __floatunsidf 17 25 20.2 Random distribution over (1..2^31) |
||
+ | __floatundidf 16 44 29.5 Random distribution over (-2^63..2^63) |
||
+ | -------------- ------ ------ ------ ----------------------------------------- |
||
+ | __extendsfdf2 12 12 12.0 Random distribution over (-2^63..1, 1..2^63) |
||
+ | __truncdfsf2 25 25 25.0 Random distribution over (-2^63..1, 1..2^63) |
||
+ | ============== ====== ====== ====== ========================================= |
||
+ | Total 1097.4 Totalized average time over all functions |
||
+ | ============== ====== ====== ====== ========================================= |
||
+ | |||
+ | |||
+ | STOP. |
||
+ | </source> |
||
+ | |||
+ | === Floating-Point Math === |
||
+ | |||
+ | Test the user-facing C library functions related to floating-point operations. |
||
+ | The tests measure performance of the functions with different input as well as accuracy against known answers. |
||
+ | |||
+ | <source> |
||
+ | IEEE-754 Floating-point Performance and Accuracy Benchmark |
||
+ | Copyright (c) 2018-2022 SEGGER Microcontroller GmbH. |
||
+ | |||
+ | System: emRun v4.22.0 + emFloat v2.8.0 |
||
+ | System: Compiled with GNU C Compiler 12.2.0 |
||
+ | Target: RV32IMAC |
||
+ | Target: Little-endian byte order |
||
+ | Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size |
||
+ | Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point |
||
+ | Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers |
||
+ | Config: With assembly-coded FP acceleration |
||
+ | Config: With fully conformant NaNs |
||
+ | Config: With assembly-coded string acceleration |
||
+ | |||
+ | Avg ulps RMS ulps Max ulps |
||
+ | Function Error Error Error Cycles Avg/fn |
||
+ | ---------- -------- -------- -------- -------- -------- |
||
+ | sqrtf 0.28 0.34 0.74 593923 580.00 |
||
+ | cbrtf 0.50 0.62 1.82 448798 880.00 |
||
+ | sinf 0.36 0.44 1.31 486983 893.55 |
||
+ | cosf 0.36 0.43 1.31 517241 985.22 |
||
+ | tanf 0.49 0.61 1.85 547780 1138.84 |
||
+ | asinf 0.46 0.60 1.97 730189 1415.09 |
||
+ | acosf 0.43 0.53 1.48 1467852 1433.45 |
||
+ | atanf 0.38 0.47 1.54 540749 1090.22 |
||
+ | expf 0.29 0.35 1.13 1003703 919.14 |
||
+ | logf 0.25 0.29 0.63 371219 725.04 |
||
+ | sinhf 0.30 0.37 1.21 369480 730.20 |
||
+ | coshf 0.35 0.43 1.66 1134471 1107.88 |
||
+ | tanhf 0.21 0.28 1.12 497954 997.90 |
||
+ | asinhf 0.30 0.39 2.18 858631 1626.20 |
||
+ | acoshf 0.29 0.36 1.68 1672202 1633.01 |
||
+ | atanhf 0.16 0.35 1.76 294554 416.63 |
||
+ | fabsf 0.00 0.00 0.00 9216 9.00 |
||
+ | ceilf 0.00 0.00 0.00 12661 24.30 |
||
+ | floorf 0.00 0.00 0.00 6480 27.00 |
||
+ | frexpf_s 0.00 0.00 0.00 14326 26.00 |
||
+ | frexpf_e 0.00 0.00 0.00 60416 59.00 |
||
+ | modff_i 0.00 0.00 0.00 12040 35.00 |
||
+ | modff_f 0.00 0.00 0.00 5130 30.00 |
||
+ | hypotf 0.31 0.38 1.14 740649 723.29 |
||
+ | atan2f 0.43 0.53 2.20 1389962 1353.42 |
||
+ | powf 0.43 0.66 6.10 1724424 1669.34 |
||
+ | fmodf 0.00 0.00 0.00 57793 56.44 |
||
+ | fminf 0.00 0.00 0.00 15915 15.51 |
||
+ | fmaxf 0.00 0.00 0.00 15921 15.52 |
||
+ | ldexpf 0.00 0.00 0.00 40199 46.91 |
||
+ | ========== ======== ======== ======== ======== ======== |
||
+ | All 0.00 0.06 6.10 15640861 714.03 |
||
+ | ========== ======== ======== ======== ======== ======== |
||
+ | |||
+ | |||
+ | STOP. |
||
+ | </source> |
||
+ | |||
+ | === Integer Arithmetic === |
||
+ | |||
+ | Test the arithmetic integer functions. |
||
+ | These functions are used for low-level integer arithmetic and conversion operations which cannot be done in hardware. |
||
+ | |||
+ | Each function is tested with a set of inputs throughout the range of valid parameters. |
||
+ | |||
+ | <source> |
||
+ | Integer Arithmetic Benchmarks |
||
+ | Copyright (c) 2018-2022 SEGGER Microcontroller GmbH. |
||
+ | |||
+ | System: emRun v4.22.0 |
||
+ | System: Compiled with GNU C Compiler 12.2.0 |
||
+ | Target: RV32IMAC |
||
+ | Target: Little-endian byte order |
||
+ | Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size |
||
+ | Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point |
||
+ | Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers |
||
+ | Config: With assembly-coded FP acceleration |
||
+ | Config: With fully conformant NaNs |
||
+ | Config: With assembly-coded string acceleration |
||
+ | |||
+ | Function Min Max Avg Description |
||
+ | ---------------- ------ ------ ------ ------------------------------- |
||
+ | __ashldi3 4 8 6.0 13440 cycles (2240 tests) |
||
+ | __lshrdi3 4 8 6.0 13440 cycles (2240 tests) |
||
+ | __ashrdi3 4 8 6.0 13440 cycles (2240 tests) |
||
+ | __mulsi3 1 1 1.0 171 cycles (171 tests) |
||
+ | __muldi3 7 7 7.0 4165 cycles (595 tests) |
||
+ | __divsi3 1 1 1.0 684 cycles (684 tests) |
||
+ | __modsi3 1 1 1.0 684 cycles (684 tests) |
||
+ | __udivsi3 1 1 1.0 171 cycles (171 tests) |
||
+ | __umodsi3 1 1 1.0 171 cycles (171 tests) |
||
+ | __divdi3 27 129 64.7 154216 cycles (2380 tests) |
||
+ | __moddi3 30 124 66.4 158260 cycles (2380 tests) |
||
+ | __udivdi3 7 101 42.1 25052 cycles (595 tests) |
||
+ | __umoddi3 12 105 48.0 28610 cycles (595 tests) |
||
+ | ================ ====== ====== ====== =============================== |
||
+ | Grand total 251.2 412504 cycles (15146 tests) |
||
+ | ================ ====== ====== ====== =============================== |
||
+ | |||
+ | |||
+ | STOP. |
||
+ | </source> |
||
+ | |||
+ | === String and Memory Functions === |
||
+ | |||
+ | Test C library functions for copying, moving, setting, searching, comparing strings or memory. |
||
+ | |||
+ | The tests measure performance with inputs of different length and different alignment. |
||
+ | |||
+ | <source> |
||
+ | String/Memory Function Benchmarks |
||
+ | Copyright (c) 2018-2022 SEGGER Microcontroller GmbH. |
||
+ | |||
+ | System: emRun v4.22.0 |
||
+ | System: Compiled with GNU C Compiler 12.2.0 |
||
+ | Target: RV32IMAC |
||
+ | Target: Little-endian byte order |
||
+ | Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size |
||
+ | Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point |
||
+ | Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers |
||
+ | Config: With assembly-coded FP acceleration |
||
+ | Config: With fully conformant NaNs |
||
+ | Config: With assembly-coded string acceleration |
||
+ | |||
+ | strlen(): |
||
+ | |||
+ | Aligned empty string : 21 |
||
+ | Misaligned empty string : 12 |
||
+ | Aligned 1-char string : 24 |
||
+ | Misaligned 1-char string : 17 |
||
+ | Aligned 255-char string : 425 |
||
+ | Misaligned 255-char string : 431 |
||
+ | -------------------------------------------- |
||
+ | Total : 930 |
||
+ | |||
+ | strchr(): |
||
+ | |||
+ | Aligned empty string : 33 |
||
+ | Misaligned empty string : 15 |
||
+ | Aligned 1-char string : 32 |
||
+ | Misaligned 1-char string : 14 |
||
+ | Aligned 255-char string : 800 |
||
+ | Misaligned 255-char string : 806 |
||
+ | -------------------------------------------- |
||
+ | Total : 1700 |
||
+ | |||
+ | strcmp(): |
||
+ | |||
+ | Aligned empty strings : 28 |
||
+ | Misaligned empty strings : 16 |
||
+ | Aligned 1-char string : 28 |
||
+ | Misaligned 1-char string : 16 |
||
+ | Aligned 255-char string : 572 |
||
+ | Equally-misaligned 255-char string : 1546 |
||
+ | Unequally-misaligned 255-char string : 1539 |
||
+ | -------------------------------------------- |
||
+ | Total : 3745 |
||
+ | |||
+ | strcpy(): |
||
+ | |||
+ | Aligned empty string : 25 |
||
+ | Misaligned empty string : 13 |
||
+ | Aligned 1-char string : 25 |
||
+ | Misaligned 1-char string : 13 |
||
+ | Aligned 255-char string : 670 |
||
+ | Equally-misaligned 255-char string : 1288 |
||
+ | Unequally-misaligned 255-char string : 1283 |
||
+ | -------------------------------------------- |
||
+ | Total : 3317 |
||
+ | |||
+ | memset(): |
||
+ | |||
+ | Aligned empty string : 9 |
||
+ | Misaligned empty string : 9 |
||
+ | Aligned 1-char string : 24 |
||
+ | Misaligned 1-char string : 16 |
||
+ | Aligned 255-char string : 139 |
||
+ | Misaligned 255-char string : 145 |
||
+ | -------------------------------------------- |
||
+ | Total : 342 |
||
+ | |||
+ | memcmp(): |
||
+ | |||
+ | Aligned empty strings : 19 |
||
+ | Misaligned empty strings : 14 |
||
+ | Aligned 1-char string : 37 |
||
+ | Misaligned 1-char string : 23 |
||
+ | Aligned 255-char string : 300 |
||
+ | Equally-misaligned 255-char string : 309 |
||
+ | Unequally-misaligned 255-char string : 1078 |
||
+ | -------------------------------------------- |
||
+ | Total : 1780 |
||
+ | |||
+ | memchr(): |
||
+ | |||
+ | Aligned empty string : 30 |
||
+ | Misaligned empty string : 21 |
||
+ | Aligned 1-char string : 62 |
||
+ | Misaligned 1-char string : 60 |
||
+ | Aligned 255-char string : 984 |
||
+ | Misaligned 255-char string : 993 |
||
+ | -------------------------------------------- |
||
+ | Total : 2150 |
||
+ | |||
+ | memcpy(): |
||
+ | |||
+ | Aligned empty string : 6 |
||
+ | Misaligned empty string : 6 |
||
+ | Aligned 1-char string : 25 |
||
+ | Misaligned 1-char string : 19 |
||
+ | Aligned 255-char string : 219 |
||
+ | Equally-misaligned 255-char string : 225 |
||
+ | Unequally-misaligned 255-char string : 1542 |
||
+ | -------------------------------------------- |
||
+ | Total : 2042 |
||
+ | |||
+ | memmove(): |
||
+ | |||
+ | Aligned empty string : 23 |
||
+ | Misaligned empty string : 12 |
||
+ | Aligned 1-char string : 26 |
||
+ | Misaligned 1-char string : 25 |
||
+ | Aligned 255-char string : 215 |
||
+ | Equally-misaligned 255-char string : 230 |
||
+ | Unequally-misaligned 255-char string : 604 |
||
+ | -------------------------------------------- |
||
+ | Total : 1135 |
||
+ | |||
+ | ============================================ |
||
+ | Grand total : 17141 |
||
+ | ============================================ |
||
+ | |||
+ | No failures from 32 tests |
||
+ | |||
+ | STOP. |
||
+ | </source> |
||
== IDE specific content == |
== IDE specific content == |
||
− | * [[How to use |
+ | * [[How to use emRun with NXP's MCUXpresso]] |
Latest revision as of 14:35, 31 May 2024
emRun is the replacement from SEGGER for newlib, newlib-nano, and glibc used in most GCC toolchains. These libraries have significant disadvantages over professional runtime libraries for embedded systems. emRun converts any GCC-based toolchain into a professional development choice.
In many cases, the ROM-savings of emRun enable the use of a smaller microcontroller with less on-chip memory. This can result in significant cost savings, especially for devices built in large quantities for the mass market.
For detailed information visit the product page on segger.com.
Contents
Who benefits from this product?
There are three classes of customer for this product and three variants:
- End users that wish to replace newlib, newlib-nano, or some other vendor-supplied library with emRun in order to reduce code footprint. In this case, the library is already configured for the target architecture and delivered ready for customer integration into the IDE.
- Silicon vendors that wish to license emRun in order to offer it to their customers in place of newlib or newlib-nano as a competitive advantage. In this case, the silicon vendor receives a library configured for the processor architecture and ABI and integrates this into their IDE on behalf of all customers.
- Processor IP vendors that wish to bring up a processor and associated toolset, for a proprietary architecture, where there is no pre-existing runtime library. In this case, the customer receives an architecture-neutral version of the runtime library, with supporting C functions, and integrates this into the compiler toolchain for their architecture.
What does the library contain?
emRun contains implementations of all Embedded C Subset functions required by the ISO standard. In addition it contains some functions that you will find in POSIX.1 and Linux that extend the C library with useful functionality.
However, an implementation of the user-facing C library API is not all that is required to run a C program on a microcontroller. All C operations that do not directly map to machine instructions must be emulated in software. Therefore emRun contains implementations of basic floating point operations, floating point conversions, and integer operations such as multiply, divide, and long shifts which use only fundamental integer data types, addition, subtraction, and shifting.
What parts of the library are machine specific?
Although emRun has C implementations of the required C API and runtime API, implementation of setjmp()
and longjmp()
are highly compiler, ABI, and machine specific. The SEGGER Runtime Library contains implementations for Arm and RISC-V using standard ABIs, but if you are bringing up the library on a different processor, or using a nonstandard ABI, you will need to implement both setjmp()
and longjmp()
yourself.
What ports exist for the library?
emRun is already widely deployed and is built into SEGGER's Embedded Studio for both Arm and RISC-V processor architectures.
Arm port
The Arm port confirms to Arm's procedure calling standard for all supported architectures and also the run-time ABI for the Arm Architecture. It provides all required C functions and also the required runtime ABI functions with the correct ABI names. 32-bit and 64-bit integer operations (where required) are written in assembly language. Floating point emulation is written entirely in assembly language, for processors that have no hardware floating point, for both speed and compactness.
RISC-V port
The RISC-V port integrates with the GNU C compiler and provides runtime support using the standard GNU runtme support naming scheme (such as __addsf3
which implements single-precision floating-point addition).
Architecture-neutral port
The architecture-neutral distribution contains functions written in C that allow toolset bootstrapping. The requirements made of the compiler are rudimentary, all that is required is basic integer and unsigned operations, up to 32 bits in width, to be provided. For machines without multiply or divide instructions, runtime support is emulated in plain C. IEEE single-precision and double-precision floating-point and 64-bit arithmetic is written in C. Once basic functionality is attained, the compiler and runtime system can be enhanced by replacing runtime support in C with runtime support in assembly language, one function at a time.
Performance Benchmark
emRun is designed for fast and efficient execution. A summary of performance numbers and comparison with gcclib / newlib is available at http://www.segger.com/emrun.
This is the description for the test projects. The test projects have been designed to measure the performance of C library functions as well as low-level runtime ABI functions.
The complete test source is included in the emRun source distribution.
Floating-Point Arithmetic
Test the arithmetic functions of the IEEE-754 floating-point emulation. These functions are used for low-level floating point operations which cannot be done in hardware, e.g. due to missing floating-point unit.
Each function is tested with a set of inputs throughout the range of valid parameters.
IEEE-754 Floating-point Library Benchmarks
Copyright (c) 2018-2022 SEGGER Microcontroller GmbH.
System: emRun v4.22.0 + emFloat v2.8.0
System: Compiled with GNU C Compiler 12.2.0
Target: RV32IMAC
Target: Little-endian byte order
Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size
Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point
Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers
Config: With assembly-coded FP acceleration
Config: With fully conformant NaNs
Config: With assembly-coded string acceleration
======================
GNU libgcc API
======================
Function Min Max Avg Description
-------------- ------ ------ ------ -----------------------------------------
__addsf3 37 46 41.8 Random distribution over (0, 1), operands differ
__subsf3 32 51 44.8 Random distribution over (0, 1), operands differ
__mulsf3 32 37 34.3 Random distribution over (0, 1), operands differ
__divsf3 65 65 65.0 Random distribution over (0, 1), operands differ
__ltsf2 11 11 11.0 Random distribution over (0, 1), operands differ
__lesf2 10 10 10.0 Random distribution over (0, 1), operands differ
__gtsf2 10 10 10.0 Random distribution over (0, 1), operands differ
__gesf2 11 11 11.0 Random distribution over (0, 1), operands differ
__eqsf2 10 10 10.0 Random distribution over (0, 1), operands differ
__nesf2 10 10 10.0 Random distribution over (0, 1), operands differ
-------------- ------ ------ ------ -----------------------------------------
__adddf3 43 64 53.4 Random distribution over (0, 1), operands differ
__subdf3 49 94 67.0 Random distribution over (0, 1), operands differ
__muldf3 57 70 62.1 Random distribution over (0, 1), operands differ
__divdf3 188 192 191.2 Random distribution over (0, 1), operands differ
__ltdf2 13 14 13.4 Random distribution over (0, 1), operands differ
__ledf2 13 14 13.4 Random distribution over (0, 1), operands differ
__gtdf2 13 14 13.6 Random distribution over (0, 1), operands differ
__gedf2 13 14 13.6 Random distribution over (0, 1), operands differ
__eqdf2 14 14 14.0 Random distribution over (0, 1), operands differ
__eqdf2 14 14 14.0 Random distribution over (0, 1), operands differ
-------------- ------ ------ ------ -----------------------------------------
__fixsfsi 14 14 14.0 Random distribution over (-2^31.., 1..2^31)
__fixdfsi 6 16 13.3 Random distribution over (-2^31.., 1..2^31)
__fixsfdi 15 21 18.0 Random distribution over (-2^63..1, 1..2^63)
__fixdfdi 7 28 23.7 Random distribution over (-2^63..1, 1..2^63)
__fixunssfsi 12 12 12.0 Random distribution over (1..2^31)
__fixunsdfsi 5 13 9.7 Random distribution over (1..2^31)
__fixunssfdi 14 18 16.0 Random distribution over (-2^63..2^63)
__fixunsdfdi 7 23 20.3 Random distribution over (-2^63..2^63)
-------------- ------ ------ ------ -----------------------------------------
__floatsisf 26 34 29.5 Random distribution over (-2^31.., 1..2^31)
__floatdisf 26 45 35.7 Random distribution over (-2^63..1, 1..2^63)
__floatsidf 22 30 25.2 Random distribution over (-2^31.., 1..2^31)
__floatdidf 19 51 34.5 Random distribution over (-2^63..1, 1..2^63)
__floatunsisf 21 29 24.5 Random distribution over (1..2^31)
__floatundisf 23 38 30.7 Random distribution over (-2^63..2^63)
__floatunsidf 17 25 20.2 Random distribution over (1..2^31)
__floatundidf 16 44 29.5 Random distribution over (-2^63..2^63)
-------------- ------ ------ ------ -----------------------------------------
__extendsfdf2 12 12 12.0 Random distribution over (-2^63..1, 1..2^63)
__truncdfsf2 25 25 25.0 Random distribution over (-2^63..1, 1..2^63)
============== ====== ====== ====== =========================================
Total 1097.4 Totalized average time over all functions
============== ====== ====== ====== =========================================
STOP.
Floating-Point Math
Test the user-facing C library functions related to floating-point operations. The tests measure performance of the functions with different input as well as accuracy against known answers.
IEEE-754 Floating-point Performance and Accuracy Benchmark
Copyright (c) 2018-2022 SEGGER Microcontroller GmbH.
System: emRun v4.22.0 + emFloat v2.8.0
System: Compiled with GNU C Compiler 12.2.0
Target: RV32IMAC
Target: Little-endian byte order
Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size
Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point
Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers
Config: With assembly-coded FP acceleration
Config: With fully conformant NaNs
Config: With assembly-coded string acceleration
Avg ulps RMS ulps Max ulps
Function Error Error Error Cycles Avg/fn
---------- -------- -------- -------- -------- --------
sqrtf 0.28 0.34 0.74 593923 580.00
cbrtf 0.50 0.62 1.82 448798 880.00
sinf 0.36 0.44 1.31 486983 893.55
cosf 0.36 0.43 1.31 517241 985.22
tanf 0.49 0.61 1.85 547780 1138.84
asinf 0.46 0.60 1.97 730189 1415.09
acosf 0.43 0.53 1.48 1467852 1433.45
atanf 0.38 0.47 1.54 540749 1090.22
expf 0.29 0.35 1.13 1003703 919.14
logf 0.25 0.29 0.63 371219 725.04
sinhf 0.30 0.37 1.21 369480 730.20
coshf 0.35 0.43 1.66 1134471 1107.88
tanhf 0.21 0.28 1.12 497954 997.90
asinhf 0.30 0.39 2.18 858631 1626.20
acoshf 0.29 0.36 1.68 1672202 1633.01
atanhf 0.16 0.35 1.76 294554 416.63
fabsf 0.00 0.00 0.00 9216 9.00
ceilf 0.00 0.00 0.00 12661 24.30
floorf 0.00 0.00 0.00 6480 27.00
frexpf_s 0.00 0.00 0.00 14326 26.00
frexpf_e 0.00 0.00 0.00 60416 59.00
modff_i 0.00 0.00 0.00 12040 35.00
modff_f 0.00 0.00 0.00 5130 30.00
hypotf 0.31 0.38 1.14 740649 723.29
atan2f 0.43 0.53 2.20 1389962 1353.42
powf 0.43 0.66 6.10 1724424 1669.34
fmodf 0.00 0.00 0.00 57793 56.44
fminf 0.00 0.00 0.00 15915 15.51
fmaxf 0.00 0.00 0.00 15921 15.52
ldexpf 0.00 0.00 0.00 40199 46.91
========== ======== ======== ======== ======== ========
All 0.00 0.06 6.10 15640861 714.03
========== ======== ======== ======== ======== ========
STOP.
Integer Arithmetic
Test the arithmetic integer functions. These functions are used for low-level integer arithmetic and conversion operations which cannot be done in hardware.
Each function is tested with a set of inputs throughout the range of valid parameters.
Integer Arithmetic Benchmarks
Copyright (c) 2018-2022 SEGGER Microcontroller GmbH.
System: emRun v4.22.0
System: Compiled with GNU C Compiler 12.2.0
Target: RV32IMAC
Target: Little-endian byte order
Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size
Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point
Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers
Config: With assembly-coded FP acceleration
Config: With fully conformant NaNs
Config: With assembly-coded string acceleration
Function Min Max Avg Description
---------------- ------ ------ ------ -------------------------------
__ashldi3 4 8 6.0 13440 cycles (2240 tests)
__lshrdi3 4 8 6.0 13440 cycles (2240 tests)
__ashrdi3 4 8 6.0 13440 cycles (2240 tests)
__mulsi3 1 1 1.0 171 cycles (171 tests)
__muldi3 7 7 7.0 4165 cycles (595 tests)
__divsi3 1 1 1.0 684 cycles (684 tests)
__modsi3 1 1 1.0 684 cycles (684 tests)
__udivsi3 1 1 1.0 171 cycles (171 tests)
__umodsi3 1 1 1.0 171 cycles (171 tests)
__divdi3 27 129 64.7 154216 cycles (2380 tests)
__moddi3 30 124 66.4 158260 cycles (2380 tests)
__udivdi3 7 101 42.1 25052 cycles (595 tests)
__umoddi3 12 105 48.0 28610 cycles (595 tests)
================ ====== ====== ====== ===============================
Grand total 251.2 412504 cycles (15146 tests)
================ ====== ====== ====== ===============================
STOP.
String and Memory Functions
Test C library functions for copying, moving, setting, searching, comparing strings or memory.
The tests measure performance with inputs of different length and different alignment.
String/Memory Function Benchmarks
Copyright (c) 2018-2022 SEGGER Microcontroller GmbH.
System: emRun v4.22.0
System: Compiled with GNU C Compiler 12.2.0
Target: RV32IMAC
Target: Little-endian byte order
Config: SEGGER_RTL_OPTIMIZE = 2 // Optimize for speed at the expense of size
Config: SEGGER_RTL_FP_HW = 0 // No FPU, software floating point
Config: SEGGER_RTL_FP_ABI = 0 // Floats and doubles in core registers
Config: With assembly-coded FP acceleration
Config: With fully conformant NaNs
Config: With assembly-coded string acceleration
strlen():
Aligned empty string : 21
Misaligned empty string : 12
Aligned 1-char string : 24
Misaligned 1-char string : 17
Aligned 255-char string : 425
Misaligned 255-char string : 431
--------------------------------------------
Total : 930
strchr():
Aligned empty string : 33
Misaligned empty string : 15
Aligned 1-char string : 32
Misaligned 1-char string : 14
Aligned 255-char string : 800
Misaligned 255-char string : 806
--------------------------------------------
Total : 1700
strcmp():
Aligned empty strings : 28
Misaligned empty strings : 16
Aligned 1-char string : 28
Misaligned 1-char string : 16
Aligned 255-char string : 572
Equally-misaligned 255-char string : 1546
Unequally-misaligned 255-char string : 1539
--------------------------------------------
Total : 3745
strcpy():
Aligned empty string : 25
Misaligned empty string : 13
Aligned 1-char string : 25
Misaligned 1-char string : 13
Aligned 255-char string : 670
Equally-misaligned 255-char string : 1288
Unequally-misaligned 255-char string : 1283
--------------------------------------------
Total : 3317
memset():
Aligned empty string : 9
Misaligned empty string : 9
Aligned 1-char string : 24
Misaligned 1-char string : 16
Aligned 255-char string : 139
Misaligned 255-char string : 145
--------------------------------------------
Total : 342
memcmp():
Aligned empty strings : 19
Misaligned empty strings : 14
Aligned 1-char string : 37
Misaligned 1-char string : 23
Aligned 255-char string : 300
Equally-misaligned 255-char string : 309
Unequally-misaligned 255-char string : 1078
--------------------------------------------
Total : 1780
memchr():
Aligned empty string : 30
Misaligned empty string : 21
Aligned 1-char string : 62
Misaligned 1-char string : 60
Aligned 255-char string : 984
Misaligned 255-char string : 993
--------------------------------------------
Total : 2150
memcpy():
Aligned empty string : 6
Misaligned empty string : 6
Aligned 1-char string : 25
Misaligned 1-char string : 19
Aligned 255-char string : 219
Equally-misaligned 255-char string : 225
Unequally-misaligned 255-char string : 1542
--------------------------------------------
Total : 2042
memmove():
Aligned empty string : 23
Misaligned empty string : 12
Aligned 1-char string : 26
Misaligned 1-char string : 25
Aligned 255-char string : 215
Equally-misaligned 255-char string : 230
Unequally-misaligned 255-char string : 604
--------------------------------------------
Total : 1135
============================================
Grand total : 17141
============================================
No failures from 32 tests
STOP.