Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Frank_R_1
Beginner
444 Views

cmath visual studio 14.28.29910 not working on oneAPI classic C++

Hello,

 

this simple code snippet does not link under visual studio 2019 14.28.29910 (updated today to newest vs 2019 16.9.2)

a.cxx

#include<cmath>

int func(float a) {
return round(a);
}

int main()
{
return (int)func(5.0);
}

 

icl.exe -Qcxx-features -Qvc14.2 -Qstd=c++17 -O3 -Ob2 -Oi a.cxx

Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.

a.cxx
Microsoft (R) Incremental Linker Version 14.28.29913.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:a.exe
a.obj
a.obj : error LNK2019: unresolved external symbol __roundf referenced in function main
a.exe : fatal error LNK1120: 1 unresolved externals

 

The cmath headers redirects to __roundf which is defined in intrin0.h

__MACHINE(double __round(double))

 

dumpbin -disasm a.obj
Microsoft (R) COFF/PE Dumper Version 14.28.29913.0
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file a.obj

File Type: COFF OBJECT

main:
0000000000000000: 48 83 EC 28 sub rsp,28h
0000000000000004: B9 03 00 00 00 mov ecx,3
0000000000000009: 33 D2 xor edx,edx
000000000000000B: E8 00 00 00 00 call __intel_new_feature_proc_init
0000000000000010: 0F AE 5C 24 20 stmxcsr dword ptr [rsp+20h]
0000000000000015: 81 4C 24 20 40 80 or dword ptr [rsp+20h],8040h
00 00
000000000000001D: F3 0F 10 05 00 00 movss xmm0,dword ptr [_2il0floatpacket.0]
00 00
0000000000000025: 0F AE 54 24 20 ldmxcsr dword ptr [rsp+20h]
000000000000002A: E8 00 00 00 00 call __roundf
000000000000002F: F3 0F 2C C0 cvttss2si eax,xmm0
0000000000000033: 48 83 C4 28 add rsp,28h
0000000000000037: C3 ret
0000000000000038: 0F 1F 84 00 00 00 nop dword ptr [rax+rax]
00 00

?func@@YAHM@Z (int __cdecl func(float)):
0000000000000000: 48 83 EC 28 sub rsp,28h
0000000000000004: E8 00 00 00 00 call __roundf
0000000000000009: F3 0F 2C C0 cvttss2si eax,xmm0
000000000000000D: 48 83 C4 28 add rsp,28h
0000000000000011: C3 ret
0000000000000012: 0F 1F 80 00 00 00 nop dword ptr [rax]
00
0000000000000019: 0F 1F 80 00 00 00 nop dword ptr [rax]
00

Summary

11B .drectve
18 .pdata
4 .rdata
60 .text
10 .xdata

 

Is there a workaround or I it wrong?

Best regards

Frank

0 Kudos
12 Replies
RahulV_intel
Moderator
402 Views

Hi Frank,


Do you see this issue only after upgrading to the latest VS-19 version?

I'm unable to reproduce your issue in my environment.

VS-19 version: 16.8.5

Microsoft (R) Incremental Linker Version 14.28.29337.0


Thanks,

Rahul


Frank_R_1
Beginner
399 Views

Hi,

 

We updated from 14.25.28610 with Intel C++ 2020.1 to the newest VS 2019 with Intel oneAPI.

Intel  2020.4 doesn't work with the newest VS 2019 due to some C++ defines.

When I change to std::floorf it works (should also have worked the original way)

 

Best regards

Frank

RahulV_intel
Moderator
343 Views

Hi Frank,


Thanks for reporting this issue. The latest version of VS-19 (16.9.2) is currently untested. The floor function issue is reproducible. We are working on this internally and will get back to you.


Thanks,

Rahul


Frank_R_1
Beginner
332 Views

Hi,

Thank you for your answer.

On RHEL 7.9 with devtoolset-9 std::floorf, std::ceilf, std::round are not available!

We develop our product on windows and linux, so it have to compile on both platforms.

Therefore it would be necessary that under windows the intrinsics for floor ceil round work!

Will this be fixed in oneAPI version 2021.1.2?

Best regards

Frank

 

313 Views

Hi Frank,

This issue is fixed in oneAPI version 2021.1.2. Let me know if you face any difficulties.


Regards,

Subarna


Frank_R_1
Beginner
247 Views

Hi,

 

the issue is still there in Intel oneAPI 2021.2.0!

 

Best regards

Frank

Frank_R_1
Beginner
245 Views

Hi,

this is the classic C++ compiler version which we use:

Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

Frank

Frank_R_1
Beginner
189 Views

Hi,

the following location in vs 2019 "cmath" header is the culprit (same for ceil, floor, trunc etc.):

_NODISCARD _Check_return_ inline float round(_In_ float _Xx) noexcept /* strengthened */ {
#ifdef _M_CEE
return _CSTD roundf(_Xx);
#elif defined(__clang__)
return __builtin_roundf(_Xx);
#else // ^^^ __clang__ / !__clang__ vvv
return __roundf(_Xx);
#endif // __clang__
}

Best regards

Frank

Haifeng_Gao
Beginner
101 Views

Hi, 

I also have the same problem after upgrading to the oneAPI C++ classic. Have you found a proper solution for that or have any updates on this thread?

The version of the compilers I am using are:

- Visual Studio 2019 (16.9.4)

- Intel C++ Compiler Classic 2021.2.0.616. 

Best regards, 

Haifeng

Frank_R_1
Beginner
88 Views

Hi,

as a workaround and to see if all our other code compiles and link I used the cmath include file from Visual Studio 2019 16.5.4 we have used before:

I copied

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.25.28610\include\cmath

to

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29910\include\cmath

then it compiles.

Using icx.exe is no option at the moment, since it does not provide all command line options we use.

 

Best regards

Frank

Haifeng_Gao
Beginner
76 Views

Hi Frank, 

thank you very much for your advice. I can confirm that replacing the cmath file works on my side. 

According to my test, the ICC 2021.2.0.616 works with MSVC toolset 14.25.28610. An alternative workaround could be changing the default "MSVC Toolset Version" to "14.25.28610", so you do not need to replace the cmath file. I post the following workaround here just in case someone has the same problem:

 1. Specify the toolset version by using CMake option: -DCMAKE_GENERATOR_TOOLSET="v142,version=14.25.28610". 

      for example: cmake .. -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_TOOLSET="v142,version=14.25.28610

2. If you use Visual Studio to build your projects,  you can switch to "Use Intel C++ Compile Classic" for all the projects, and build the solution from the Visual Studio. 

3. If you use MSBuild, you need to set the following properties:   

    /p:PlatformToolset="Intel C++ Compiler 19.2" /p:VCToolsVersion=14.25.28610

    for example:   msbuild your_project.sln /p:Configuration=Release  /maxcpucount:%NUMBER_OF_PROCESSORS%  /p:PlatformToolset="Intel C++ Compiler 19.2" /p:Platform=x64 /p:VCToolsVersion=14.25.28610 /t:rebuild

 

Best regards, 

Haifeng

 
 
Frank_R_1
Beginner
69 Views

Hi,

we use cmake with ninja generator and intel compiler with vs 2019 runtime.

I hope Intel oneAPI 2021.2.1 icl classic will fix this trivial bug!

 

Best regards

Frank

Reply