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

support for 128 bit integer types

Daniel_D
Beginner
1,077 Views

Hi,

 

I need for a project a 128 bit integer data type. As far as I could find out the intel compiler supports __int128 and __uint128. This works fine as long as I do not use %. Here is a complete sample to reproduce the problem:

Environment:

  • windows 11, all updates
  • intel C++ 2024 latest version

 

 

int main()
{
__int128 l_i128Result = 12345678;
l_i128Result %= 13;
}

 

 

 

output:

 

 

1>R:\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(4,11): : warning : variable 'l_i128Result' set but not used [-Wunused-but-set-variable]
1> 4 | __int128 l_i128Result = 12345678;
1> | ^
1>1 warning generated.
1>ConsoleApplication1.obj : : error LNK2019: unresolved external symbol __modti3 referenced in function main
1>R:\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : : error LNK1120: 1 unresolved externals
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

 

 

 

I could not find out which library I need to add to fix this function call.

Thanks for your help.

Labels (2)
0 Kudos
1 Solution
cw_intel
Moderator
535 Views

Hi,


This issue is resolved with the clang builtins library. You can build the code with the library clang_rt.builtins-x86_64.lib, for example,

icx-cl.exe /Od ConsoleApplication1.cpp clang_rt.builtins-x86_64.lib


This library was not available in the 2024.0 release, but we have it in the 2024.1 release that become available for download now. Please download the 2024.1 release.


Thanks.





View solution in original post

0 Kudos
12 Replies
Alex_Y_Intel
Moderator
1,013 Views

Hi @Daniel_D
What's the command used in this case? 
 

0 Kudos
Daniel_D
Beginner
1,010 Views

I created a new console project for the intel compiler. Add the lines of code and click on compile. I use the intel project template.

Is it that you are asking or does your question point to something else?

0 Kudos
Alex_Y_Intel
Moderator
990 Views

@Daniel_D it looks like you used Visual Studio instead of Intel oneAPI command prompt?

0 Kudos
Daniel_D
Beginner
988 Views

Yes- all in VS:

Create a new c++ console project. Add the few code lines. Switch to intel compiler and click on compile.

 

I already found a workaround and use boost:

#include "boost/multiprecision/cpp_int.hpp"
using namespace boost::multiprecision;

it comes with the types I need.

 

0 Kudos
Theo-at-Stillwater
638 Views

Hi Daniel:

 

boost::multiprecision is an arbitrary precision library that does NOT mimic a fixed-sized type like __int128. So any linear algebra you want to do will not have 'nice' memory layouts because the boost::multiprecision are not byte packed. A number system library that does is Universal (https://github.com/stillwater-sc/universal)

There are custom 128bit integers in the Universal Numbers library 

In Universal you can ask for a specific integer parameterized in size, for example, integer<128>, for a 128-bit integer. Universal allows for parameterization at single bit precision, so if you want a 97 bit integer, you can get one via the declaration: integer<97>.

Universal is a headers-only lib, so all you would need to do is add the include file:

#include <universal/number/integer/integer.hpp> 

and you would be off to the races.

 

Hope that helps.

 

Theo

0 Kudos
Alex_Y_Intel
Moderator
984 Views

@Daniel_D I've noticed that this problem happens when you use Visual Studio, but if you Intel oneAPI command prompt then there's no problem. Thus I escalated this issue so our developers can take a look. 

0 Kudos
Bernasek__Franz
978 Views

Hi

i have compile this code fragment under Linux ( OpenSUSE Tumbleweed) with the oneAPI 2024 icx

no problems, no compiler error , nothing all works fine

 

regards

Franz

 

0 Kudos
Daniel_D
Beginner
977 Views

@Alex_Y_Intel :

Thanks to taking care!

 

@Bernasek__Franz : 

Will switch to Linux later in the project. At the moment I need windows.


0 Kudos
cw_intel
Moderator
869 Views

Hi,


I tested the code and got the same error with Debug configuration. But with Release configuration, the code could be built successfully. So as a workaround, you can use Release configuration. In the meantime, I will report the issue to our development team to fix it.


Thanks.


0 Kudos
cw_intel
Moderator
868 Views

This issue is related to the option "/Od". In the Debug configuration, the default optimization is "/Od", you can change it to "/O1" or "/O2" or "/O3", then the code can run successfully.


Thanks.


0 Kudos
cw_intel
Moderator
536 Views

Hi,


This issue is resolved with the clang builtins library. You can build the code with the library clang_rt.builtins-x86_64.lib, for example,

icx-cl.exe /Od ConsoleApplication1.cpp clang_rt.builtins-x86_64.lib


This library was not available in the 2024.0 release, but we have it in the 2024.1 release that become available for download now. Please download the 2024.1 release.


Thanks.





0 Kudos
Daniel_D
Beginner
515 Views

Thanks a lot!

0 Kudos
Reply