Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Intrinsic function

From Wikipedia, the free encyclopedia
Function whose implementation is handled specially by the compiler
This article is about compiler intrinsic functions. For X toolkit, seeX Toolkit Intrinsics.
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Intrinsic function" – news ·newspapers ·books ·scholar ·JSTOR
(December 2009) (Learn how and when to remove this message)

Incomputer software, incompiler theory, anintrinsic function, also calledbuilt-in function orbuiltin function, is a function (subroutine) available for use in a givenprogramming language whose implementation is handled specially by thecompiler. Typically, it may substitute a sequence of automatically generatedinstructions for the original function call, similar to aninline function.[1] Unlike an inline function, the compiler has an intimate knowledge of an intrinsic function and can thus better integrate and optimize it for a given situation.

Compilers that implement intrinsic functions may enable them only when a program requestsoptimization, otherwise falling back to a default implementation provided by the languageruntime system (environment).

Vectorization and parallelization

[edit]

Intrinsic functions are often used to explicitly implementvectorization andparallelization in languages which do not address such constructs. Someapplication programming interfaces (API), for example,AltiVec andOpenMP, use intrinsic functions to declare, respectively, vectorizable andmultiprocessing-aware operations during compiling. The compiler parses the intrinsic functions and converts them into vector math or multiprocessingobject code appropriate for the targetplatform.Some intrinsics are used to provide additional constraints to the optimizer, such as values a variable cannot assume.[2]

By programming language

[edit]

C and C++

[edit]

Compilers forC andC++, of Microsoft,[3]Intel,[1] and theGNU Compiler Collection (GCC)[4]implement intrinsics that map directly to thex86single instruction, multiple data (SIMD) instructions (MMX,Streaming SIMD Extensions (SSE),SSE2,SSE3,SSSE3,SSE4,AVX,AVX2,AVX512,FMA, ...). Intrinsics allow mapping to standard assembly instructions that are not normally accessible through C/C++; e.g. bit scan and parallel operations on128 bits and256 bits.

Some C and C++ compilers provide non-portable platform-specific intrinsics. Other intrinsics (such asGNU built-ins) are slightly more abstracted, approximating the abilities of several contemporary platforms, with portablefall back implementations on platforms with no appropriate instructions.[5] It is common for C++ libraries, such asglm orSony'svector maths libraries,[6] to achieve portability viaconditional compilation (based on platform specific compiler flags), providing fully portable high-level primitives (e.g., a four-element floating-point vector type) mapped onto the appropriatelow level programming language implementations, while still benefiting from the C++ type system and inlining; hence the advantage over linking to hand-written assembly object files, using the Capplication binary interface (ABI).

Examples

[edit]

The following are examples of signatures of intrinsic functions from Intel's set of intrinsic functions.

uint64_t__rdtsc();// return internal CPU clock counteruint64_t__popcnt64(uint64_tn);// count of bits set in nuint64_t_umul128(uint64_tFactor1,uint64_tFactor2,uint64_t*HighProduct);// 64 bit * 64 bit => 128 bit multiplication__m512_mm512_add_ps(__m512a,__m512b);// calculates a + b for two vectors of 16 floats__m512_mm512_fmadd_ps(__m512a,__m512b,__m512c);// calculates a*b + c for three vectors of 16 floats

[7]

COBOL

[edit]

Intrinsic function Module forCOBOL was introduced in ANSI INCITS X3.23a-1989 and ISO 1989:1985/Amd 1:1992.

Java

[edit]

TheHotSpotJava virtual machine's (JVM)just-in-time compiler also has intrinsics for specific Java APIs.[8] Hotspot intrinsics are standard Java APIs which may have one or more optimized implementation on some platforms.

PL/I

[edit]

ANSI/ISOPL/I defines nearly 90 builtin functions.[9] These are conventionally grouped as follows:[10]: 337–338 

  • String-handling builtin functions such as INDEX, LENGTH
  • Arithmetic builtin functions such as ABS, CEIL, ROUND
  • Mathematical builtin functions like SIN, COS, LOG, ERF
  • Array-handling builtin functions, for example ANY, ALL, PROD
  • Condition-handling builtin functions like ONCODE, ONFILE
  • Storage Control builtin functions, for example ADDR, POINTER
  • Input-Output builtins: LINENO
  • Miscellaneous builtin functions like DATE and TIME

Individual compilers have added additional builtins specific to a machine architecture or operating system.

A builtin function is identified by leaving its name undeclared and allowing it to default, or by declaring itBUILTIN. A user-supplied function of the same name can be substituted by declaring it asENTRY.

References

[edit]
  1. ^ab"Intel® C++ Compiler 19.1 Developer Guide and Reference".Intel® C++ Compiler Documentation. 16 December 2019. Retrieved2020-01-17.
  2. ^The Clang Team (2020)."Clang Language Extensions".Clang 11 documentation. Retrieved2020-01-17.Builtin Functions
  3. ^MSDN."Compiler Intrinsics".Microsoft. Retrieved2012-06-20.
  4. ^GCC documentation."Built-in Functions Specific to Particular Target Machines".Free Software Foundation. Retrieved2012-06-20.
  5. ^"Vector Extensions".Using the GNU Compiler Collection (GCC). Retrieved2020-01-16.
  6. ^"Sony open sources Vector Math and SIMD math libraries (Cell PPU/SPU/other platforms)".Beyond3D Forum. Archived fromthe original on 2016-06-24. Retrieved2020-01-17.
  7. ^Intel Intrinsics
  8. ^Mok, Kris (25 February 2013)."Intrinsic Methods in HotSpot VM". Slideshare. Retrieved2014-12-20.
  9. ^ANSI X3 Committee (1976).American National Standard programming language PL/I.{{cite book}}: CS1 maint: numeric names: authors list (link)
  10. ^IBM Corporation (1995).IBM PL/I for MVS & VM Language Reference.

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Intrinsic_function&oldid=1330556058"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp