Skip to content
Merged
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
21 changes: 16 additions & 5 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ static OclocInfo PVCDevices[] = {

// Determine if any of the given arguments contain any PVC based values for
// the -device option.
static bool hasPVCDevice(const ArgStringList &CmdArgs) {
static bool hasPVCDevice(const ArgStringList &CmdArgs, std::string &DevArg) {
bool DeviceSeen = false;
StringRef DeviceArg;
for (StringRef Arg : CmdArgs) {
Expand Down Expand Up @@ -1074,16 +1074,22 @@ static bool hasPVCDevice(const ArgStringList &CmdArgs) {
// Check for device, version or hex (literal values)
for (unsigned int I = 0; I < std::size(PVCDevices); I++) {
if (SingleArg.equals_insensitive(PVCDevices[I].DeviceName) ||
SingleArg.equals_insensitive(PVCDevices[I].Version))
SingleArg.equals_insensitive(PVCDevices[I].Version)) {
DevArg = SingleArg.str();
return true;
}
for (int HexVal : PVCDevices[I].HexValues) {
int Value = 0;
if (!SingleArg.getAsInteger(0, Value) && Value == HexVal)
if (!SingleArg.getAsInteger(0, Value) && Value == HexVal) {
DevArg = SingleArg.str();
return true;
}
}
if (CheckShortVersion &&
StringRef(PVCDevices[I].Version).starts_with(SingleArg))
StringRef(PVCDevices[I].Version).starts_with(SingleArg)) {
DevArg = SingleArg.str();
return true;
}
}
}
return false;
Expand Down Expand Up @@ -1659,8 +1665,13 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple,
Args.AddAllArgValues(TargArgs, options::OPT_Xs, options::OPT_Xs_separate);
Args.AddAllArgValues(TargArgs, options::OPT_Xsycl_backend);
// Check for any -device settings.
if (IsJIT || Device == "pvc" || hasPVCDevice(TargArgs)) {
std::string DevArg;
if (IsJIT || Device == "pvc" || hasPVCDevice(TargArgs, DevArg)) {
// The -device option passed in by the user may not be 'pvc'. Use the
// value provided by the user if it was specified.
StringRef DeviceName = "pvc";
if (!DevArg.empty())
DeviceName = DevArg;
StringRef BackendOptName = SYCL::gen::getGenGRFFlag("auto");
if (IsGen)
PerDeviceArgs.push_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:auto %s 2>&1 \
// RUN: | FileCheck -check-prefix=AUTO_AOT %s
// RUN: | FileCheck -check-prefix=AUTO_AOT %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:large %s 2>&1 \
Expand All @@ -18,19 +18,19 @@

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device 0x0BD5" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=0x0BD5

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device 12.60.7" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=12.60.7

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc,mtl-s" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --no-offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:small,pvc:large %s 2>&1 \
Expand Down Expand Up @@ -88,7 +88,7 @@

// AUTO_AOT: ocloc{{.*}} "-output"
// AUTO_AOT: -device_options
// AUTO_AOT: pvc
// AUTO_AOT: [[DEVICE]]
// AUTO_AOT: "-ze-intel-enable-auto-large-GRF-mode"

// LARGE_AOT: ocloc{{.*}} "-output"
Expand Down
12 changes: 6 additions & 6 deletions clang/test/Driver/sycl-ftarget-register-alloc-mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:auto %s 2>&1 \
// RUN: | FileCheck -check-prefix=AUTO_AOT %s
// RUN: | FileCheck -check-prefix=AUTO_AOT %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:large %s 2>&1 \
Expand All @@ -18,19 +18,19 @@

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device 0x0BD5" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=0x0BD5

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device 12.60.7" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=12.60.7

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc,mtl-s" %s 2>&1 \
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

// RUN: %clang -### -fsycl --offload-new-driver \
// RUN: -fsycl-targets=spir64_gen -ftarget-register-alloc-mode=pvc:small,pvc:large %s 2>&1 \
Expand Down Expand Up @@ -88,7 +88,7 @@
// NO_PVC-NOT: -device_options
// NO_PVC-NOT: -ze-opt-large-register-file

// AUTO_AOT: clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=spir64_gen-unknown-unknown,arch={{.*}},kind=sycl,compile-opts=-device_options pvc -ze-intel-enable-auto-large-GRF-mode{{.*}}"
// AUTO_AOT: clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=spir64_gen-unknown-unknown,arch={{.*}},kind=sycl,compile-opts=-device_options [[DEVICE]] -ze-intel-enable-auto-large-GRF-mode{{.*}}"

// LARGE_AOT: clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=spir64_gen-unknown-unknown,arch=,kind=sycl,compile-opts=-device_options pvc -ze-opt-large-register-file"

Expand Down
Loading