Skip to content

Commit 7e4ac49

Browse files
authored
[SYCLomatic][CMake] Add migration of CUDA specific option "--use_fast_math" and "-use_fast_math" (#2014)
Signed-off-by: chenwei.sun <[email protected]>
1 parent a886063 commit 7e4ac49

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: rm -rf %T && mkdir -p %T
2+
// RUN: cd %T
3+
// RUN: cp %S/input.cmake ./input.cmake
4+
// RUN: dpct -in-root ./ -out-root out ./input.cmake --migrate-build-script-only
5+
// RUN: echo "begin" > %T/diff.txt
6+
// RUN: diff --strip-trailing-cr %S/expected.txt %T/out/input.cmake >> %T/diff.txt
7+
// RUN: echo "end" >> %T/diff.txt
8+
9+
// CHECK: begin
10+
// CHECK-NEXT: end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compiler options
2+
set_source_files_properties(fused_softmax/scaled_masked_softmax.dp.cpp
3+
fused_softmax/scaled_upper_triang_masked_softmax.dp.cpp
4+
fused_softmax/scaled_aligned_causal_masked_softmax.dp.cpp
5+
PROPERTIES
6+
COMPILE_OPTIONS "-ffast-math")
7+
8+
# Compiler options
9+
set_source_files_properties(fused_softmax/scaled_masked_softmax.dp.cpp
10+
fused_softmax/scaled_upper_triang_masked_softmax.dp.cpp
11+
fused_softmax/scaled_aligned_causal_masked_softmax.dp.cpp
12+
PROPERTIES
13+
COMPILE_OPTIONS "-ffast-math")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compiler options
2+
set_source_files_properties(fused_softmax/scaled_masked_softmax.cu
3+
fused_softmax/scaled_upper_triang_masked_softmax.cu
4+
fused_softmax/scaled_aligned_causal_masked_softmax.cu
5+
PROPERTIES
6+
COMPILE_OPTIONS "--use_fast_math")
7+
8+
# Compiler options
9+
set_source_files_properties(fused_softmax/scaled_masked_softmax.cu
10+
fused_softmax/scaled_upper_triang_masked_softmax.cu
11+
fused_softmax/scaled_aligned_causal_masked_softmax.cu
12+
PROPERTIES
13+
COMPILE_OPTIONS "-use_fast_math")

clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,4 +2538,30 @@
25382538
MatchMode: Full
25392539
In: cuda
25402540
Out: ""
2541-
RuleId: "remove_lib_cuda"
2541+
RuleId: "remove_lib_cuda"
2542+
2543+
- Rule: rule_use_fast_math_one_dash
2544+
Kind: CMakeRule
2545+
Priority: Fallback
2546+
MatchMode: Partial
2547+
CmakeSyntax: use_fast_math_one_dash
2548+
In: ${func_name}(${value})
2549+
Out: ${func_name}(${value})
2550+
Subrules:
2551+
value:
2552+
MatchMode: Full
2553+
In: -use_fast_math
2554+
Out: -ffast-math
2555+
2556+
- Rule: rule_use_fast_math_two_dash
2557+
Kind: CMakeRule
2558+
Priority: Fallback
2559+
MatchMode: Partial
2560+
CmakeSyntax: use_fast_math_two_dash
2561+
In: ${func_name}(${value})
2562+
Out: ${func_name}(${value})
2563+
Subrules:
2564+
value:
2565+
MatchMode: Full
2566+
In: --use_fast_math
2567+
Out: -ffast-math

0 commit comments

Comments
 (0)