Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Enable standard optimization pipeline for device code #2207

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,7 @@ def fsycl_esimd : Flag<["-"], "fsycl-explicit-simd">, Group<sycl_Group>, Flags<[
HelpText<"Enable SYCL explicit SIMD extension">;
def fno_sycl_esimd : Flag<["-"], "fno-sycl-explicit-simd">, Group<sycl_Group>,
HelpText<"Disable SYCL explicit SIMD extension">, Flags<[NoArgumentUnused, CoreOption]>;
defm sycl_std_optimizations : OptOutFFlag<"sycl-std-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler">;

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

} // let Flags = [CC1Option]

Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4102,6 +4102,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasFlag(options::OPT_fsycl_esimd, options::OPT_fno_sycl_esimd,
false))
CmdArgs.push_back("-fsycl-explicit-simd");

if (!Args.hasFlag(options::OPT_fsycl_std_optimizations,
options::OPT_fno_sycl_std_optimizations, true))
CmdArgs.push_back("-fno-sycl-std-optimizations");
bader marked this conversation as resolved.
Show resolved Hide resolved

// Pass the triple of host when doing SYCL
auto AuxT = llvm::Triple(llvm::sys::getProcessTriple());
std::string NormalizedTriple = AuxT.normalize();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DisableLLVMPasses =
Args.hasArg(OPT_disable_llvm_passes) ||
(Args.hasArg(OPT_fsycl_is_device) && Triple.isSPIR() &&
!Args.hasArg(OPT_fsycl_enable_optimizations) && !IsSyclESIMD);
Args.hasArg(OPT_fno_sycl_std_optimizations) && !IsSyclESIMD);
Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);

const llvm::Triple::ArchType DebugEntryValueArchs[] = {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/inline_asm.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-enable-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm -x c++ %s -o - | FileCheck %s
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm -x c++ %s -o - | FileCheck %s
bader marked this conversation as resolved.
Show resolved Hide resolved

class kernel;

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/remove-ur-inst.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fno-sycl-std-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-enable-optimizations -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s

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

Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/accessor/accessor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
Fznamznon marked this conversation as resolved.
Show resolved Hide resolved
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/boolean.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/stream/stream.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | FileCheck %s
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
// RUN: %GPU_RUN_ON_LINUX_PLACEHOLDER %t.out %GPU_CHECK_ON_LINUX_PLACEHOLDER
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/check_device_code/fpga_ihs_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

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

#include "CL/__spirv/spirv_ops.hpp"

Expand Down
2 changes: 1 addition & 1 deletion sycl/test/fpga_tests/fpga_lsu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations %s -o %t.out
// RUNx: %ACC_RUN_PLACEHOLDER %t.out
//==----------------- fpga_lsu.cpp - SYCL FPGA LSU test --------------------==//
//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/hier_par/hier_par_wgscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/regression/group.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/spec_const/spec_const_hw.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// UNSUPPORTED: cuda || level_zero
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
4 changes: 2 additions & 2 deletions sycl/test/sub_group/generic_reduce.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -std=c++14 %s -o %t.out
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple -std=c++14 -D SG_GPU %s -o %t_gpu.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-unnamed-lambda -std=c++14 %s -o %t.out
// 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
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t_gpu.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/sub_group/load_store.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/sub_group/scan_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

//==--------------- scan_fp16.cpp - SYCL sub_group scan test --------*- C++ -*---==//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/sub_group/shuffle.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/sub_group/shuffle_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
//
//==------------ shuffle_fp16.cpp - SYCL sub_group shuffle test -----*- C++ -*---==//
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/sub_group/shuffle_fp64.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// UNSUPPORTED: cuda
// CUDA compilation and runtime do not yet support sub-groups.
//
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %clangxx -fsycl -fno-sycl-std-optimizations -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down