Skip to content

Commit

Permalink
[test-suite] Suppress FP_CONTRACT due to command line changes planned…
Browse files Browse the repository at this point in the history
… in D74436

The dependent clang patch changes the default setting for ffp-contract to true,
and that causes about 20 test-suite LNT tests to fail on X86 and other arch.
This patch modifies the build settings to these tests to suppress FP_CONTRACT
and allows the tests to pass.

Reviewed By: andrew.kaylor, segpop, rengolin, jdoerfert

Differential Revision: https://reviews.llvm.org/D102861
  • Loading branch information
Melanie Blower committed Jun 15, 2021
1 parent 19325b4 commit 24550c3
Show file tree
Hide file tree
Showing 53 changed files with 659 additions and 29 deletions.
Expand Up @@ -2,6 +2,10 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
list(APPEND LDFLAGS -lm)

# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_test_verify_hash_program_output(bilateralFilterOutput.txt)
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
${FPCMP} bilateralFilter.reference_output bilateralFilterOutput.txt
Expand Down
4 changes: 4 additions & 0 deletions MicroBenchmarks/ImageProcessing/Blur/CMakeLists.txt
Expand Up @@ -3,6 +3,10 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
list(APPEND LDFLAGS -lm)

# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_test_verify_hash_program_output(boxBlurOutput.txt)
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
${FPCMP} boxBlur.reference_output boxBlurOutput.txt
Expand Down
4 changes: 4 additions & 0 deletions MultiSource/Applications/oggenc/CMakeLists.txt
@@ -1,4 +1,8 @@
list(APPEND CFLAGS -fno-strict-aliasing)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

list(APPEND LDFLAGS -lm)
set(RUN_OPTIONS -Q -s 901820 - < tune)
llvm_multisource(oggenc)
Expand Down
4 changes: 4 additions & 0 deletions MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/CMakeLists.txt
@@ -1,2 +1,6 @@
set(RUN_OPTIONS -n 64 -t 1000)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_multisource(CLAMR)
4 changes: 4 additions & 0 deletions MultiSource/Benchmarks/DOE-ProxyApps-C++/HPCCG/CMakeLists.txt
@@ -1,4 +1,8 @@
list(APPEND CXXFLAGS -DREDSTORM) # -DREDSTORM for mkdir
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

