Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

question about C language-defined operations for e.g. __m128i and portability

Melanie_B_Intel
Employee
584 Views
It seems that the C language construct of static initialization are not defined for objects of type __m128i. Can the compiler generate an error message if the program uses static initializer, or is this "caveat emptor"?

Here is some documentation from the Intel Software Developer Manual vol 2,
Do not initialize __m128, __m128d, and __m128i with literals; there is no way to
express 128-bit constants.

Also, the gcc and Microsoft C define the __m128i type differently, which would make it difficult to access thecomponents of the __m128i type in a portable way(my reading of the type description is that accessing the struct/union components of__m128i type is defined.) It would be cool if we could bringgcc and Microsoft C type declarations closer to convergence. When a user's program isbuilt Linux they'll get a different underlying type definition for __m128i than if the program is being built on Windows.

Type definitions follow:

# 39 "/usr/lib/gcc/x86_64-redhat-linux/4.3.2/include/emmintrin.h" 2 3 4
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));

versus

#line 35 "c:\\program files\\microsoft visual studio 9.0\\vc\\include\\emmintrin.h"

typedef union __declspec(intrin_type) __declspec(align(16)) __m128i {
__int8 m128i_i8[16];
__int16 m128i_i16[8];
__int32 m128i_i32[4];
__int64 m128i_i64[2];
unsigned __int8 m128i_u8[16];
unsigned __int16 m128i_u16[8];
unsigned __int32 m128i_u32[4];
unsigned __int64 m128i_u64[2];
} __m128i;



Regards,
Melanie Blower
0 Kudos
2 Replies
TimP
Honored Contributor III
584 Views
If you would like icc and ICL to warn about syntax which isn't compatible with both Microsoft and gcc, you could submit a feature request with working example on your premier.intel.com account. I don't know if this would be feasible; I've noticed that icc supports SSE intrinsic syntax which doesn't work with other compilers, as well as not supporting all the 128-bit integer syntax of gcc. There is no agreed standard to work with, and Microsoft and gcc will change what they support without warning Intel.
As to persuading gcc and Microsoft to use identical extensions, they march to different drummers, and not to drummers who drum only on this forum.
0 Kudos
Melanie_B_Intel
Employee
584 Views
Quoting - tim18
If you would like icc and ICL to warn about syntax which isn't compatible with both Microsoft and gcc, you could submit a feature request with working example on your premier.intel.com account. I don't know if this would be feasible; I've noticed that icc supports SSE intrinsic syntax which doesn't work with other compilers, as well as not supporting all the 128-bit integer syntax of gcc. There is no agreed standard to work with, and Microsoft and gcc will change what they support without warning Intel.
As to persuading gcc and Microsoft to use identical extensions, they march to different drummers, and not to drummers who drum only on this forum.

Thanks for your reply, Tim. My original post was mixing 2 ideas:
1. Can the compiler warn about the usage of static initializer for __m128i
2. The underlying type definitions provided by gcc and Microsoft C are different, and it may create a source code portability issue.

My understanding is that the language intrinsics were created to support Intel hardware, so it seems like Intel would more-or-less provide the underlying type definition. I will continue to investigate.

Regards,
Melanie Blower
0 Kudos
Reply