bloomberg / bde

Basic Development Environment - a set of foundational C++ libraries used at Bloomberg.
Apache License 2.0
1.67k stars 316 forks source link

SSE cpuid bad bad #270

Closed seanbaxter closed 2 years ago

seanbaxter commented 3 years ago

bsls_platform.t fails in case 5 here

        int info[4];
        cpuid(info, 0);
        if (info[0] >= 0x00000001) {
            cpuid(info, 0x00000001);
        }
        #ifdef BSLS_PLATFORM_CPU_SSE3
            ASSERT(1 == ((info[2] >>  0) & 0x1));
        #else
            ASSERT(0 == ((info[2] >>  0) & 0x1));
        #endif

When you compile without BSLS_PLATFORM_CPU_SSE3, the assert fails. Because, of course, compiling without a macro won't disable the feature on the processor!

hyrosen commented 3 years ago

The macro is supposed to be identifying the state of affairs, so I would say that we should always have the macro defined when the program is going to run on a machine that has SSE.

From: reply@reply.github.com At: 10/28/20 21:12:06To: bde@noreply.github.com Cc: subscribed@noreply.github.com Subject: [bloomberg/bde] SSE cpuid bad bad (#270)

bsls_platform.t fails in case 5 here int info[4]; cpuid(info, 0); if (info[0] >= 0x00000001) { cpuid(info, 0x00000001); }

ifdef BSLS_PLATFORM_CPU_SSE3

    ASSERT(1 == ((info[2] >>  0) & 0x1));
#else
    ASSERT(0 == ((info[2] >>  0) & 0x1));
#endif

When you compile without BSLS_PLATFORM_CPU_SSE3, the assert fails. Because, of course, compiling without a macro won't disable the feature on the processor!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

seanbaxter commented 3 years ago

Is cmake_build.py configure supposed to add the SSE3 flag? It doesn't on my system, which is why I get this test failure.

osubboo commented 3 years ago

cmake/toolchains/linux/gcc-default.cmake:32: "-mfpmath=sse " cmake/toolchains/linux/gcc-default.cmake:37: "-mfpmath=sse "

This is the flag passed by default to gcc (only). You probably need this for clang-based toolchain. I'll look into it tomorrow.