Skip to content

[WIP] Refactor SYCL compilation with 125556 changes from community #19709

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

Draft
wants to merge 17 commits into
base: sycl-web
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 9 additions & 8 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def warn_flag_no_sycl_libspirv
InGroup<UnsafeLibspirvNotLinked>;
def err_drv_mix_cuda_hip : Error<
"mixed CUDA and HIP compilation is not supported">;
def err_drv_mix_offload
: Error<"mixed %0 and %1 offloading compilation is not supported">;
def err_drv_bad_target_id : Error<
"invalid target ID '%0'; format is a processor name followed by an optional "
"colon-delimited list of features followed by an enable/disable sign (e.g., "
Expand Down Expand Up @@ -415,9 +417,11 @@ def err_drv_sycl_offload_arch_new_driver: Error<
"'--offload-arch' is supported when '-fsycl' is set with '--offload-new-driver'">;
def err_drv_sycl_offload_arch_missing_value : Error<
"must pass in an explicit cpu or gpu architecture to '--offload-arch'">;
def warn_drv_sycl_offload_target_duplicate : Warning<
"SYCL offloading target '%0' is similar to target '%1' already specified; "
"will be ignored">, InGroup<SyclTarget>;
def warn_drv_offload_target_duplicate
: Warning<
"offloading target '%0' is similar to target '%1' already specified; "
"will be ignored">,
InGroup<OffloadTarget>;
def warn_drv_sycl_target_missing : Warning<
"linked binaries do not contain expected '%0' target; found targets: '%1'">,
InGroup<SyclTarget>;
Expand Down Expand Up @@ -445,11 +449,8 @@ def err_drv_omp_offload_target_missingbcruntime : Error<
"; use '--libomptarget-%1-bc-path' to specify %1 bitcode library">;
def err_drv_omp_offload_target_bcruntime_not_found : Error<
"bitcode library '%0' does not exist">;
def err_drv_omp_offload_target_cuda_version_not_support : Error<
"NVPTX target requires CUDA 9.2 or above; CUDA %0 detected">;
def warn_drv_omp_offload_target_duplicate : Warning<
"OpenMP offloading target '%0' is similar to target '%1' already specified; "
"will be ignored">, InGroup<OpenMPTarget>;
def err_drv_omp_offload_target_cuda_version_not_support
: Error<"NVPTX target requires CUDA 9.2 or above; CUDA %0 detected">;
def err_drv_unsupported_embed_bitcode
: Error<"%0 is not supported with -fembed-bitcode">;
def err_drv_bitcode_unsupported_on_toolchain : Error<
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,9 @@ def SyclAspectMismatch : DiagGroup<"sycl-aspect-mismatch">;
def SyclNativeCPUTargets: DiagGroup<"sycl-native-cpu-targets">;
def SyclPrivateAllocaPositiveSize : DiagGroup<"sycl-private-alloca-positive-size">;

// Common warnings for SYCL and OpenMP offloading
def OffloadTarget : DiagGroup<"offload-target">;

// OpenACC warnings.
def SourceUsesOpenACC : DiagGroup<"source-uses-openacc">;
def OpenACC : DiagGroup<"openacc", [SourceUsesOpenACC]>;
Expand Down
5 changes: 3 additions & 2 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ class Driver {
// handleArguments.
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
llvm::opt::Arg **FinalPhaseArg = nullptr) const;
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
executeProgram(llvm::ArrayRef<llvm::StringRef> Args) const;

private:
/// Certain options suppress the 'no input files' warning.
Expand Down Expand Up @@ -549,8 +551,7 @@ class Driver {
/// empty string.
llvm::SmallVector<StringRef>
getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
Action::OffloadKind Kind, const ToolChain *TC,
bool SpecificToolchain = true) const;
Action::OffloadKind Kind, const ToolChain &TC) const;

/// Check that the file referenced by Value exists. If it doesn't,
/// issue a diagnostic and return false.
Expand Down
29 changes: 19 additions & 10 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,12 @@ def offload_arch_EQ : CommaJoined<["--"], "offload-arch=">,
"If 'native' is used the compiler will detect locally installed architectures. "
"For HIP offloading, the device architecture can be followed by target ID features "
"delimited by a colon (e.g. gfx908:xnack+:sramecc-). May be specified more than once.">;
def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">,
Visibility<[ClangOption, FlangOption]>,
HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;
def no_offload_arch_EQ
: CommaJoined<["--"], "no-offload-arch=">,
Visibility<[ClangOption, FlangOption]>,
HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, "
"gfx906) from the list of devices to compile for. "
"'all' resets the list to its default value.">;

def offload_new_driver : Flag<["--"], "offload-new-driver">,
Visibility<[ClangOption, CC1Option]>, Group<f_Group>,
Expand Down Expand Up @@ -1732,8 +1734,11 @@ defm auto_import : BoolFOption<"auto-import",
// In the future this option will be supported by other offloading
// languages and accept other values such as CPU/GPU architectures,
// offload kinds and target aliases.
def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
HelpText<"Specify comma-separated list of offloading target triples (CUDA and HIP only)">;
def offload_EQ : CommaJoined<["--"], "offload=">,
Flags<[NoXarchOption]>,
Alias<offload_targets_EQ>,
HelpText<"Specify comma-separated list of offloading target "
"triples (CUDA and HIP only)">;

// C++ Coroutines
defm coroutines : BoolFOption<"coroutines",
Expand Down Expand Up @@ -7267,10 +7272,14 @@ defm sycl_rtc_mode: BoolFOption<"sycl-rtc-mode",
def fno_sycl_esimd_build_host_code : Flag<["-"], "fno-sycl-esimd-build-host-code">,
Visibility<[ClangOption, CLOption, CC1Option]>, Flags<[HelpHidden]>,
HelpText<"Do not build the host implementation of ESIMD functions.">;
def fsycl_targets_EQ : CommaJoined<["-"], "fsycl-targets=">,
Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, CC1Option]>,
HelpText<"Specify comma-separated list of triples SYCL offloading targets "
"to be supported">;
def fsycl_targets_EQ
: CommaJoined<["-"], "fsycl-targets=">,
Alias<offload_targets_EQ>,
Flags<[NoXarchOption]>,
Visibility<[ClangOption, CLOption, CC1Option]>,
HelpText<
"Specify comma-separated list of triples SYCL offloading targets "
"to be supported">;
def fsycl_force_target_EQ : Joined<["-"], "fsycl-force-target=">,
Flags<[NoXarchOption]>,
HelpText<"Force the usage of the given triple when extracting device code "
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ class ToolChain {
ToolChain(const Driver &D, const llvm::Triple &T,
const llvm::opt::ArgList &Args);

/// Executes the given \p Executable and returns the stdout.
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
executeToolChainProgram(StringRef Executable) const;

void setTripleEnvironment(llvm::Triple::EnvironmentType Env);

virtual Tool *buildAssembler() const;
Expand Down
Loading