Skip to content

Commit

Permalink
Merge branch 'sycl' into llvmspirv_pulldown
Browse files Browse the repository at this point in the history
  • Loading branch information
calebwat authored Jun 24, 2024
2 parents 4031172 + 157310a commit 111b781
Show file tree
Hide file tree
Showing 716 changed files with 24,304 additions and 8,446 deletions.
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ sycl/test-e2e/KernelFusion @intel/dpcpp-kernel-fusion-reviewers
sycl/include/sycl/ext/oneapi/matrix/ @intel/sycl-matrix-reviewers
sycl/test-e2e/Matrix @intel/sycl-matrix-reviewers
sycl/test/matrix @intel/sycl-matrix-reviewers
sycl/test/check_device_code/matrix @intel/sycl-matrix-reviewers

# Native CPU
llvm/**/*SYCLNativeCPU* @intel/dpcpp-nativecpu-pi-reviewers
Expand Down Expand Up @@ -164,3 +165,15 @@ sycl/test-e2e/DeviceCodeSplit/ @intel/dpcpp-tools-reviewers
sycl/test-e2e/SeparateCompile/ @intel/dpcpp-tools-reviewers
sycl/test-e2e/Printf/ @intel/dpcpp-tools-reviewers @intel/llvm-reviewers-runtime
sycl/test-e2e/SpecConstants/ @intel/dpcpp-tools-reviewers

# Sanitizer
clang/lib/Driver/SanitizerArgs.cpp @intel/dpcpp-sanitizers-review
libdevice/sanitizer_utils.cpp @intel/dpcpp-sanitizers-review
libdevice/include/asan_libdevice.hpp @intel/dpcpp-sanitizers-review
libdevice/include/sanitizer_utils.hpp @intel/dpcpp-sanitizers-review
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @intel/dpcpp-sanitizers-review
sycl/test-e2e/AddressSanitizer/ @intel/dpcpp-sanitizers-review
llvm/test/Instrumentation/AddressSanitizer/ @intel/dpcpp-sanitizers-review
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-sanitizers-review
6 changes: 3 additions & 3 deletions .github/workflows/sycl-linux-precommit-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:

jobs:
create-check:
runs-on: [Linux, build]
runs-on: [Linux, aux-tasks]
permissions:
checks: write
statuses: write
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
with:
name: CUDA E2E
runner: '["aws_cuda-${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image: ghcr.io/intel/llvm/ubuntu2204_build:latest-0300ac924620a51f76c4929794637b82790f12ab
image_options: -u 1001 --gpus all --cap-add SYS_ADMIN --env NVIDIA_DISABLE_REQUIRE=1
target_devices: ext_oneapi_cuda:gpu
# No idea why but that seems to work and be in sync with the main
Expand All @@ -79,7 +79,7 @@ jobs:
update-check:
needs: [create-check, e2e-cuda]
if: always()
runs-on: [Linux, build]
runs-on: [Linux, aux-tasks]
permissions:
checks: write
statuses: write
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/sycl-linux-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
build_artifact_suffix: "default"
build_cache_suffix: "default"
changes: ${{ needs.detect_changes.outputs.filters }}
build_image: "ghcr.io/intel/llvm/ubuntu2204_build:latest-0300ac924620a51f76c4929794637b82790f12ab"

determine_arc_tests:
name: Decide which Arc tests to run
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
include:
- name: AMD/HIP
runner: '["Linux", "amdgpu"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image: ghcr.io/intel/llvm/ubuntu2204_build:latest-0300ac924620a51f76c4929794637b82790f12ab
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd
target_devices: ext_oneapi_hip:gpu
- name: Intel
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/sycl-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ jobs:
target_devices: opencl:cpu
tests_selector: e2e

- name: Self-hosted CUDA
runner: '["Linux", "cuda"]'
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
image_options: -u 1001 --gpus all --cap-add SYS_ADMIN
target_devices: ext_oneapi_cuda:gpu
tests_selector: e2e

- name: SYCL-CTS on OCL CPU
runner: '["Linux", "gen12"]'
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
Expand Down
13 changes: 9 additions & 4 deletions buildbot/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def do_configure(args):
fusion_dir = os.path.join(abs_src_dir, "sycl-fusion")
llvm_targets_to_build = args.host_target
llvm_enable_projects = 'clang;' + llvm_external_projects
libclc_build_native = 'OFF'
libclc_targets_to_build = ''
libclc_gen_remangled_variants = 'OFF'
sycl_build_pi_hip_platform = 'AMD'
Expand Down Expand Up @@ -88,8 +89,10 @@ def do_configure(args):
sycl_enabled_plugins.append("hip")

