Linux Kernel floating point simulation

Source: Internet
Author: User

When I recently read the kernel version of Linux kernel,It is found that the kernel has a module that simulates floating point operations.

 

In the ARCH/MIPS/Math-emu/directory, the kernel uses integer operations to simulate floating point operations. Why?

 

Originally, many embedded chips do not have floating point operations. Why? The power consumption and cost of floating point operations are very large. For Embedded chips, it is sometimes worth saving costs by sacrificing efficiency.

 

However, these operations are implemented in the kernel and common applicationsProgramHow to use it? When a user process uses floating-point operations, it is first compiled into floating-point operation commands, but the chip does not have these commands, so an exception occurs, the exception handling function entry is the entry of the preceding module (this is set during kernel initialization ).

 

Therefore, the user State is transferred to the kernel state for simulation and the result is returned. However, at this point, I have noticed a problem: Is this highly efficient?

Indeed, this efficiency is relatively low for two reasons:

An exception is required for each floating point operation. switching between the user State and the kernel state is required;

The kernel simulates floating-point operations through integer operations. In addition, the efficiency of case-by-case comparison between different commands is also relatively low.

 

Due to the above problems, it is said that some adopt soft simulation, that is, links are made in the form of libraries. Use cross-compilation to give correct parameters, just as the math-LM compilation saves the exception switching mentioned above. I have never been involved, and I have never made too many guesses.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.