Skip to content

Commit 7a18373

Browse files
sergey-semenovvladimirlaz
authored andcommitted
[SYCL] Add __SYCL_COMPILER_VERSION macro
Signed-off-by: Sergey Semenov <[email protected]> Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent 310b3e2 commit 7a18373

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

sycl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/CL/sycl/version.hpp

sycl/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ find_package(OpenCL REQUIRED)
3434
include_directories(${OpenCL_INCLUDE_DIRS})
3535
link_libraries(OpenCL)
3636

37+
# Configure SYCL version macro
38+
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include/CL)
39+
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
40+
set(version_header "${sycl_inc_dir}/sycl/version.hpp")
41+
configure_file("${version_header}.in" "${version_header}")
42+
3743
# Copy SYCL headers
3844
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include/CL)
3945
set(dst_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include/CL)

sycl/include/CL/sycl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <CL/sycl/queue.hpp>
3636
#include <CL/sycl/range.hpp>
3737
#include <CL/sycl/types.hpp>
38+
#include <CL/sycl/version.hpp>
3839

3940
// Do not include RT only function implementations for device code as it leads
4041
// to problem. Should be finally fixed when we introduce library.

sycl/include/CL/sycl/version.hpp.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//==------ version.hpp --- SYCL compiler version macro ---------*- C++ -*---==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#cmakedefine __SYCL_COMPILER_VERSION ${__SYCL_COMPILER_VERSION}

sycl/test/basic_tests/macros.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang -std=c++11 -g %s -o %t.out -lstdc++ -lOpenCL -lsycl
2+
3+
#include <CL/sycl.hpp>
4+
#include <iostream>
5+
6+
int main() {
7+
std::cout << "SYCL language version: " << CL_SYCL_LANGUAGE_VERSION
8+
<< std::endl;
9+
std::cout << "SYCL compiler version: " << __SYCL_COMPILER_VERSION
10+
<< std::endl;
11+
return 0;
12+
}

0 commit comments

Comments
 (0)