From 33d0399a26829e773ad09579c0d6f127d09de876 Mon Sep 17 00:00:00 2001 From: Shivarama Rao Date: Fri, 26 Jul 2024 06:57:26 +0000 Subject: [PATCH] [NFC] Testcase for Issue #1413 A reproducible testcase for issue #1413 is added. The testcase checks if AVX512 pgmath functions are generated only when avx512 target options are specified. --- test/f90_correct/inc/pgmath_avx512.mk | 24 +++++++++++++++++ test/f90_correct/lit/pgmath_avx512.sh | 10 +++++++ test/f90_correct/src/pgmath_avx512.f90 | 37 ++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 test/f90_correct/inc/pgmath_avx512.mk create mode 100644 test/f90_correct/lit/pgmath_avx512.sh create mode 100644 test/f90_correct/src/pgmath_avx512.f90 diff --git a/test/f90_correct/inc/pgmath_avx512.mk b/test/f90_correct/inc/pgmath_avx512.mk new file mode 100644 index 00000000000..59c105ad9e2 --- /dev/null +++ b/test/f90_correct/inc/pgmath_avx512.mk @@ -0,0 +1,24 @@ +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# + +$(TEST): run + +EXTFLAGS=-O3 -march=x86-64 -mtune=core-avx2 -mfma -mavx -mavx2 -mllvm -force-vector-width=16 + +build: $(SRC)/$(TEST).f90 + -$(RM) $(TEST).$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.* + @echo ------------------------------------ building test $@ + -$(CC) -c $(CFLAGS) $(SRC)/check.c -o check.$(OBJX) + -$(FC) -c $(FFLAGS) $(EXTFLAGS) $(LDFLAGS) $(SRC)/$(TEST).f90 -o $(TEST).$(OBJX) + -$(FC) $(FFLAGS) $(LDFLAGS) $(TEST).$(OBJX) check.$(OBJX) $(LIBS) -o $(TEST).$(EXESUFFIX) + + +run: + @echo ------------------------------------ executing test $(TEST) + $(TEST).$(EXESUFFIX) + +verify: ; + diff --git a/test/f90_correct/lit/pgmath_avx512.sh b/test/f90_correct/lit/pgmath_avx512.sh new file mode 100644 index 00000000000..21a66ed2ef9 --- /dev/null +++ b/test/f90_correct/lit/pgmath_avx512.sh @@ -0,0 +1,10 @@ +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Shared lit script for each tests. Run bash commands that run tests with make. + +# REQUIRES: x86_64-host +# RUN: env KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%/s MAKE_FILE_DIR=%/S/.. bash %/S/runmake | tee %/t +# RUN: cat %t | FileCheck %S/runmake diff --git a/test/f90_correct/src/pgmath_avx512.f90 b/test/f90_correct/src/pgmath_avx512.f90 new file mode 100644 index 00000000000..72050950eb5 --- /dev/null +++ b/test/f90_correct/src/pgmath_avx512.f90 @@ -0,0 +1,37 @@ +! +! Part of the LLVM Project, under the Apache License v2.0 with LLVM +! Exceptions. +! See https://llvm.org/LICENSE.txt for license information. +! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +! +! Test for USE statement when there is rename of user-defined operator in the +! ONLY option. +! REQUIRES: x86_64-registered-target + +program main + real (kind=8) :: a(128), b(128), c(128) + integer :: res,expect + res=1 + expect=2 + do i=1,100 + c(i) = log(a(i)) + log(b(i)) + enddo + call sub1(a,b,c,128,res) + call check(res,expect,1); + +contains + + subroutine sub1(a,b,c,N,res) + real(kind=8), intent(in) :: a(:), b(:) + real(kind=8),intent (out) :: c(:) + integer, intent(IN) :: N + integer, intent(OUT) :: res + + do i=1,N,16 + c(i) = exp(log(a(i))) + dlog(b(i)) + enddo + res=2 + end subroutine + +end program +