diff --git a/clang/test/dpct/cmake_migration/case_045/case_045_use_fast_math.cpp b/clang/test/dpct/cmake_migration/case_045/case_045_use_fast_math.cpp new file mode 100644 index 000000000000..a62d747147a8 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_045/case_045_use_fast_math.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %T && mkdir -p %T +// RUN: cd %T +// RUN: cp %S/input.cmake ./input.cmake +// RUN: dpct -in-root ./ -out-root out ./input.cmake --migrate-build-script-only +// RUN: echo "begin" > %T/diff.txt +// RUN: diff --strip-trailing-cr %S/expected.txt %T/out/input.cmake >> %T/diff.txt +// RUN: echo "end" >> %T/diff.txt + +// CHECK: begin +// CHECK-NEXT: end diff --git a/clang/test/dpct/cmake_migration/case_045/expected.txt b/clang/test/dpct/cmake_migration/case_045/expected.txt new file mode 100644 index 000000000000..8bcf9071de66 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_045/expected.txt @@ -0,0 +1,13 @@ +# Compiler options +set_source_files_properties(fused_softmax/scaled_masked_softmax.dp.cpp + fused_softmax/scaled_upper_triang_masked_softmax.dp.cpp + fused_softmax/scaled_aligned_causal_masked_softmax.dp.cpp + PROPERTIES + COMPILE_OPTIONS "-ffast-math") + +# Compiler options +set_source_files_properties(fused_softmax/scaled_masked_softmax.dp.cpp + fused_softmax/scaled_upper_triang_masked_softmax.dp.cpp + fused_softmax/scaled_aligned_causal_masked_softmax.dp.cpp + PROPERTIES + COMPILE_OPTIONS "-ffast-math") diff --git a/clang/test/dpct/cmake_migration/case_045/input.cmake b/clang/test/dpct/cmake_migration/case_045/input.cmake new file mode 100644 index 000000000000..19ba69c47143 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_045/input.cmake @@ -0,0 +1,13 @@ +# Compiler options +set_source_files_properties(fused_softmax/scaled_masked_softmax.cu + fused_softmax/scaled_upper_triang_masked_softmax.cu + fused_softmax/scaled_aligned_causal_masked_softmax.cu + PROPERTIES + COMPILE_OPTIONS "--use_fast_math") + +# Compiler options +set_source_files_properties(fused_softmax/scaled_masked_softmax.cu + fused_softmax/scaled_upper_triang_masked_softmax.cu + fused_softmax/scaled_aligned_causal_masked_softmax.cu + PROPERTIES + COMPILE_OPTIONS "-use_fast_math") diff --git a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml index ff60d93e2ed3..22aac70f0225 100644 --- a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml +++ b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml @@ -2538,4 +2538,30 @@ MatchMode: Full In: cuda Out: "" - RuleId: "remove_lib_cuda" \ No newline at end of file + RuleId: "remove_lib_cuda" + +- Rule: rule_use_fast_math_one_dash + Kind: CMakeRule + Priority: Fallback + MatchMode: Partial + CmakeSyntax: use_fast_math_one_dash + In: ${func_name}(${value}) + Out: ${func_name}(${value}) + Subrules: + value: + MatchMode: Full + In: -use_fast_math + Out: -ffast-math + +- Rule: rule_use_fast_math_two_dash + Kind: CMakeRule + Priority: Fallback + MatchMode: Partial + CmakeSyntax: use_fast_math_two_dash + In: ${func_name}(${value}) + Out: ${func_name}(${value}) + Subrules: + value: + MatchMode: Full + In: --use_fast_math + Out: -ffast-math