if args.native_cpu:
# Todo: we should set whatever targets we support for native cpu
libclc_targets_to_build += ";x86_64-unknown-linux-gnu"
if args.native_cpu_libclc_targets:
libclc_targets_to_build += ";" + args.native_cpu_libclc_targets
else:
libclc_build_native = "ON"
libclc_gen_remangled_variants = "ON"
sycl_enabled_plugins.append("native_cpu")

Expand Down Expand Up @@ -191,6 +194,7 @@ def do_configure(args):
"-DLIBCLC_GENERATE_REMANGLED_VARIANTS={}".format(
libclc_gen_remangled_variants
),
"-DLIBCLC_NATIVECPU_HOST_TARGET={}".format(libclc_build_native),
]
)

Expand Down Expand Up @@ -257,8 +261,8 @@ def main():
parser.add_argument("--native_cpu", action='store_true', help="Enable SYCL Native CPU")
parser.add_argument("--hip", action='store_true', help="switch from OpenCL to HIP")
parser.add_argument("--hip-platform", type=str, choices=['AMD', 'NVIDIA'], default='AMD', help="choose hardware platform for HIP backend")
parser.add_argument("--host-target", default='X86',
help="host LLVM target architecture, defaults to X86, multiple targets may be provided as a semi-colon separated string")
parser.add_argument("--host-target", default='host',
help="host LLVM target architecture, defaults to \'host\', multiple targets may be provided as a semi-colon separated string")
parser.add_argument("--enable-all-llvm-targets", action='store_true', help="build compiler with all supported targets, it doesn't change runtime build")
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
Expand All @@ -276,6 +280,7 @@ def main():
parser.add_argument("--disable-preview-lib", action='store_true', help="Disable building of the SYCL runtime major release preview library")
parser.add_argument("--disable-fusion", action="store_true", help="Disable the kernel fusion JIT compiler")
parser.add_argument("--add_security_flags", type=str, choices=['none', 'default', 'sanitize'], default=None, help="Enables security flags for compile & link. Two values are supported: 'default' and 'sanitize'. 'Sanitize' option is an extension of 'default' set.")
parser.add_argument('--native-cpu-libclc-targets', help='Target triples for libclc, used by the Native CPU backend')
args = parser.parse_args()

print("args:{}".format(args))
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ def warn_drv_opt_requires_opt
: Warning<"'%0' should be used only in conjunction with '%1'">, InGroup<UnusedCommandLineArgument>;
def err_drv_sycl_missing_amdgpu_arch : Error<
"missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend%select{|=%1}0 --offload-arch=<arch-name>'">;
def err_drv_sycl_thinlto_split_off: Error<
"'%0' is not supported when '%1' is set with '-fsycl'">;
def warn_drv_sycl_offload_target_duplicate : Warning<
"SYCL offloading target '%0' is similar to target '%1' already specified; "
"will be ignored">, InGroup<SyclTarget>;
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12031,10 +12031,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
// or `indirectly_callable' attribute must be emitted regardless of number
// of actual uses
if (LangOpts.SYCLIsDevice && isa<CXXMethodDecl>(D)) {
if (auto *A = D->getAttr<SYCLDeviceIndirectlyCallableAttr>())
return !A->isImplicit();
if (auto *A = D->getAttr<SYCLDeviceAttr>())
return !A->isImplicit();
if (D->hasAttr<SYCLDeviceIndirectlyCallableAttr>())
return true;
if (D->hasAttr<SYCLDeviceAttr>())
return true;
}

GVALinkage Linkage = GetGVALinkageForFunction(FD);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Basic/Targets/NVPTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__SYCL_CUDA_ARCH__", CUDAArchCode);
} else {
Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
if (GPU == CudaArch::SM_90a)
Builder.defineMacro("__CUDA_ARCH_FEAT_SM90_ALL", "1");
}
if (GPU == CudaArch::SM_90a)
Builder.defineMacro("__CUDA_ARCH_FEAT_SM90_ALL", "1");
}
}

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,9 +1881,9 @@ static llvm::fp::FPAccuracy convertFPAccuracy(StringRef FPAccuracyStr) {
}

