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

int128 on Linux for Intel compiler

alexvi
Beginner
4,409 Views

Linux 2.6.32

Intel compiler: icpc version 13.0.1 (gcc version 4.4.6 compatibility)

#include <iostream> #include <sys/types.h> int main() {     std::cerr << sizeof (__uint128_t) << std::endl;         return 0; } Output: 16

So, type __uint128_t exists.  However, working with __uint128_t produces compilation and run errors.

 

Programs:

------------------ File int01.cpp #include <cstdint> int main() {  uint128_t val128 = 0;  return 0; }

------------------ File int02.cpp #include <cstdint> int main() {  __uint128_t val128 = 0;  return 0; }

------------------ File int03.cpp #include <iostream> #include <cstdint> int main() {  __uint128_t val128 = 0;  std::cerr << val128 << std::endl;  return 0; }

Compilations:

> icpc int01.cpp /usr/include/c++/4.4.6/c++0x_warning.h(31): catastrophic error: #error directive: This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.   #error This file requires compiler and library support for the upcoming \    ^

compilation aborted for int01.cpp (code 4)

> icpc int01.cpp -std=c++0x int01.cpp(4): error: identifier "uint128_t" is undefined    uint128_t val128 = 0;    ^

compilation aborted for int01.cpp (code 2)

> icpc int02.cpp -std=c++0x // No errors

> icpc int03.cpp -std=c++0x

int03.cpp(6): error: more than one operator "<<" matches these operands:             function "std::basic_ostream<_CharT, _Traits>::operator<<(long) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(unsigned long) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(short) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(unsigned short) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(long long) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(unsigned long long) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT=char, _Traits=std::char_traits<char>]"             function "std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT=char, _Traits=std::char_traits<char>]"             operand types are: std::ostream << __uint128_t    std::cerr << val128 << std::endl;              ^

compilation aborted for int03.cpp (code 2)

 

 

0 Kudos
29 Replies
alexvi
Beginner
946 Views

> Did you miss *t* in *__uint128_*?

Of course. Thanks

stdint.h attached

 

 

 

0 Kudos
alexvi
Beginner
946 Views

Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 13.0.1.117 Build 20121010 Copyright (C) 1985-2012 Intel Corporation.  All rights reserved.

 

0 Kudos
SergeyKostrov
Valued Contributor II
946 Views
Just for reference. Please take a look at: software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
0 Kudos
TimP
Honored Contributor III
946 Views

int128_t doesn't appear in that copy of stdint.h nor in any I can find among my installations of gcc 4.4 or 4.8.  I thought when I saw such things in the past it was treated as a case of __m128i.  If it's done internal to gcc and not expressed in a header file, icc can't share it with gcc.

If gcc defines the usual arithmetic operations on such data types, it would appear to require support in libgcc. In a default build of libgcc, the only 128-bit data types are bid128.

http://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html states that int128 support requires a matching long long int data type.

0 Kudos
SergeyKostrov
Valued Contributor II
946 Views
>>... I thought when I saw such things in the past it was treated as a case of __m128i... It is declared as follows: ... typedef union __declspec(intrin_type) _CRT_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; ... and if this is the case __uint128_t needs to be considered as unsigned __int64 m128i_u64[2]. I'm still investigating...
0 Kudos
SergeyKostrov
Valued Contributor II
946 Views
Attached are four stdint.h headers and I have Not found a declaration for the type __uint128_t. Does it mean that the type is built-in?
0 Kudos
jimdempseyatthecove
Honored Contributor III
946 Views

The __m128i is a container class for use with SSE (AVX). This container class partitions the 128-bit register (and memory storage thereof) into the working uints supported by the small vector instructions. Currently this does not include (unsigned/signed) integer classes of 128-bits for arithmatic operations. Logical operations can be performed as they do not produce a carry or borrow across bit fields.

At some future date AVX may be extended to support 128-bit integers and hopefully 128-bit floating point formats. At this time this is hopeful thinking.

There are extended precision as well as arbitrary precision libraries that are available.

Jim Dempsey

0 Kudos
SergeyKostrov
Valued Contributor II
946 Views
>>...and hopefully 128-bit floating point formats... That would be helpful! >>... I have Not found a declaration for the type __uint128_t. Does it mean that the type is built-in? Here are two questions: 1. Is the type __uint128_t is built-in type supported by the most recent version of a C++ compiler ( Intel or GCC )? 2. If it is Not built-in type where is it declared and how ( I expect a typedef... )?
0 Kudos
SergeyKostrov
Valued Contributor II
946 Views
Here is a compilation output for a test case compiled with a recent version of Intel C++ compiler for Windows ( 13.x ): ... __uint128_t uiValue = 0; ... ... .\GenTestApp.cpp(31): error: identifier "__uint128_t" is undefined __uint128_t uiValue = 0; ...
0 Kudos
Reply