Wireshark-dev: [Wireshark-dev] SIMD optimizations with CMake
From: Joerg Mayer <[email protected]>
Date: Thu, 12 Jun 2014 16:19:51 +0200
Hi,

I'm planning to add the SIMD optimization that was recently added to autofoo
to cmake as well. The current solution looks a bit weird to me, so maybe I
have read the existing code incorrectly or misunderstood the ideas behind the
current solution:

Current situation:
- Runtime: If the code has been compiled with SSE support then there is a
  runtime check whether the current cpu supports the optimizations. If not,
  a non-sse code path is taken.
- Compile time: The C-compiler in wsutil/ is told to use the optimization
  flags discovered at configuration time. HAVE_SSE4_2 is the only flag curently
  used in the following files: ws_mempbrk.h and ./ws_mempbrk_sse42.c whether
  to enable the code or not.
- Configuration time: The aclocal-fallback/ax_XXX.m4 files check whether the
  *current host cpu* supports theses extensions and sets the HAVE_xxx and
  SIMD_FLAGS (which then get added to ws_util/-CLFAGS) variables accodingly.

Questions:
a) Is this correct?
b) Is there any check whether the compiler actually supports these flags?
c) Are there any provisions for cross-compiling?

Cmake only needs to redo the configuration time stuff, so I looked at it and
didn't understand the design. What I intend to do is to just test whether the
current compiler supports the extensions via adding the following flags to
WIRESHARK_C_FLAGS: -faltivec, -mmmx, -msse, -msse2, -msse3, -mssse3,
-msse4.1, -msse4.2, -mavx and then creating the necessary HAVE_xxx variables.
Is there a good reason not to take this path (note: I have a cpu that only
supports sse_4.1 so I can only do limited testing).

Thanks
   Jörg
-- 
Joerg Mayer                                           <[email protected]>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.