Skip to content

Commit 0909cfb

Browse files
committed
[SYCL] Enable standard optimization pipeline for device code by default
Add new compiler flag to disable optimizations at compile time: -fno-sycl-std-optimizations Temporally disable optimizations in some LIT tests.
1 parent d5a7f20 commit 0909cfb

File tree

19 files changed

+24
-20
lines changed

19 files changed

+24
-20
lines changed

clang/include/clang/Driver/Options.td

+1-2
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,7 @@ def fsycl_esimd : Flag<["-"], "fsycl-explicit-simd">, Group<sycl_Group>, Flags<[
35303530
HelpText<"Enable SYCL explicit SIMD extension">;
35313531
def fno_sycl_esimd : Flag<["-"], "fno-sycl-explicit-simd">, Group<sycl_Group>,
35323532
HelpText<"Disable SYCL explicit SIMD extension">, Flags<[NoArgumentUnused, CoreOption]>;
3533+
defm sycl_std_optimizations : OptOutFFlag<"sycl-std-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler">;
35333534

35343535
//===----------------------------------------------------------------------===//
35353536
// CC1 Options
@@ -4454,8 +4455,6 @@ def fsycl_std_layout_kernel_params: Flag<["-"], "fsycl-std-layout-kernel-params"
44544455
def fsycl_allow_func_ptr : Flag<["-"], "fsycl-allow-func-ptr">,
44554456
HelpText<"Allow function pointers in SYCL device.">;
44564457
def fno_sycl_allow_func_ptr : Flag<["-"], "fno-sycl-allow-func-ptr">;
4457-
def fsycl_enable_optimizations: Flag<["-"], "fsycl-enable-optimizations">,
4458-
HelpText<"Experimental flag enabling standard optimization in the front-end.">;
44594458

44604459
} // let Flags = [CC1Option]
44614460

clang/lib/Driver/ToolChains/Clang.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -4102,6 +4102,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
41024102
if (Args.hasFlag(options::OPT_fsycl_esimd, options::OPT_fno_sycl_esimd,
41034103
false))
41044104
CmdArgs.push_back("-fsycl-explicit-simd");
4105+
4106+
if (!Args.hasFlag(options::OPT_fsycl_std_optimizations,
4107+
options::OPT_fno_sycl_std_optimizations, true))
4108+
CmdArgs.push_back("-fno-sycl-std-optimizations");
4109+
41054110
// Pass the triple of host when doing SYCL
41064111
auto AuxT = llvm::Triple(llvm::sys::getProcessTriple());
41074112
std::string NormalizedTriple = AuxT.normalize();

clang/lib/Frontend/CompilerInvocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
823823
Opts.DisableLLVMPasses =
824824
Args.hasArg(OPT_disable_llvm_passes) ||
825825
(Args.hasArg(OPT_fsycl_is_device) && Triple.isSPIR() &&
826-
!Args.hasArg(OPT_fsycl_enable_optimizations) && !IsSyclESIMD);
826+
Args.hasArg(OPT_fno_sycl_std_optimizations) && !IsSyclESIMD);
827827
Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
828828

829829
const llvm::Triple::ArchType DebugEntryValueArchs[] = {

clang/test/CodeGenSYCL/inline_asm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-enable-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm -x c++ %s -o - | FileCheck %s
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm -x c++ %s -o - | FileCheck %s
22

33
class kernel;
44

clang/test/CodeGenSYCL/remove-ur-inst.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fno-sycl-std-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
12
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
2-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-enable-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
33

44
SYCL_EXTERNAL void doesNotReturn() throw() __attribute__((__noreturn__));
55

sycl/test/basic_tests/accessor/accessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/basic_tests/boolean.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/basic_tests/stream/stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | FileCheck %s
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
44
// RUN: %GPU_RUN_ON_LINUX_PLACEHOLDER %t.out %GPU_CHECK_ON_LINUX_PLACEHOLDER

sycl/test/check_device_code/fpga_ihs_float.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// RUN: %clangxx -I %sycl_include -S -emit-llvm -fsycl -fsycl-device-only %s -o - | FileCheck %s
10-
// RUN: %clangxx -I %sycl_include -S -emit-llvm -fsycl -fsycl-device-only %s -Xclang -fsycl-enable-optimizations -o - | FileCheck %s
10+
// RUN: %clangxx -I %sycl_include -S -emit-llvm -fsycl -fno-sycl-std-optimizations -fsycl-device-only %s -o - | FileCheck %s
1111

1212
#include "CL/__spirv/spirv_ops.hpp"
1313

sycl/test/fpga_tests/fpga_lsu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations %s -o %t.out
22
// RUNx: %ACC_RUN_PLACEHOLDER %t.out
33
//==----------------- fpga_lsu.cpp - SYCL FPGA LSU test --------------------==//
44
//

sycl/test/hier_par/hier_par_wgscope.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
9+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
1010
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
1111
// RUN: %CPU_RUN_PLACEHOLDER %t.out
1212
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/regression/group.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/spec_const/spec_const_hw.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// UNSUPPORTED: cuda || level_zero
22
//
3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
3+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
44
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
55
// RUN: %CPU_RUN_PLACEHOLDER %t.out
66
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/sub_group/generic_reduce.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -std=c++14 %s -o %t.out
5-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple -std=c++14 -D SG_GPU %s -o %t_gpu.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-unnamed-lambda -std=c++14 %s -o %t.out
5+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple -std=c++14 -D SG_GPU %s -o %t_gpu.out
66
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
77
// RUN: %CPU_RUN_PLACEHOLDER %t.out
88
// RUN: %GPU_RUN_PLACEHOLDER %t_gpu.out

sycl/test/sub_group/load_store.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
55
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
66
// RUN: %CPU_RUN_PLACEHOLDER %t.out
77
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/sub_group/scan_fp16.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66

77
//==--------------- scan_fp16.cpp - SYCL sub_group scan test --------*- C++ -*---==//

sycl/test/sub_group/shuffle.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
55
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
66
// RUN: %CPU_RUN_PLACEHOLDER %t.out
77
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/sub_group/shuffle_fp16.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66
//
77
//==------------ shuffle_fp16.cpp - SYCL sub_group shuffle test -----*- C++ -*---==//

sycl/test/sub_group/shuffle_fp64.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// UNSUPPORTED: cuda
22
// CUDA compilation and runtime do not yet support sub-groups.
33
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
4+
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
55
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
66
// RUN: %CPU_RUN_PLACEHOLDER %t.out
77
// RUN: %GPU_RUN_PLACEHOLDER %t.out

0 commit comments

Comments
 (0)