From ec1f44228b40dcb009ba6404cfa97ed64ff546a8 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 21 Sep 2023 16:00:41 +0200 Subject: [PATCH] fp16-abi: add test to check that Float16 ABI matches with clang --- fp16-abi/main.fmf | 32 ++++++++++++++++++++++++++++++++ fp16-abi/test.cpp | 14 ++++++++++++++ fp16-abi/test.sh | 15 +++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 fp16-abi/main.fmf create mode 100644 fp16-abi/test.cpp create mode 100755 fp16-abi/test.sh diff --git a/fp16-abi/main.fmf b/fp16-abi/main.fmf new file mode 100644 index 0000000..098120e --- /dev/null +++ b/fp16-abi/main.fmf @@ -0,0 +1,32 @@ +summary: Test that Float16 ABI matches with clang +test: "$WITH_SCL ./test.sh" +framework: shell +tier: 1 +component: + - llvm-toolset + - compiler-rt + +adjust: + - because: "Float16 not supported on s390x or ppc64le" + enabled: false + when: arch == s390x or arch == ppc64le + + # Common requirements when LLVM is not SCL-ized + - require+: + - clang + - compiler-rt + when: collection is not defined + + # Requirements for SCL-ized LLVM + - require+: + - llvm-toolset-13.0-clang + - llvm-toolset-13.0-compiler-rt + when: collection == llvm-toolset-13.0 + - require+: + - llvm-toolset-14.0-clang + - llvm-toolset-14.0-compiler-rt + when: collection == llvm-toolset-14.0 + - require+: + - llvm-toolset-15.0-clang + - llvm-toolset-15.0-compiler-rt + when: collection == llvm-toolset-15.0 diff --git a/fp16-abi/test.cpp b/fp16-abi/test.cpp new file mode 100644 index 0000000..3c15ea1 --- /dev/null +++ b/fp16-abi/test.cpp @@ -0,0 +1,14 @@ +// Reproducer based on this code from Steve Leung (evetsso): +// https://github.com/ROCmSoftwarePlatform/rocFFT/issues/439#issuecomment-1693835987 + +#include +#include +#include + +int main() +{ + _Float16 one_f16 = 0.123; + float one_f32 = one_f16; + std::cout << one_f32 << std::endl; + return 0; +} diff --git a/fp16-abi/test.sh b/fp16-abi/test.sh new file mode 100755 index 0000000..35b99e8 --- /dev/null +++ b/fp16-abi/test.sh @@ -0,0 +1,15 @@ +#!/bin/sh -ux +# Do NOT set exit after error flag (set -e). Let all the optimizations to be run + +tmp=$(mktemp -d) +result=0 +# Test the reproducer with all the optimization levels +for opt_level in 0 1 2 3; do + clang++ --rtlib=compiler-rt -O$opt_level test.cpp -o $tmp/test_O$opt_level + $tmp/test_O$opt_level | grep '0.122986' || result=1 +done + +rm -rf $tmp +if [[ "$result" == 1 ]]; then + exit 1 +fi