Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests fail when building UB2 binaries on Mac. #1762

Open
stephen-yee-adsk opened this issue May 30, 2024 · 1 comment
Open

Unit tests fail when building UB2 binaries on Mac. #1762

stephen-yee-adsk opened this issue May 30, 2024 · 1 comment

Comments

@stephen-yee-adsk
Copy link

Hi there,

I'm having trouble compiling OpenEXR for UB2 binaries, from an Intel based Mac. (To reproduce the issue build with cmake and set CMAKE_OSX_ARCHTECTURES=x86_64;arm64)

The problem appears to be that this check in openexr/cmake/CMakeLists.txt fails:

check_cxx_source_compiles(
"
int main()
{
#if defined(__SSE2__)
    int n   = 0;
    int eax = 0;
    int edx = 0;
    __asm__(
        \"xgetbv     ;\"
        \"vzeroupper  \"
        : \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
#else
#    error No SSE support enabled to query AVX support
#endif
}
" OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
)

Arm doesn't support SSE so I think that's why it fails in UB2 compilation.

However OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX gets "burned in" to OpenEXRConfigInternal.h, even when compiling the x86_64 "side" of the universal binaries.

This causes some tests to fail. In particular testCPUIdent:

  7/127 Test   #7: OpenEXRCore.testCPUIdent ..................Subprocess aborted***Exception:   0.01 sec
tempDir = '/var/tmp/OpenEXR_D8YKiB/': 24

=======
Running testCPUIdent
CPU Id test f16c mismatch: 1 vs 0
Core Test failed: false
           file:/openexr/src/test/OpenEXRCoreTest/base_units.cpp
           line:375
       function:void testCPUIdent(const std::string &)

CpuId is affected by OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX and reports that f16c is not available. That is incorrect, my cpu should support it. Whereas check_for_x86_simd does not depend on that macro, and correctly reports that f16c is available.

This also seems to affect two other tests related to DWA compression

53/127 Test  #53: OpenEXRCore.testDWAACompression ...........Subprocess aborted***Exception:   1.08 sec
 tempDir = '/var/tmp/OpenEXR_9HJaaa/': 24
 
 =======
 Running testDWAACompression
   zeroes tiled: no sampling 1, 1 comp 8
   zeroes tiled: yes sampling 1, 1 comp 8
   zeroes tiled: no sampling 1, 2 comp 8
   zeroes tiled: no sampling 2, 1 comp 8
   zeroes tiled: no sampling 2, 2 comp 8
   pattern1 tiled: no sampling 1, 1 comp 8
   pattern1 tiled: yes sampling 1, 1 comp 8
   pattern1 tiled: no sampling 1, 2 comp 8
   pattern1 tiled: no sampling 2, 1 comp 8
   pattern1 tiled: no sampling 2, 2 comp 8
   pattern2 tiled: no sampling 1, 1 comp 8
 B half at 1276, 1 not equal: C++ loaded C 0x3c4b (1.07324) vs C loaded C 0x3c4e (1.07617)
 Core Test failed: a == b
            file:/openexr/src/test/OpenEXRCoreTest/compression.cpp
            line:475
        function:static void pixels::compareExact(uint16_t, uint16_t, int, int, const char *, const char *, const char *)

The following tests FAILED:
	 53 - OpenEXRCore.testDWAACompression (Subprocess aborted)
	 54 - OpenEXRCore.testDWABCompression (Subprocess aborted)

If I hack the check_cxx_source_compiles code snippet to always pass, then all of the tests pass in x86_64 mode. I have not tried running in arm64 mode though, as I do not have access to an Apple silicon Mac.

System info:

>cmake --version
cmake version 3.20.3

>clang++ -v 
clang version 14.0.3 
Target: x86_64-apple-darwin21.6.0
Thread model: posix

>sw_vers
ProductName:	macOS
ProductVersion:	12.7
BuildVersion:	21G816

>sysctl -a|grep brand
machdep.cpu.brand_string: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
machdep.cpu.brand: 0```

@cary-ilm
Copy link
Member

cary-ilm commented Jun 2, 2024

Thanks for the report, we'll investigate shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants