Skip to content

Commit

Permalink
Fix compiler feature detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoki Shibata committed Nov 25, 2024
1 parent 1d19834 commit 46a5436
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,23 @@ if (CMAKE_CXX_COMPILER_TARGET)
endif()
CHECK_CXX_SOURCE_COMPILES("
#include <cstdlib>
#include <cstdint>
#include <bit>
int main(int argc, char **argv) {
__fp16 a = (__fp16)(float)atof(argv[1]);
__uint16_t u = std::bit_cast<__uint16_t>(a);
a = std::bit_cast<__fp16>(u);
return (float)a; }
" TLFLOAT_COMPILER_SUPPORTS_FP16)

CHECK_CXX_SOURCE_COMPILES("
#include <cstdlib>
#include <cstdint>
#include <bit>
int main(int argc, char **argv) {
__bf16 a = (__bf16)(float)atof(argv[1]);
__uint16_t u = std::bit_cast<__uint16_t>(a);
a = std::bit_cast<__bf16>(u);
return (float)a; }
" TLFLOAT_COMPILER_SUPPORTS_BF16)

Expand Down
7 changes: 7 additions & 0 deletions src/tester/test_exhaustive_bf16_mpfr.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <iostream>
#include <atomic>
#include <signal.h>

#include <detect.h>

#if defined(TLFLOAT_ENABLE_MPFR_WANT_FLOAT128)
#define MPFR_WANT_FLOAT128
#endif

#include <mpfr.h>

#include "suppress.hpp"
Expand Down

0 comments on commit 46a5436

Please sign in to comment.