list(APPEND LDFLAGS -lm)
set(RUN_OPTIONS 50 50 50)
llvm_multisource(HPCCG)
Expand Up @@ -6,6 +6,10 @@ list(APPEND CXXFLAGS -I. -DMINIFE_SCALAR=double -DMINIFE_LOCAL_ORDINAL=int -DMI
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
list(APPEND CXXFLAGS -D_XOPEN_SOURCE=700 -DUseTimes)
endif()
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

list(APPEND LDFLAGS -lm)
set(RUN_OPTIONS -nx 64 -ny 64 -nz 64)
llvm_multisource(miniFE)
Expand Down
4 changes: 4 additions & 0 deletions MultiSource/Benchmarks/Rodinia/srad/CMakeLists.txt
@@ -1,6 +1,10 @@
list(APPEND LDFLAGS -lm)
set(FP_ABSTOLERANCE 0.00001)
list(APPEND CFLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/../Common)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_multisource(srad
main.c
sradKernel.c
Expand Down
4 changes: 4 additions & 0 deletions SingleSource/Benchmarks/Linpack/CMakeLists.txt
@@ -1,3 +1,7 @@
list(APPEND LDFLAGS -lm)
set(FP_TOLERANCE 0.0001)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_singlesource()
4 changes: 4 additions & 0 deletions SingleSource/Benchmarks/Misc-C++/Large/CMakeLists.txt
@@ -1,4 +1,8 @@
list(APPEND LDFLAGS -lm)
set(FP_ABSTOLERANCE 0.01)
set(HASH_PROGRAM_OUTPUT 1)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

llvm_singlesource()
Expand Up @@ -3,6 +3,10 @@ list(APPEND CFLAGS -I ${CMAKE_SOURCE_DIR}/${POLYBENCH_UTILS} -DPOLYBENCH_DUMP_AR
if(SMALL_PROBLEM_SIZE)
list(APPEND CFLAGS -DSMALL_DATASET)
endif()
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

set(HASH_PROGRAM_OUTPUT 1)
add_definitions(-DFP_ABSTOLERANCE=1e-5)
llvm_singlesource()
Expand Up @@ -121,6 +121,10 @@ void kernel_correlation(int m, int n,

}

#if !FMA_DISABLED
// NOTE: FMA_DISABLED is true for targets where FMA contraction causes
// discrepancies which cause the accuracy checks to fail.
// In this case, the test runs with the option -ffp-contract=off
static void
kernel_correlation_StrictFP(int m, int n,
DATA_TYPE float_n,
Expand Down Expand Up @@ -206,6 +210,7 @@ check_FP(int m,
/* All elements are within the allowed FP_ABSTOLERANCE error margin. */
return 1;
}
#endif

int main(int argc, char** argv)
{
Expand All @@ -217,7 +222,9 @@ int main(int argc, char** argv)
DATA_TYPE float_n;
POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,M,N,m,n);
POLYBENCH_2D_ARRAY_DECL(symmat,DATA_TYPE,M,M,m,m);
#if !FMA_DISABLED
POLYBENCH_2D_ARRAY_DECL(symmat_StrictFP,DATA_TYPE,M,M,m,m);
#endif
POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m);
POLYBENCH_1D_ARRAY_DECL(stddev,DATA_TYPE,M,m);

Expand All @@ -238,6 +245,11 @@ int main(int argc, char** argv)
polybench_stop_instruments;
polybench_print_instruments;

#if FMA_DISABLED
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat)));
#else
init_array (m, n, &float_n, POLYBENCH_ARRAY(data));
kernel_correlation (m, n, float_n,
POLYBENCH_ARRAY(data),
Expand All @@ -250,11 +262,14 @@ int main(int argc, char** argv)
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat_StrictFP)));
#endif

/* Be clean. */
POLYBENCH_FREE_ARRAY(data);
POLYBENCH_FREE_ARRAY(symmat);
#if !FMA_DISABLED
POLYBENCH_FREE_ARRAY(symmat_StrictFP);
#endif
POLYBENCH_FREE_ARRAY(mean);
POLYBENCH_FREE_ARRAY(stddev);

Expand Down
Expand Up @@ -3,6 +3,10 @@ list(APPEND CFLAGS -I ${CMAKE_SOURCE_DIR}/${POLYBENCH_UTILS} -DPOLYBENCH_DUMP_AR
if(SMALL_PROBLEM_SIZE)
list(APPEND CFLAGS -DSMALL_DATASET)
endif()
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)

set(HASH_PROGRAM_OUTPUT 1)
add_definitions(-DFP_ABSTOLERANCE=1e-5)
llvm_singlesource()
Expand Up @@ -93,6 +93,10 @@ void kernel_covariance(int m, int n,

}

#if !FMA_DISABLED
// NOTE: FMA_DISABLED is true for targets where FMA contraction causes
// discrepancies which cause the accuracy checks to fail.
// In this case, the test runs with the option -ffp-contract=off
static void
kernel_covariance_StrictFP(int m, int n,
DATA_TYPE float_n,
Expand Down Expand Up @@ -152,6 +156,7 @@ check_FP(int m,
/* All elements are within the allowed FP_ABSTOLERANCE error margin. */
return 1;
}
#endif

int main(int argc, char** argv)
{
Expand All @@ -163,7 +168,9 @@ int main(int argc, char** argv)
DATA_TYPE float_n;
POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,M,N,m,n);
POLYBENCH_2D_ARRAY_DECL(symmat,DATA_TYPE,M,M,m,m);
#if !FMA_DISABLED
POLYBENCH_2D_ARRAY_DECL(symmat_StrictFP,DATA_TYPE,M,M,m,m);
#endif
POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m);


