__libm_sse2_sincos

__libm_sse2_sincos

Hello,

Can anyone interpret "call __libm_sse2_sincos". I simply understand it as computation of sine and cosine of the same number.

I did got above during generation of .S for C/C++ source code using ICC-v11.0 on Linux x86_64 Intel Xeon 5345 processor.

Out of curiosity, wish to know the list of SSE2/SSE3/SSE4 built-in libraries (libm_sse2_sincos, etc.) to support SSE2/SSE3/SSE4 if any.

~BR
Mukkaysh Srivastav

10 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The sincos function returns both the sine and cosine of x measured in radians. This function may be inlined by the Itanium compiler.

Calling interface:
void sincos(double x, double *sinval, double *cosval);
void sincosl(long double x, long double *sinval, long double *cosval);
void sincosf(float x, float *sinval, float *cosval);

The compiler may optimize the function and use appropriate built-ins. The built-ins are not documented. You may find some of the math built-is mentioned in mathimf.h header file.

Quoting - Om Sachan (Intel)

The sincos function returns both the sine and cosine of x measured in radians. This function may be inlined by the Itanium compiler.

Calling interface:
void sincos(double x, double *sinval, double *cosval);
void sincosl(long double x, long double *sinval, long double *cosval);
void sincosf(float x, float *sinval, float *cosval);

The compiler may optimize the function and use appropriate built-ins. The built-ins are not documented. You may find some of the math built-is mentioned in mathimf.h header file.

Thanks for your input, but I did mention Intel Xeon 5345 processor, I am not sure how to conclude for "This function may be inlined by the Itanium compiler." as qouted by you for Xeon 53XX processors with ICC-v11.0.

Since you listed couple of sincos() built-ins, how can I compare and know useability (i.e., performances) of sincos() & w.r.t other fsin, fcos, __libm_SSE2_sin, etc.

What you call these type of built-in attributes for SSE2? Is this some enhanced library support for SSE(n) on Intel Xeon processors?

I did find sincos reference in "/app/intel/Compiler/11.0/074/include/mathimf.h & math.h".

Why ICC-v11.0 uses __libm_SSE2_sin, __libm_SSE2_sincos rather than fsin, fsincos, etc?

Morover, the same C/C++ code if done to generate with -O3, it has seperate "call cos" & "call sin" within .S, not able to figure out the difference with these built-in calls with seperate -On levels.

~BR

You may ignore my comment regarding Itanium. Sorry for refereing it by mistake.

The fsin and fcos instruction are available in old Intel processors. The __libm_SSE2_sin, __libm_SSE2_sincos are available in newer Intel processors (at least from Intel Pentium IV onwards) and are faster.

Depending on the compiler options, the compiler generates suitable code for the targeted platform.

Quoting - Om Sachan (Intel)

You may ignore my comment regarding Itanium. Sorry for refereing it by mistake.

The fsin and fcos instruction are available in old Intel processors. The __libm_SSE2_sin, __libm_SSE2_sincos are available in newer Intel processors (at least from Intel Pentium IV onwards) and are faster.

Depending on the compiler options, the compiler generates suitable code for the targeted platform.

I had asked something more for better understanding rather simply saying, plz have a look for above queries as asked in green color.

Looking for better explanation.

~Br

Quoting - Om Sachan (Intel)

You may ignore my comment regarding Itanium. Sorry for refereing it by mistake.

The fsin and fcos instruction are available in old Intel processors. The __libm_SSE2_sin, __libm_SSE2_sincos are available in newer Intel processors (at least from Intel Pentium IV onwards) and are faster.

Depending on the compiler options, the compiler generates suitable code for the targeted platform.

Do you have any status by now?

~BR

Not knowing specifically what you still want to know, I'll add one or two comments.
fsin, fsincos should be used only with the option /arch:ia32 of the 32-bit compiler. As these instructions use x87 top of stack register, there would be a large delay involved in moving data through memory when mixing them into SSE code.
Provision of SSE2 math functions is among the performance advantages of the Intel compilers. Although a similar math library may be expected to appear some day for gcc, it has been a long time in development.

Quoting - tim18
Not knowing specifically what you still want to know, I'll add one or two comments.
fsin, fsincos should be used only with the option /arch:ia32 of the 32-bit compiler. As these instructions use x87 top of stack register, there would be a large delay involved in moving data through memory when mixing them into SSE code.
Provision of SSE2 math functions is among the performance advantages of the Intel compilers. Although a similar math library may be expected to appear some day for gcc, it has been a long time in development.

Let say I need to call both fmod and __lib_sse2_sincos in my .S asm file and use the assembler "as" and loader "ld" as -

$as -o file.o file.s
$ld -o file file

so I get from "ld" as -
---
file.o(.text+0x68): In function `B3':
: undefined reference to `fmod'
file.o(.text+0x6d): In function `B12':
: undefined reference to `__libm_sse2_sincos'
---

If I incorporate, dynamic-linking "-lm" as "ld -o file -lm file.o", fmod is through which means fmod is define in "libm", but I get an error message from ld as -

--------
file.o(.text+0x6d): In function `B12':
: undefined reference to `__libm_sse2_sincos'
-------

As, I said earlier, __lib_sse2_sincos is defined in both ../../11.0/074/include/math.h & ../../11.0/074/include/mathimf.h , do you have any information if __libm_sse2_sincos is provided as one of the contents of any library which I can either call through static or dynamic linking

OR

How can I pass reference to __libm_sse2_sincos in .S file in .bss section of it, such that when I perform "call __lib_sse2_sincos", ld understands the memory reference of it as an address.

Also, you qouted "Although a similar math library may be expected to appear some day for gcc ..." could I either have some reference or link to it, great news .. Thanks.

~BR

You could use dumpbin or the utility of your choice to see which of the libraries provided by icc include this function, and you could generate a .s file for an example .c file to see how icc invokes it. It's not really intended to be invoked except by standard C or C++ sin/cos intrinsics, as far as I know, and I don't see a good reason for you to pursue your tack.
I haven't seen any schedule for submission of gcc-compatible SSE3 libraries.

Quoting - tim18
You could use dumpbin or the utility of your choice to see which of the libraries provided by icc include this function, and you could generate a .s file for an example .c file to see how icc invokes it. It's not really intended to be invoked except by standard C or C++ sin/cos intrinsics, as far as I know, and I don't see a good reason for you to pursue your tack.
I haven't seen any schedule for submission of gcc-compatible SSE3 libraries.

I have done that becoz of which the initial Thread for __lib_sse2_sincos was posted. I am convinced with the reason of fsin & fsincos of yours for x87 and SSE stack.....Thanks.

Looking if someone from Intel Compiler Team could suggest either with a .S prototype of calling __lib_sse2_sincos or is their any dynamic/static linking possible for __lib_sse2_sincos. Intel Compiler team might have used _lib_sse2_sincos either in .S call or as -I/../..include/mathimf.h .

~BR

Leave a Comment

Please sign in to add a comment. Not a member? Join today