-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathflsrc
More file actions
executable file
·43 lines (36 loc) · 1.58 KB
/
Copy pathflsrc
File metadata and controls
executable file
·43 lines (36 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# This script pre-processes the Fortran source code for LLVM Flang and its descendants, including
# AMD AOMP Flang (amdflang) and Arm Flang (armflang).
DIR="$(realpath "$1")"
LINALG="$DIR/common/linalg.f90"
#GET_INTRINSIC_LINALG="$DIR/common/get_intrinsic_linalg"
#INTRINSIC_LINALG="$DIR/common/intrinsic_linalg.f90"
if [[ "$(uname)" == Darwin || "$(uname)" == FreeBSD ]] ; then
SEDI="sed -i ''"
else
SEDI="sed -i"
fi
if ! basename "$DIR" | grep -q ".test\|test." || ! [[ -d "$DIR" ]] ; then
printf "\n%s is not a testing directory.\n\nExit.\n\n" "$DIR"
exit 1
fi
if [[ -f "$LINALG" ]] ; then
echo "!!! Warning: $0 is DOING NOTHING !!!" >&2
# # See https://github.com/llvm/llvm-project/issues/89528
# STR="Y is NaN if and only if X contains NaN"
# $SEDI "/$STR/d" "$LINALG"
# The following should have been fixed by commit 399df3ae055566c3f6133118ebab6fdcc16cebb5
# # See https://github.com/llvm/llvm-project/issues/180957
# STR="Y >= 0 unless X contains NaN"
# $SEDI "/$STR/d" "$LINALG"
# # With flang 20.1.8, matprod in linalg.f90 often fails to compute matrix multiplications
# # correctly, generating garbage values (NaN or numbers that are nearly zero). No idea why.
# # The following is a workaround the replaces matprod with the intrinsic matmul.
# # Remove this and test again when flang is updated.
# Update 20250906: With flang 21.1.0, matprod seems to work fine now.
# if [[ -f "$GET_INTRINSIC_LINALG" ]] ; then
# bash "$GET_INTRINSIC_LINALG"
# mv "$INTRINSIC_LINALG" "$LINALG"
# fi
fi
exit 0