Skip to content

Commit dc4c4a7

Browse files
committed
Add a test for _Float16 ABI compatibility between clang and compiler-rt
From ROCm/rocFFT#439
1 parent 3ddcfd5 commit dc4c4a7

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ option(ENABLE_HWASAN
6363
${SUPPORT_HWASAN}
6464
)
6565

66+
# Check for _Float16 support
67+
if (CLANGXX_BINARY)
68+
message(STATUS "Checking for _Float16 support in ${CLANGXX_BINARY}")
69+
execute_process(COMMAND ${CLANGXX_BINARY} -c ${CMAKE_CURRENT_SOURCE_DIR}/tests/float16.cpp RESULT_VARIABLE FLOAT16_STATUS ERROR_QUIET OUTPUT_QUIET)
70+
if (${FLOAT16_STATUS} EQUAL 0)
71+
message(STATUS "_Float16 enabled.")
72+
set(ENABLE_FLOAT16 ON)
73+
endif()
74+
endif()
75+
6676
configure_file(
6777
${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
6878
${CMAKE_BINARY_DIR}/tests/lit.site.cfg

tests/float16.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// REQUIRES: clang, compiler-rt, float16
2+
// RUN: %clangxx %s -o %t.float16 -rtlib=compiler-rt
3+
// RUN: %t.float16 | grep '0.122986'
4+
5+
#include <iostream>
6+
#include <algorithm>
7+
#include <vector>
8+
9+
int main()
10+
{
11+
_Float16 one_f16 = 0.123;
12+
float one_f32 = one_f16;
13+
std::cout << one_f32 << std::endl;
14+
return 0;
15+
}

tests/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ enable_feature("libc++", "@ENABLE_LIBCXX@")
5252
enable_feature("static-libc++", "@ENABLE_STATIC_LIBCXX@")
5353
enable_feature("libunwind", "@ENABLE_LIBUNWIND@")
5454
enable_feature("support_hwasan", "@ENABLE_HWASAN@")
55+
enable_feature("float16", "@ENABLE_FLOAT16@")

0 commit comments

Comments
 (0)