Expand All @@ -183,6 +190,11 @@ int main(int argc, char** argv)
polybench_stop_instruments;
polybench_print_instruments;

#if FMA_DISABLED
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat)));
#else
init_array (m, n, &float_n, POLYBENCH_ARRAY(data));
kernel_covariance (m, n, float_n,
POLYBENCH_ARRAY(data),
Expand All @@ -194,11 +206,14 @@ int main(int argc, char** argv)
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat_StrictFP)));
#endif

/* Be clean. */
POLYBENCH_FREE_ARRAY(data);
POLYBENCH_FREE_ARRAY(symmat);
#if !FMA_DISABLED
POLYBENCH_FREE_ARRAY(symmat_StrictFP);
#endif
POLYBENCH_FREE_ARRAY(mean);

return 0;
Expand Down
34 changes: 29 additions & 5 deletions SingleSource/Benchmarks/Polybench/linear-algebra/kernels/2mm/2mm.c
Expand Up @@ -26,8 +26,11 @@ void init_array(int ni, int nj, int nk, int nl,
DATA_TYPE POLYBENCH_2D(A,NI,NK,ni,nl),
DATA_TYPE POLYBENCH_2D(B,NK,NJ,nk,nj),
DATA_TYPE POLYBENCH_2D(C,NL,NJ,nl,nj),
DATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl),
DATA_TYPE POLYBENCH_2D(D_StrictFP,NI,NL,ni,nl))
DATA_TYPE POLYBENCH_2D(D,NI,NL,ni,nl)
#if !FMA_DISABLED
, DATA_TYPE POLYBENCH_2D(D_StrictFP,NI,NL,ni,nl)
#endif
)
{
#pragma STDC FP_CONTRACT OFF
int i, j;
Expand All @@ -45,7 +48,10 @@ void init_array(int ni, int nj, int nk, int nl,
C[i][j] = ((DATA_TYPE) i*(j+3)) / nl;
for (i = 0; i < ni; i++)
for (j = 0; j < nl; j++)
D_StrictFP[i][j] = D[i][j] = ((DATA_TYPE) i*(j+2)) / nk;
#if !FMA_DISABLED
D_StrictFP[i][j] =
#endif
D[i][j] = ((DATA_TYPE) i*(j+2)) / nk;
}


Expand Down Expand Up @@ -101,6 +107,10 @@ void kernel_2mm(int ni, int nj, int nk, int nl,

}

#if !FMA_DISABLED
// NOTE: FMA_DISABLED is true for targets where FMA contraction causes
// discrepancies which cause the accuracy checks to fail.
// In this case, the test runs with the option -ffp-contract=off
static void
kernel_2mm_StrictFP(int ni, int nj, int nk, int nl,
DATA_TYPE alpha,
Expand Down Expand Up @@ -155,6 +165,7 @@ check_FP(int ni, int nl,
/* All elements are within the allowed FP_ABSTOLERANCE error margin. */
return 1;
}
#endif

int main(int argc, char** argv)
{
Expand All @@ -172,15 +183,20 @@ int main(int argc, char** argv)
POLYBENCH_2D_ARRAY_DECL(B,DATA_TYPE,NK,NJ,nk,nj);
POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,NL,NJ,nl,nj);
POLYBENCH_2D_ARRAY_DECL(D,DATA_TYPE,NI,NL,ni,nl);
#if !FMA_DISABLED
POLYBENCH_2D_ARRAY_DECL(D_StrictFP,DATA_TYPE,NI,NL,ni,nl);
#endif

/* Initialize array(s). */
init_array (ni, nj, nk, nl, &alpha, &beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(D),
POLYBENCH_ARRAY(D_StrictFP));
POLYBENCH_ARRAY(D)
#if !FMA_DISABLED
, POLYBENCH_ARRAY(D_StrictFP)
#endif
);

/* Start timer. */
polybench_start_instruments;
Expand All @@ -198,6 +214,11 @@ int main(int argc, char** argv)
polybench_stop_instruments;
polybench_print_instruments;

#if FMA_DISABLED
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(D)));
#else
kernel_2mm_StrictFP(ni, nj, nk, nl,
alpha, beta,
POLYBENCH_ARRAY(tmp),
Expand All @@ -212,14 +233,17 @@ int main(int argc, char** argv)
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(D_StrictFP)));
#endif

