Skip to content

Commit 15fae8e

Browse files
tstellarsylvestre
authored andcommitted
Add a test for _Float16 ABI compatibility between clang and compiler-rt
From ROCm/rocFFT#439
1 parent f9f8422 commit 15fae8e

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
@@ -81,6 +81,16 @@ option(ENABLE_HWASAN
8181
${SUPPORT_HWASAN}
8282
)
8383

84+
# Check for _Float16 support
85+
if (CLANGXX_BINARY)
86+
message(STATUS "Checking for _Float16 support in ${CLANGXX_BINARY}")
87+
execute_process(COMMAND ${CLANGXX_BINARY} -c ${CMAKE_CURRENT_SOURCE_DIR}/tests/float16.cpp RESULT_VARIABLE FLOAT16_STATUS ERROR_QUIET OUTPUT_QUIET)
88+
if (${FLOAT16_STATUS} EQUAL 0)
89+
message(STATUS "_Float16 enabled.")
90+
set(ENABLE_FLOAT16 ON)
91+
endif()
92+
endif()
93+
8494
configure_file(
8595
${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
8696
${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
@@ -57,3 +57,4 @@ enable_feature("libc++", "@ENABLE_LIBCXX@")
5757
enable_feature("static-libc++", "@ENABLE_STATIC_LIBCXX@")
5858
enable_feature("libunwind", "@ENABLE_LIBUNWIND@")
5959
enable_feature("support_hwasan", "@ENABLE_HWASAN@")
60+
enable_feature("float16", "@ENABLE_FLOAT16@")

0 commit comments

Comments
 (0)