Skip to content

Commit

Permalink
[SYCL] Disallow selecting SYCL 1.2.1 through sycl-std (#14544)
Browse files Browse the repository at this point in the history
As a continuation of #14261 this PR makes impossible to call clang with
-sycl-std=2017 option as well as with 121, 1.2.1, sycl-1.2.1 values. It
also removes some tests which are available only with support of
2017/121

Some of the SYCL 1.2.1-specific functionality (like attributes propagation,
for example) is still in the codebase, but it will be removed in upcoming
patches.
  • Loading branch information
AndreiZibrov authored Jul 15, 2024
1 parent c98fc7c commit c0c4d02
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 193 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -8461,7 +8461,7 @@ def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>,
Flags<[NoArgumentUnused]>,
Visibility<[ClangOption, CC1Option, CLOption]>,
HelpText<"SYCL language standard to compile for.">,
Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
Values<"2020">,
ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>;

def fsycl_default_sub_group_size
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ std::string getClangFullCPPVersion() {

llvm::SmallVector<std::pair<llvm::StringRef, llvm::StringRef>, 2>
getSYCLVersionMacros(const LangOptions &LangOpts) {
if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017)
return {{"CL_SYCL_LANGUAGE_VERSION", "121"},
{"SYCL_LANGUAGE_VERSION", "201707"}};
if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2020)
return {{"SYCL_LANGUAGE_VERSION", "202001"}};
llvm_unreachable("SYCL standard should be set");
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5509,13 +5509,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-D__INTEL_PREVIEW_BREAKING_CHANGES");

if (SYCLStdArg) {
// Use of -sycl-std=1.2.1 is deprecated. Emit a diagnostic stating so.
// TODO: remove support at next approprate major release.
StringRef StdValue(SYCLStdArg->getValue());
if (StdValue == "1.2.1" || StdValue == "121" ||
StdValue == "sycl-1.2.1" || StdValue == "2017")
D.Diag(diag::warn_drv_deprecated_argument_option_release)
<< StdValue << SYCLStdArg->getSpelling();
SYCLStdArg->render(Args, CmdArgs);
CmdArgs.push_back("-fsycl-std-layout-kernel-params");
} else {
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3805,9 +3805,6 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,

if (Opts.isSYCL()) {
switch (Opts.SYCLVersion) {
case LangOptions::SYCL_2017:
GenerateArg(Consumer, OPT_sycl_std_EQ, "2017");
break;
case LangOptions::SYCL_2020:
GenerateArg(Consumer, OPT_sycl_std_EQ, "2020");
break;
Expand Down Expand Up @@ -4013,8 +4010,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.setSYCLVersion(
llvm::StringSwitch<LangOptions::SYCLMajorVersion>(A->getValue())
.Case("2020", LangOptions::SYCL_2020)
.Cases("2017", "121", "1.2.1", "sycl-1.2.1",
LangOptions::SYCL_2017)
.Default(LangOptions::SYCL_None));

if (Opts.SYCLVersion == LangOptions::SYCL_None)
Expand Down
14 changes: 0 additions & 14 deletions clang/test/Driver/sycl-deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,3 @@
// RUN: %clangxx -fsycl -fsycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-use-bitcode
// RUN: %clangxx -fsycl -fno-sycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-use-bitcode
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release

// RUN: %clangxx -fsycl -sycl-std=1.2.1 %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ARG -DOPTION=-sycl-std= \
// RUN: -DARGUMENT=1.2.1
// RUN: %clangxx -fsycl -sycl-std=121 %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ARG -DOPTION=-sycl-std= \
// RUN: -DARGUMENT=121
// RUN: %clangxx -fsycl -sycl-std=sycl-1.2.1 %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ARG -DOPTION=-sycl-std= \
// RUN: -DARGUMENT=sycl-1.2.1
// RUN: %clangxx -fsycl -sycl-std=2017 %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CHECK-ARG -DOPTION=-sycl-std= \
// RUN: -DARGUMENT=2017
// CHECK-ARG: argument '[[ARGUMENT]]' for option '[[OPTION]]' is deprecated and will be removed in a future release
3 changes: 1 addition & 2 deletions clang/test/Preprocessor/sycl-macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL-ID %s
// RUN: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-host -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-2020 %s
// RUN: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-2020 %s
// RUN: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-DEVICE %s
// RUN: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD-DEVICE %s
// RUNx: %clang_cc1 %s -fsycl-id-queries-fit-in-int -fsycl-is-device -E -dM -fms-compatibility | FileCheck --check-prefix=CHECK-MSVC %s
// RUN: %clang_cc1 -fno-sycl-id-queries-fit-in-int %s -E -dM | FileCheck \
// RUN: --check-prefix=CHECK-NO-SYCL_FIT_IN_INT %s
Expand All @@ -13,7 +13,6 @@

// CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
// CHECK-NOT:#define SYCL_EXTERNAL
// CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
// CHECK-NOT:#define __SYCL_ID_QUERIES_FIT_IN_INT__ 1

// CHECK-SYCL-STD:#define SYCL_LANGUAGE_VERSION 202001
Expand Down
82 changes: 0 additions & 82 deletions clang/unittests/Frontend/CompilerInvocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,23 +599,6 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) {
ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std="))));
}

TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) {
const char *Args[] = {"-sycl-std=2017"};

CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-device"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std="))));
}

