SIMD-based high-performance mathematical function runtime library optimization method and system
By optimizing the mathematical function library on the ReWorks operating system, utilizing SIMD technology, and adopting the methods of range reduction, test quadrant, and Taylor polynomial expansion approximation, we have achieved vectorized calculation of high-performance mathematical functions, solved the problem of insufficient performance in existing technologies, and improved the computing efficiency of the ARMV8 platform.
Patent Information
- Application Number
- CN202510764773.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-10-17
AI Technical Summary
Existing technologies fail to fully utilize SIMD technology on the ReWorks operating system platform to improve the performance of mathematical functions, resulting in insufficient performance in processing big data and computationally intensive systems.
A high-performance SIMD-based mathematical function runtime library optimization method is used to optimize the implementation of sin, cos, tan, and log functions by reducing function range, testing quadrants, Taylor polynomial expansion approximation, and SIMD instruction vectorized code.
Improved the mathematical function computing performance of the ReWorks platform, especially improved the efficiency of single instruction multiple data computing on the ARMV8 platform.
Smart Images

Figure CN120804485A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of basic mathematical operation library, and particularly relates to an optimization method and system of a high-performance mathematical function runtime library based on SIMD. BACKGROUND
[0002] The FT series processor is a general-purpose CPU developed by Feiteng Information Technology Co., Ltd., and the FT-2000 / 4 chip integrates four high-efficiency processor cores FTC663 independently developed by Feiteng, is compatible with the 64-bit ARMv8 instruction set and supports ARM64 and ARM32 execution modes, supports single-precision and double-precision floating-point operation instructions and ASIMD processing instructions, and with the development of processor architecture, in order to better support parallelism, the single instruction multiple data (Single Instruction, Multiple Data, SIMD) technology has gradually developed and has become the mainstream technology of current processors, especially in video, image and signal processing, which can greatly improve performance, and the domestic Feiteng CPU also supports this technology (SIMD NEON technology).
[0003] The ReWorks embedded operating system is an embedded real-time operating system independently developed by China Electronics Technology Group No. 32 based on the technical achievements of the "Ninth Five-Year Plan" and the "Tenth Five-Year Plan", and has all the source codes. It is suitable for various target hardware environments (armv8, x86, mips, and Loongson). The ReWorks operating system is developed using object-oriented and microkernel technologies, has strong real-time performance, scalability and scalability, and also supports regional and partition memory management mechanisms, as well as various network protocols, and is widely used in industrial control, rail transit, equipment electronics, and ship electronics.
[0004] Mathematics is the foundation of computers and the core component of computer science, such as algorithm design and analysis, data structure, machine learning and statistics, network security, graphics, signal processing, artificial intelligence, etc. They not only provide theoretical basis and tools for these fields, but also support modern high-performance computing and artificial intelligence development. For example, trigonometric functions and basic mathematical libraries are required for signal processing, graphics processing, game development, robotics and automatic control, network and geographic information systems (GIS).
[0005] In the processing of big data and computing-intensive systems, the performance requirements are very high and the real-time performance is strong. For example, for media video images, signal multi-band processing, etc.; on the embedded platform, the code size and library size will have requirements, and the performance requirements are also very high, which requires the system and CPU advantages to be fully utilized to improve performance. Therefore, a high-performance mathematical function runtime library optimization method is needed. SUMMARY
[0006] The application aims to provide an optimization method and system of a high-performance mathematical function library based on SIMD, implementation and optimization of sin, cos, tan, log functions based on ReWorks operating system, high-performance optimization of mathematical trigonometric functions and basic mathematical operation library, fast fusion of external optimization code and improvement of code pipeline operation through vectorization of system basic mathematical functions by using SIMD instructions.
[0007] The application provides an optimization method of a high-performance mathematical function library based on SIMD, which optimizes the high-performance mathematical function library through high-performance mathematical trigonometric function sin, high-performance mathematical trigonometric function cos(x), high-performance mathematical trigonometric function tan(x) and high-performance mathematical function logf(x), wherein,
[0008] The implementation of the high-performance mathematical trigonometric function sin includes the following steps:
[0009] 1) Range reduction: reduce the radian x in the function sin(x) to and the like calculation;
[0010] 2) Test quadrant: set the sign of the value of sin(x) according to the value of the radian x in the function sin(x), the sign bit is 0, then it is positive, sin(x)>0, the sign bit is 1, and sin(x)<0;
[0011] 3) Taylor polynomial expansion approximates the value of sin(x), and the formula is as follows:
[0012]
[0013] 4) CPU single instruction multiple data (SIMD) vectorization code;
[0014] The implementation of the high-performance mathematical trigonometric function cos(x) includes the following steps:
[0015] The implementation of cos(x) is special, which is realized by cos(x)=sin(x+π / 2), so most of the implementation process is consistent with that of sin(x), and the specific process is as follows:
[0016] 1) Range reduction: reduce the radian x in the function sin(x) to and the like calculation;
[0017] 2) Test quadrant: set the sign of the value of sin(x) according to the value of the radian x in the function sin(x), the sign bit is 0, then it is positive, sin(x)>0, the sign bit is 1, and sin(x)<0;
[0018] 3) Taylor polynomial expansion approximation sin(x) value, formula as shown below:
[0019]
[0020] 4) cos(x) = sin(x + π / 2), the implementation of cos(x) is equal to the x offset π / 2 of sin(x).
[0021] 5) cpu single instruction multiple data SIMD vectorization code.
[0022] The implementation of the high-performance mathematical trigonometric function tan(x) includes the following steps:
[0023] 1) reduce the range: the radian x in the function tan(x) is reduced to range such as calculation;
[0024] 2) test quadrant: set the sign of sin(x) according to the value of radian x in the function sin(x), the sign bit is 0, which is positive and sin(x) > 0, the sign bit is 1 and sin(x) < 0;
[0025] 3) Taylor polynomial expansion approximation sin(x) value, formula as shown below:
[0026]
[0027] 4) calculate cos 2 x = 1 - sin 2 x value;
[0028] 5) according to Newton iteration method to find value;
[0029] 6) calculate value, that is, the value of tan(x);
[0030] 7) cpu instruction SIMD vectorization code;
[0031] The implementation of the high-performance mathematical function logf(x) includes the following steps:
[0032] 1) input the value of logf(float x) function x;
[0033] 2) extract float type exponent bit index, float exponent bit is 8bit, offset 127;
[0034] 3) extract float type exponent bit index, float decimal bit 23bit;
[0035] 4) extract decimal bit index part by Taylor expansion polynomial, formula as follows:
[0036]
[0037] 5) Add an exponent, including an integer part exponent and a decimal part exponent;
[0038] 6) SIMD instruction vectorizes all code.
[0039] The application further provides an optimization system of a high-performance mathematical function library based on SIMD, comprising an optimization module, which executes the optimization method of the high-performance mathematical function library based on SIMD.
[0040] The application further provides a non-transitory computer readable storage medium, which stores computer instructions, and the computer instructions are executed by a processor to implement the optimization method of the high-performance mathematical function library based on SIMD.
[0041] The application further provides an electronic device, comprising:
[0042] a memory and a processor, which are connected in communication with each other, and the memory stores computer instructions, and the processor executes the computer instructions to execute the optimization method of the high-performance mathematical function library based on SIMD.
[0043] By the optimization method and system of the high-performance mathematical function library based on SIMD, high-performance mathematical basic algorithms are provided, and the problem of the single instruction multiple data calculation basic mathematical library of the ReWorks (FT2000 / 4) platform is solved, and the performance of the ARMV8 platform is improved.
[0044] The above description is only a summary of the technical scheme of the application, in order to more clearly understand the technical means of the application, and the content of the description can be implemented, the following preferred embodiments of the application are described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 The implementation flowchart of the vectorized trigonometric function sin(x) of the application;
[0046] Figure 2 The implementation flowchart of the vectorized trigonometric function cos(x) of the application;
[0047] Figure 3 The implementation flowchart of the vectorized trigonometric function tan(x) of the application;
[0048] Figure 4 The implementation flowchart of the vectorized trigonometric function logf(x) of the application;
[0049] Figure 5 Figure 1 is a schematic diagram of an electronic device according to the present application. DETAILED DESCRIPTION
[0050] The specific embodiments of the present application will be further described in conjunction with the drawings and examples. The following examples are used to illustrate the present application but are not intended to limit the scope of the present application.
[0051] This embodiment is directed to a high performance mathematical function algorithm which simplifies the operation by using Taylor polynomial and vectorization by using SIMD instruction.
[0052] As shown in the figure, the high performance mathematical trigonometric function sin(x) implementation includes the following steps: Figure 1
[0053] 1. Reduce the range: reduce the radian x in the function sin(x) to the range of
[0054] 2. Test the quadrant: set the sign of the value of sin(x) according to the value of the radian x in the function sin(x), the sign bit is 0, then sin(x) > 0, the sign bit is 1, then sin(x) < 0.
[0055] 3. Taylor polynomial expansion approximates the value of sin(x), the formula is as follows:
[0056]
[0057] 4. CPU single instruction multiple data SIMD vectorization code.
[0058] As shown in the figure, the high performance mathematical trigonometric function cos(x) implementation includes the following steps: Figure 2 The implementation of cos(x) is relatively special, which is implemented by cos(x) = sin(x + π / 2), so most of the implementation process is consistent with that of sin(x), and the specific process is as follows:
[0059] 1) Reduce the range: reduce the radian x in the function sin(x) to the range of
[0060]
[0061] 2) Test the quadrant: set the sign of the value of sin(x) according to the value of the radian x in the function sin(x), the sign bit is 0, then sin(x) > 0, the sign bit is 1, then sin(x) < 0.
[0062] 3) Taylor polynomial expansion approximates the value of sin(x), the formula is as follows:
[0063]
[0064] 4) cos(x) = sin(x + π / 2), the implementation of cos(x) is equal to the x offset π / 2 of sin(x).
[0065] 5) cpu single instruction multiple data (SIMD) vectorized code.
[0066] Referring to FIG. 1, a high-performance mathematical function tan(x) implementation includes the following steps: Figure 3 Referring to FIG. 1, a high-performance mathematical function tan(x) implementation includes the following steps:
[0067] 1, reduce the range: reduce the radian x in the function tan(x) to range such as calculation.
[0068] 2, test the quadrant: set the sign of the value of sin(x) according to the value of radian x in the function sin(x), the sign bit is 0, then it is positive and sin(x) > 0, the sign bit is 1 and sin(x) < 0.
[0069] 3, Taylor polynomial expansion approximates the value of sin(x), the formula is as follows:
[0070]
[0071] 4, calculate the value of cos 2 x = 1 - sin 2 x.
[0072] 5, according to Newton iteration method to find the value of .
[0073] 6, calculate the value of , that is the value of tan(x).
[0074] 7, cpu instruction SIMD vectorized code.
[0075] Referring to FIG. 2, a high-performance mathematical function logf(x) implementation includes the following steps: Figure 4
[0076] 1, input the value of x of the function logf(float x).
[0077] 2, extract the float type exponent bit exponent, such as float exponent bit is 8bit, offset 127.
[0078] 3, extract the float type exponent bit exponent, such as float decimal bit 23bit.
[0079] 4, extract the decimal bit exponent part by Taylor expansion polynomial, the formula is as follows:
[0080]
[0081] 5. Add exponent (integer part exponent and decimal part exponent).
[0082] 6. SIMD instruction vectorizes all code.
[0083] The embodiment also provides an optimization system of a high-performance mathematical function library based on SIMD, comprising an optimization module which executes the optimization method of the high-performance mathematical function library based on SIMD.
[0084] The embodiment also provides a non-transitory computer readable storage medium which stores computer instructions, and the computer instructions are executed by a processor to implement the optimization method of the high-performance mathematical function library based on SIMD.
[0085] Referring to the drawings, Figure 5 The embodiment also provides an electronic device, which comprises:
[0086] The memory 201 and the processor 202 are in communication connection with each other, the memory 201 stores computer instructions, and the processor 202 executes the computer instructions to implement the optimization method of the high-performance mathematical function library based on SIMD.
[0087] The above merely describes the preferred embodiments of the present application and is not intended to limit the present application, and it should be noted that, for those skilled in the art, without departing from the technical principles of the present application, a number of improvements and modifications can be made, and these improvements and modifications should also be considered as the protection scope of the present application.
Claims
1. A method for optimizing a high-performance mathematical function runtime library based on SIMD, characterized in that: The high-performance mathematical function runtime library is optimized through the high-performance mathematical trigonometric function sin, high-performance mathematical trigonometric function cos(x), high-performance mathematical trigonometric function tan(x), and high-performance mathematical function logf(x). The implementation of the high-performance mathematical trigonometric function sin includes the following steps: 1) Reduce the range: Reduce the radian x in the sin(x) function to Range and other calculations; 2) Test quadrant: Set the sign of the sin(x) value according to the value of radian x in the sin(x) function. If the sign bit is 0, it is positive. If sin(x)>0, the sign bit is 1, and if sin(x)<0; 3) Taylor polynomial expansion approximates the value of sin(x), the formula is as follows: 4) CPU single instruction multiple data SIMD vectorized code; The implementation of the high-performance mathematical trigonometric function cos(x) comprises the following steps: The implementation of cos(x) is quite special, and is implemented by cos(x) = sin(x + π / 2). Therefore, the implementation process is mostly the same as that of sin(x). The specific process is as follows: 1) Reduce the range: Reduce the radian x in the sin(x) function to Range and other calculations; 2) Test quadrant: Set the sign of the sin(x) value according to the value of radian x in the sin(x) function. If the sign bit is 0, it is positive. If sin(x)>0, the sign bit is 1, and if sin(x)<0; 3) Taylor polynomial expansion approximates the value of sin(x), the formula is as follows: 4) cos(x) = sin(x + π / 2), the realization of cos(x) is equal to sin(x) with x offset by π / 2. 5)CPU Single Instruction Multiple Data SIMD vectorized code. The implementation of the high performance mathematical trigonometric function tan(x) comprises the following steps: 1) Reduce the range: Reduce the radian x in the function tan(x) to Range and other calculations; 2) Test quadrant: Set the sign of the sin(x) value according to the value of radian x in the sin(x) function. If the sign bit is 0, it is positive and sin(x)>0; if the sign bit is 1, sin(x)<0; 3) Taylor polynomial expansion approximates the value of sin(x), the formula is as follows: 4) Calculate cosine 2 x=1-sin 2 The value of x; 5) According to Newton's iteration method, The value of 6) Calculation The value of , that is, the value of tan(x); 7) CPU instruction SIMD vectorized code; The implementation of the high performance mathematical function logf(x) comprises the following steps: 1) Input the value of x in the logf(float x) function; 2) Extract the float type exponent bit index, the float exponent bit is 8 bits, and the offset is 127; 3) Extract the exponent of float type, the float decimal place is 23 bits; 4) Extract the decimal exponent part through Taylor expansion polynomial. The formula is as follows: 5) Add exponents, including integer and fractional exponents; 6) SIMD instructions vectorize all codes.
2. An optimization system for a high-performance mathematical function runtime library based on SIMD, characterized in that: It includes an optimization module, which executes the optimization method of the SIMD-based high-performance mathematical function runtime library as described in claim 1.
3. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the optimization method of the SIMD-based high-performance mathematical function runtime library as claimed in claim 1 is implemented.
4. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the optimization method of a high-performance mathematical function runtime library based on SIMD as claimed in claim 1 by executing the computer instructions.