simde: Problem detecting the lack of _Float16 on Clang-Cl with /arch:SSE (x86)

The following cmake settings for a 32bit build with clang-cl, with only SSE enabled: -G "Visual Studio 17 2022" -A Win32 -T "ClangCl" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="/arch:SSE" (Clang 16.0.5 with MSVC-like command-line) Caused error: simde-f16.h(94,11): error : _Float16 is not supported

Seems like detection in simde-f16.h is generally sketchy, additionally because detecting clang-cl involves checking for both __clang__ and _MSC_VER at the same time. I was able to circumvent the issue by detecting _Float16 availablity like this:

// Make sure _Float16 identifier exists in such cases, and if not,   
// use the portable alternative provided by SIMDe                       
// Do this before including any SIMDe headers
#ifdef __is_identifier
  #if !__is_identifier(_Float16)
    #define SIMDE_FLOAT16_API 1     // SIMDE_FLOAT16_API_PORTABLE == 1  
  #endif
#endif

I saw a comment, that you’re searching for suggestions on more robust detection of _Float16, so I thought this will be helpful. I could probably do a PR at some point, but I’m quite busy atm.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 1
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I can confirm, that c98b76a fixes the problem I had, when applied to 4d55fc25bcfddc0e2f0c744448557a070dd310c9

I will now test the new commit you proposed, regarding SVML, but I think it is fine to close this issue

@Epixu sorry to hear that; let me know if it turns out that https://github.com/simd-everywhere/simde/commit/c98b76a0a6a3708ae56d85b863583d8d77c4ff7b fixes your issue

diff --git a/simde/simde-f16.h b/simde/simde-f16.h
index 4024dd18f..da14c68cd 100644
--- a/simde/simde-f16.h
+++ b/simde/simde-f16.h
@@ -66,6 +66,7 @@ SIMDE_BEGIN_DECLS_
  * welcome. */
 #if !defined(SIMDE_FLOAT16_API)
   #if !defined(__EMSCRIPTEN__) && !(defined(__clang__) && defined(SIMDE_ARCH_POWER)) && \
+    !(defined(HEDLEY_MSVC_VERSION) && defined(__clang__)) && \
     !(defined(__clang__) && defined(SIMDE_ARCH_RISCV64)) && ( \
       defined(SIMDE_X86_AVX512FP16_NATIVE) || \
       (defined(SIMDE_ARCH_X86_SSE2) && HEDLEY_GCC_VERSION_CHECK(12,0,0)) || \

@mr-c I will check it by the end of the work week