TEST_F(CommandLineTest, ConditionalParsingIfNonsenseSyclStdArg) {
const char *Args[] = {"-fsycl-is-device", "-sycl-std=garbage"};

Expand All @@ -633,57 +616,6 @@ TEST_F(CommandLineTest, ConditionalParsingIfNonsenseSyclStdArg) {
ASSERT_THAT(GeneratedArgs, Not(Contains(HasSubstr("-sycl-std="))));
}

TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg1) {
const char *Args[] = {"-fsycl-is-device", "-sycl-std=121"};

CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
}

TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg2) {
const char *Args[] = {"-fsycl-is-device", "-sycl-std=1.2.1"};

CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
}

TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg3) {
const char *Args[] = {"-fsycl-is-device", "-sycl-std=sycl-1.2.1"};

CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fsycl-is-host"))));
ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=2017")));
}

TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentHost) {
const char *Args[] = {"-fsycl-is-host"};

Expand Down Expand Up @@ -714,20 +646,6 @@ TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentDevice) {
ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=")));
}

TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagPresent) {
const char *Args[] = {"-fsycl-is-device", "-sycl-std=2017"};

CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fsycl-is-device")));
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-sycl-std=2017")));
}

// Wide integer option.

TEST_F(CommandLineTest, WideIntegerHighValue) {
Expand Down
7 changes: 3 additions & 4 deletions sycl/doc/UsersManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ and not recommended to use in production environment.

**`-sycl-std=<value>`** [EXPERIMENTAL]

SYCL language standard to compile for. Possible values:
* 121 - SYCL 1.2.1 [DEPRECATED]
* 2020 - SYCL 2020
SYCL language standard to compile for. Currently the possible value is:
* 2020 - for SYCL 2020
It doesn't guarantee specific standard compliance, but some selected
compiler features change behavior.
It is under development and not recommended to use in production
Expand All @@ -148,7 +147,7 @@ and not recommended to use in production environment.

Enables/Disables unnamed SYCL lambda kernels support.
The default value depends on the SYCL language standard: it is enabled
by default for SYCL 2020, and disabled for SYCL 1.2.1.
by default for SYCL 2020.

**`-f[no-]sycl-explicit-simd`** [DEPRECATED]

Expand Down
2 changes: 1 addition & 1 deletion sycl/doc/design/CompilerAndRuntimeDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ assumed, and single device compiler for this target is invoked.

The option `-sycl-std` allows specifying which version of
the SYCL standard will be used for the compilation.
The default value for this option is `1.2.1`.
The default value for this option is `2020`.

#### Ahead of time (AOT) compilation

Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Basic/parallel_for_disable_range_roundup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

// RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t.out | FileCheck %s --check-prefix CHECK-DISABLED

// RUN: %{build} -sycl-std=2017 -o %t.out
// RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t.out | FileCheck %s --check-prefix CHECK-DISABLED

// RUN: %{build} -sycl-std=2020 -o %t.out
// RUN: env SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE=1 %{run} %t.out | FileCheck %s --check-prefix CHECK-ENABLED

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Sampler/basic-rw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Use it as a base file for testing any condition.
clang++ -fsycl -sycl-std=121 -o binx.bin basic-rw.cpp
clang++ -fsycl -o binx.bin basic-rw.cpp
ONEAPI_DEVICE_SELECTOR=opencl:gpu ./binx.bin
ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./binx.bin
Expand Down
69 changes: 0 additions & 69 deletions sycl/test/basic_tests/aliases-legacy.cpp

This file was deleted.

1 change: 0 additions & 1 deletion sycl/test/regression/unnamed-lambda.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: %clangxx -fsycl -fsyntax-only %s
// RUN: %clangxx -fsycl -sycl-std=1.2.1 -fsyntax-only %s

#include "sycl.hpp"

Expand Down

0 comments on commit c0c4d02

Please sign in to comment.