/* Be clean. */
POLYBENCH_FREE_ARRAY(tmp);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(D);
#if !FMA_DISABLED
POLYBENCH_FREE_ARRAY(D_StrictFP);
#endif

return 0;
}
Expand Up @@ -5,4 +5,7 @@ if(SMALL_PROBLEM_SIZE)
endif()
set(HASH_PROGRAM_OUTPUT 1)
add_definitions(-DFP_ABSTOLERANCE=1e-5)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)
llvm_singlesource()
15 changes: 15 additions & 0 deletions SingleSource/Benchmarks/Polybench/linear-algebra/kernels/3mm/3mm.c
Expand Up @@ -105,6 +105,10 @@ void kernel_3mm(int ni, int nj, int nk, int nl, int nm,

}

#if !FMA_DISABLED
// NOTE: FMA_DISABLED is true for targets where FMA contraction causes
// discrepancies which cause the accuracy checks to fail.
// In this case, the test runs with the option -ffp-contract=off
static
void kernel_3mm_StrictFP(int ni, int nj, int nk, int nl, int nm,
DATA_TYPE POLYBENCH_2D(E,NI,NJ,ni,nj),
Expand Down Expand Up @@ -167,6 +171,7 @@ check_FP(int ni, int nl,

return 1;
}
#endif

int main(int argc, char** argv)
{
Expand All @@ -185,7 +190,9 @@ int main(int argc, char** argv)
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NJ, NM, nj, nm);
POLYBENCH_2D_ARRAY_DECL(D, DATA_TYPE, NM, NL, nm, nl);
POLYBENCH_2D_ARRAY_DECL(G, DATA_TYPE, NI, NL, ni, nl);
#if !FMA_DISABLED
POLYBENCH_2D_ARRAY_DECL(G_StrictFP, DATA_TYPE, NI, NL, ni, nl);
#endif

/* Initialize array(s). */
init_array (ni, nj, nk, nl, nm,
Expand All @@ -211,6 +218,11 @@ int main(int argc, char** argv)
polybench_stop_instruments;
polybench_print_instruments;

#if FMA_DISABLED
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(G)));
#else
kernel_3mm_StrictFP(ni, nj, nk, nl, nm,
POLYBENCH_ARRAY(E),
POLYBENCH_ARRAY(A),
Expand All @@ -225,6 +237,7 @@ int main(int argc, char** argv)
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(G_StrictFP)));
#endif

/* Be clean. */
POLYBENCH_FREE_ARRAY(E);
Expand All @@ -234,7 +247,9 @@ int main(int argc, char** argv)
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(D);
POLYBENCH_FREE_ARRAY(G);
#if !FMA_DISABLED
POLYBENCH_FREE_ARRAY(G_StrictFP);
#endif

return 0;
}
Expand Up @@ -5,4 +5,7 @@ if(SMALL_PROBLEM_SIZE)
endif()
set(HASH_PROGRAM_OUTPUT 1)
add_definitions(-DFP_ABSTOLERANCE=1e-5)
# Floating point contraction must be suppressed due to accuracy issues
list(APPEND CXXFLAGS -ffp-contract=off -DFMA_DISABLED=1)
list(APPEND CFLAGS -ffp-contract=off -DFMA_DISABLED=1)
llvm_singlesource()

0 comments on commit 24550c3

Please sign in to comment.