-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Improve SYCL library versioning macro
We have a macro `__SYCL_COMPILER_VERSION` which only corresponds to a date when build was performed - it does not give any indication of the actual compiler version, nor does it give any indication of the actual library build. This patch attempts to deprecate that old macro and replaces it with `__LIBSYCL_TIMESTAMP` which contains a date of the latest commit included into the SYCL library (and therefore SYCL headers) build. Using commit date is more relibable than build date and its naming speicifally refers to library instead of the compiler. "Attempts" above is because it is a bit tricky to deprecate a macro and heavily depends on the compiler which is being used. Not every 3rd-party host compiler is covered, i.e. deprecation message may only be emitted from device compilation pass in certain cases. Resolves #2250
- Loading branch information
1 parent
023cb2b
commit 3fd1c07
Showing
7 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
# Grab the date of the latest commit | ||
execute_process( | ||
COMMAND git log -1 --format=%as # date in YYYY-MM-DD mode | ||
WORKING_DIRECTORY ${SYCL_ROOT_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_COMMIT_DATE_TEMP | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
string(REPLACE "-" "" __LIBSYCL_TIMESTAMP ${GIT_COMMIT_DATE_TEMP}) | ||
|
||
# Legacy thing for backwards compatibility. Use of the current date is not | ||
# reliable, because we can always make new build from older commits. | ||
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d") | ||
configure_file("${sycl_src_dir}/version.hpp.in" "${SYCL_INCLUDE_BUILD_DIR}/sycl/version.hpp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
//==------ version.hpp --- SYCL compiler version macro ---------*- C++ -*---==// | ||
//==------- version.hpp --- SYCL library version macro ---------*- C++ -*---==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// __SYCL_COMPILER_VERSION is a legacy macro which does not represent a compiler | ||
// version, but instead only conveys a date when sycl library was built. | ||
|
||
#if /* defined(__GNUC__) || */ defined(__clang__) | ||
// clang supports GCC-style pragma messages, but GCC does not! | ||
// include/sycl/version.hpp error: missing binary operator before token "(" | ||
// 14 | #define __SYCL_COMPILER_VERSION _Pragma("GCC warning \"..\"") 20241120 | ||
|
||
#cmakedefine __SYCL_COMPILER_VERSION _Pragma( \ | ||
"GCC warning \"__SYCL_COMPILER_VERSION is deprecated, " \ | ||
"use __LIBSYCL_TIMESTAMP instead\"") ${__SYCL_COMPILER_VERSION} | ||
#elif defined(_MSC_VER) | ||
#cmakedefine __SYCL_COMPILER_VERSION ${__SYCL_COMPILER_VERSION} | ||
// It seems like MSVC ignores that pragma if its embedded into a macro | ||
// definition, so we have it on a standalone line | ||
_Pragma("deprecated(\"__SYCL_COMPILER_VERSION\")") | ||
#else | ||
// As a fallback, we still define the macro, but without a deprecation warning. | ||
// This path is only expected to be taken when 3rd-party host compiler is used | ||
// and that is not clang/msvc | ||
#cmakedefine __SYCL_COMPILER_VERSION ${__SYCL_COMPILER_VERSION} | ||
#endif | ||
|
||
#cmakedefine __LIBSYCL_TIMESTAMP ${__LIBSYCL_TIMESTAMP} | ||
|
||
#define __LIBSYCL_MAJOR_VERSION ${SYCL_MAJOR_VERSION} | ||
#define __LIBSYCL_MINOR_VERSION ${SYCL_MINOR_VERSION} | ||
#define __LIBSYCL_PATCH_VERSION ${SYCL_PATCH_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=cl %s \ | ||
// RUN: -fsycl-host-compiler-options="/std:c++17 /Zc:__cplusplus" -c \ | ||
// RUN: -o %t.out | FileCheck %s | ||
// REQUIRES: windows | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
// CHECK: '__SYCL_COMPILER_VERSION': name was marked as #pragma deprecated | ||
#if __SYCL_COMPILER_VERSION >= 2024 | ||
|
||
#endif | ||
|
||
int main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %clangxx -fsycl %s -fsyntax-only -Xclang -verify | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
// expected-warning@+1 {{__SYCL_COMPILER_VERSION is deprecated, use __LIBSYCL_TIMESTAMP instead}} | ||
#if __SYCL_COMPILER_VERSION >= 2024 | ||
|
||
#endif | ||
|
||
int main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ %s -c %t.out | FileCheck %s | ||
// XFAIL: * | ||
// XFAIL-TRACKER: TBD | ||
// REQUIRES: linux | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
// CHECK: __SYCL_COMPILER_VERSION is deprecated, use __LIBSYCL_TIMESTAMP instead | ||
#if __SYCL_COMPILER_VERSION >= 2024 | ||
|
||
#endif | ||
|
||
int main() {} |