static int32_t convertFPAccuracyToAspect(StringRef FPAccuracyStr) {
assert(FPAccuracyStr.equals("high") || FPAccuracyStr.equals("medium") ||
FPAccuracyStr.equals("low") || FPAccuracyStr.equals("sycl") ||
FPAccuracyStr.equals("cuda"));
assert(FPAccuracyStr == "high" || FPAccuracyStr == "medium" ||
FPAccuracyStr == "low" || FPAccuracyStr == "sycl" ||
FPAccuracyStr == "cuda");
return llvm::StringSwitch<int32_t>(FPAccuracyStr)
.Case("high", SYCLInternalAspect::fp_intrinsic_accuracy_high)
.Case("medium", SYCLInternalAspect::fp_intrinsic_accuracy_medium)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
// when the nvptx*-nvidia-cuda is passed to -fsycl-targets.
if (DefaultToolChain.getTriple().isNVPTX())
return false;
if (llvm::sys::path::extension(ActualFile).equals(".spv"))
if (llvm::sys::path::extension(ActualFile) == ".spv")
return false;
}
}
Expand Down
71 changes: 51 additions & 20 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ static bool isValidSYCLTriple(llvm::Triple T) {
// SPIR/SPIRV arch, but has invalid SubArch for AOT.
StringRef A(T.getArchName());
if (T.getSubArch() == llvm::Triple::NoSubArch &&
((T.getArch() == llvm::Triple::spir && !A.equals("spir")) ||
(T.getArch() == llvm::Triple::spir64 && !A.equals("spir64"))))
((T.getArch() == llvm::Triple::spir && A != "spir") ||
(T.getArch() == llvm::Triple::spir64 && A != "spir64")))
return false;
return true;
}
Expand Down Expand Up @@ -1149,7 +1149,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
return;
const char *ArgValue = A->getValue();
for (const StringRef AllowedValue : AllowedValues)
if (AllowedValue.equals(ArgValue))
if (AllowedValue == ArgValue)
return;
Diag(clang::diag::err_drv_invalid_argument_to_option)
<< ArgValue << A->getOption().getName();
Expand Down Expand Up @@ -1182,6 +1182,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
// of -fsycl*target options passed
Arg *SYCLTargetsValues = SYCLTargets;
if (SYCLTargetsValues) {
llvm::StringSet<> SYCLTriples;
if (SYCLTargetsValues->getNumValues()) {

// Multiple targets are currently not supported when using
Expand Down Expand Up @@ -1220,15 +1221,40 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
const ToolChain *HostTC =
C.getSingleOffloadToolChain<Action::OFK_Host>();
llvm::Triple HostTriple = HostTC->getTriple();
UniqueSYCLTriplesVec.push_back(HostTriple);
SYCLTriples.insert(HostTriple.normalize());
continue;
}

if (!isValidSYCLTriple(MakeSYCLDeviceTriple(UserTargetName))) {
llvm::Triple DeviceTriple(MakeSYCLDeviceTriple(UserTargetName));
if (!isValidSYCLTriple(DeviceTriple)) {
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
continue;
}

// For any -fsycl-targets=spir64_gen additions, we will scan the
// additional -X* options for potential -device settings. These
// need to be added as a known Arch to the packager.
if (DeviceTriple.isSPIRAOT() && Arch.empty() &&
DeviceTriple.getSubArch() == llvm::Triple::SPIRSubArch_gen) {
const ToolChain *HostTC =
C.getSingleOffloadToolChain<Action::OFK_Host>();
auto DeviceTC = std::make_unique<toolchains::SYCLToolChain>(
*this, DeviceTriple, *HostTC, C.getInputArgs());
assert(DeviceTC && "Device toolchain not defined.");
ArgStringList TargetArgs;
DeviceTC->TranslateBackendTargetArgs(DeviceTC->getTriple(),
C.getInputArgs(), TargetArgs);
// Look for -device <string> and use that as the known arch to
// be associated with the current spir64_gen entry. Grab the
// right most entry.
for (int i = TargetArgs.size() - 2; i >= 0; --i) {
if (StringRef(TargetArgs[i]) == "-device") {
Arch = TargetArgs[i + 1];
break;
}
}
}

// Make sure we don't have a duplicate triple.
std::string NormalizedName = MakeSYCLDeviceTriple(Val).normalize();
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
Expand All @@ -1241,11 +1267,16 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
// Store the current triple so that we can check for duplicates in
// the following iterations.
FoundNormalizedTriples[NormalizedName] = Val;
llvm::Triple DeviceTriple(MakeSYCLDeviceTriple(UserTargetName));
UniqueSYCLTriplesVec.push_back(DeviceTriple);
SYCLTriples.insert(DeviceTriple.normalize());
if (!Arch.empty())
DerivedArchs[DeviceTriple.getTriple()].insert(Arch);
}
if (!SYCLTriples.empty()) {
for (const auto &SYCLTriple : SYCLTriples) {
llvm::Triple Triple(SYCLTriple.getKey());
UniqueSYCLTriplesVec.push_back(Triple);
}
}
addSYCLDefaultTriple(C, UniqueSYCLTriplesVec);
} else
Diag(clang::diag::warn_drv_empty_joined_argument)
Expand Down Expand Up @@ -1891,7 +1922,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// an external option setting is required to target hardware.
setOffloadCompileMode(FPGAEmulationMode);
for (StringRef ArgString : TargetArgs) {
if (ArgString.equals("-hardware") || ArgString.equals("-simulation")) {
if (ArgString == "-hardware" || ArgString == "-simulation") {
setOffloadCompileMode(FPGAHWMode);
break;
}
Expand Down Expand Up @@ -5022,17 +5053,16 @@ class OffloadingActionBuilder final {
}

// By default, we produce an action for each device arch.
auto TC = ToolChains.begin();
for (Action *&A : SYCLDeviceActions) {
if ((*TC)->getTriple().isNVPTX() && CurPhase >= phases::Backend) {
for (auto TargetActionInfo :
llvm::zip(SYCLDeviceActions, SYCLTargetInfoList)) {
auto &TargetInfo = std::get<1>(TargetActionInfo);
if (TargetInfo.TC->getTriple().isNVPTX() && CurPhase >= phases::Backend)
// For CUDA, stop to emit LLVM IR so it can be linked later on.
++TC;
continue;
}

Action *&A = std::get<0>(TargetActionInfo);
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
AssociatedOffloadKind);
++TC;
}

return ABRT_Success;
Expand Down Expand Up @@ -6241,12 +6271,12 @@ class OffloadingActionBuilder final {
using namespace tools::SYCL;
StringRef Device{Value.first};
if (Device.consume_front(gen::AmdGPU))
return TargetArch.equals(Device) && TargetTriple.isAMDGCN();
return TargetArch == Device && TargetTriple.isAMDGCN();
if (Device.consume_front(gen::NvidiaGPU))
return TargetArch.equals(Device) && TargetTriple.isNVPTX();
return TargetArch == Device && TargetTriple.isNVPTX();
if (Device.consume_front(gen::IntelGPU))
return TargetArch.equals(Device) && TargetTriple.isSPIRAOT();
return TargetArch.equals(Device) && isValidSYCLTriple(TargetTriple);
return TargetArch == Device && TargetTriple.isSPIRAOT();
return TargetArch == Device && isValidSYCLTriple(TargetTriple);
});
} else {
TargetIt = TargetTable.find(TargetTriple.str());
Expand Down Expand Up @@ -9604,7 +9634,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
bool IsHIPNoRDC = JA.getOffloadingDeviceKind() == Action::OFK_HIP &&
!C.getArgs().hasFlag(options::OPT_fgpu_rdc,
options::OPT_fno_gpu_rdc, false);
bool UseOutExtension = IsHIPNoRDC || isa<OffloadPackagerJobAction>(JA);
bool UseOutExtension = IsHIPNoRDC || isa<OffloadPackagerJobAction>(JA) ||
isa<BackendCompileJobAction>(JA);
if (UseOutExtension) {
Output = BaseName;
llvm::sys::path::replace_extension(Output, "");
Expand Down Expand Up @@ -9701,7 +9732,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const auto &ResultFiles = C.getResultFiles();
const auto CollidingFilenameIt =
llvm::find_if(ResultFiles, [NamedOutput](const auto &It) {
return StringRef(NamedOutput).equals(It.second);
return StringRef(NamedOutput) == It.second;
});
if (CollidingFilenameIt != ResultFiles.end()) {
// Upon any collision, a unique hash will be appended to the filename,
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
CmdArgs.push_back("-asan-stack=0");
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-asan-globals=0");
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-asan-mapping-scale=4");
}
return;
}
Expand Down
Loading

0 comments on commit 111b781

Please sign in to comment.