Skip to content

Commit 3b0defe

Browse files
v-klochkovbader
authored andcommitted
[SYCL] Add Windows support for device_info
Fixed few warnings caused by inconsistent usage of class and struct keywords. Added a macro to expose global symbols and generate sycl.lib on Windows. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent ed668e0 commit 3b0defe

File tree

13 files changed

+232
-115
lines changed

13 files changed

+232
-115
lines changed

sycl/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project(sycl-solution)
55
set(CMAKE_CXX_STANDARD 11)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
set(CMAKE_CXX_EXTENSIONS OFF)
8+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
89

910
if(MSVC)
1011
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -135,6 +136,7 @@ add_library("${SYCLLibrary}" SHARED
135136
"${sourceRootPath}/detail/program_manager/program_manager.cpp"
136137
"${sourceRootPath}/detail/queue_impl.cpp"
137138
"${sourceRootPath}/detail/os_util.cpp"
139+
"${sourceRootPath}/detail/platform_util.cpp"
138140
"${sourceRootPath}/detail/sampler_impl.cpp"
139141
"${sourceRootPath}/detail/scheduler/commands.cpp"
140142
"${sourceRootPath}/detail/scheduler/commands2.cpp"

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class accessor;
4242
template <typename T, int dimensions, typename AllocatorT> class buffer;
4343
class handler;
4444
class queue;
45-
template <int dimentions> class id;
45+
template <int dimentions> struct id;
4646
template <int dimentions> class range;
4747
using buffer_allocator = aligned_allocator<char, /*alignment*/ 64>;
4848
namespace detail {

sycl/include/CL/sycl/detail/helpers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace cl {
1919
namespace sycl {
2020
class context;
2121
class event;
22-
template <int dimensions, bool with_offset> class item;
22+
template <int dimensions, bool with_offset> struct item;
2323
template <int dimensions> class group;
2424
template <int dimensions> class range;
25-
template <int dimensions> class id;
25+
template <int dimensions> struct id;
2626
template <int dimensions> class nd_item;
2727
namespace detail {
2828
class context_impl;

sycl/include/CL/sycl/detail/os_util.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#pragma once
1212

13+
#include <stdlib.h>
14+
1315
#ifdef _WIN32
1416
#define SYCL_RT_OS_WINDOWS
1517
// Windows platform
@@ -48,6 +50,9 @@ class OSUtil {
4850
/// Module handle for the executable module - it is assumed there is always
4951
/// single one at most.
5052
static const OSModuleHandle ExeModuleHandle;
53+
54+
/// Returns the amount of RAM available for the operating system.
55+
static size_t getOSMemSize();
5156
};
5257

5358
} // namespace detail
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===-- platform_util.hpp - platform utilities ----------------*- 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+
#pragma once
10+
11+
#include <cstdint>
12+
13+
namespace cl {
14+
namespace sycl {
15+
namespace detail {
16+
17+
struct PlatformUtil {
18+
enum class TypeIndex : unsigned int {
19+
Char = 0,
20+
Short = 1,
21+
Int = 2,
22+
Long = 3,
23+
Float = 4,
24+
Double = 5,
25+
Half = 6
26+
};
27+
28+
/// Returns the maximum vector width counted in elements of the given type.
29+
static uint32_t getNativeVectorWidth(TypeIndex Index);
30+
31+
static uint32_t getMaxClockFrequency();
32+
33+
static uint32_t getMemCacheLineSize();
34+
35+
static uint64_t getMemCacheSize();
36+
};
37+
38+
} // namespace detail
39+
} // namespace sycl
40+
} // namespace cl

sycl/include/CL/sycl/group.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace cl {
2020
namespace sycl {
2121
namespace detail {
22-
class Builder;
22+
struct Builder;
2323
} // namespace detail
2424

2525
template <int dimensions = 1> class group {

sycl/include/CL/sycl/id.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ namespace cl {
1616
namespace sycl {
1717
template <int dimensions> class range;
1818
template <int dimensions = 1> struct id : public detail::array<dimensions> {
19-
public:
19+
private:
2020
using base = detail::array<dimensions>;
21+
public:
2122
id() = default;
2223

2324
/* The following constructor is only available in the id struct

sycl/include/CL/sycl/item.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
namespace cl {
1717
namespace sycl {
1818
namespace detail {
19-
class Builder;
19+
struct Builder;
2020
}
2121
template <int dimensions> struct id;
22-
template <int dimensions> struct range;
22+
template <int dimensions> class range;
2323
template <int dimensions = 1, bool with_offset = true> struct item {
2424

2525
item() = delete;
@@ -86,8 +86,9 @@ template <int dimensions = 1, bool with_offset = true> struct item {
8686

8787
protected:
8888
// For call constructor inside conversion operator
89-
friend class item<dimensions, false>;
90-
friend class detail::Builder;
89+
friend struct item<dimensions, false>;
90+
friend struct item<dimensions, true>;
91+
friend struct detail::Builder;
9192

9293
template <size_t W = with_offset>
9394
item(typename std::enable_if<(W == true), const range<dimensions>>::type &R,

sycl/include/CL/sycl/nd_item.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace cl {
2323
namespace sycl {
2424
namespace detail {
25-
class Builder;
25+
struct Builder;
2626
}
2727
template <int dimensions = 1> struct nd_item {
2828

sycl/include/CL/sycl/range.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace sycl {
1616
template <int dimensions> struct id;
1717
template <int dimensions = 1>
1818
class range : public detail::array<dimensions> {
19-
public:
2019
using base = detail::array<dimensions>;
20+
public:
2121
/* The following constructor is only available in the range class
2222
specialization where: dimensions==1 */
2323
template <int N = dimensions>

0 commit comments

Comments
 (0)