Skip to content

Commit 70cde37

Browse files
[SYCL][NFC] Move some detail:: functions into library (#15475)
1 parent 277458e commit 70cde37

File tree

10 files changed

+78
-46
lines changed

10 files changed

+78
-46
lines changed

sycl/include/sycl/detail/helpers.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ template <typename Type, std::size_t NumElements> class marray;
3838
enum class memory_order;
3939

4040
namespace detail {
41-
class CGExecKernel;
4241
class buffer_impl;
43-
class context_impl;
44-
class queue_impl;
45-
using QueueImplPtr = std::shared_ptr<sycl::detail::queue_impl>;
46-
class RTDeviceBinaryImage;
4742

43+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
4844
__SYCL_EXPORT void waitEvents(std::vector<sycl::event> DepEvents);
45+
#endif
4946

5047
__SYCL_EXPORT void
5148
markBufferAsInternal(const std::shared_ptr<buffer_impl> &BufImpl);
@@ -251,10 +248,6 @@ template <size_t count, class F> void loop(F &&f) {
251248
loop_impl(std::make_index_sequence<count>{}, std::forward<F>(f));
252249
}
253250
inline constexpr bool is_power_of_two(int x) { return (x & (x - 1)) == 0; }
254-
255-
std::tuple<const RTDeviceBinaryImage *, ur_program_handle_t>
256-
retrieveKernelBinary(const QueueImplPtr &, const char *KernelName,
257-
CGExecKernel *CGKernel = nullptr);
258251
} // namespace detail
259252

260253
} // namespace _V1

sycl/include/sycl/memory_enums.hpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#pragma once
1010

11-
#include <ur_api.h> // for ur_memory_order_capability_flags_t
12-
1311
#include <atomic> // for memory_order
1412
#include <vector> // for vector
1513

@@ -48,38 +46,6 @@ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
4846

4947
namespace detail {
5048

51-
inline std::vector<memory_order>
52-
readMemoryOrderBitfield(ur_memory_order_capability_flags_t bits) {
53-
std::vector<memory_order> result;
54-
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED)
55-
result.push_back(memory_order::relaxed);
56-
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE)
57-
result.push_back(memory_order::acquire);
58-
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE)
59-
result.push_back(memory_order::release);
60-
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL)
61-
result.push_back(memory_order::acq_rel);
62-
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST)
63-
result.push_back(memory_order::seq_cst);
64-
return result;
65-
}
66-
67-
inline std::vector<memory_scope>
68-
readMemoryScopeBitfield(ur_memory_scope_capability_flags_t bits) {
69-
std::vector<memory_scope> result;
70-
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM)
71-
result.push_back(memory_scope::work_item);
72-
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP)
73-
result.push_back(memory_scope::sub_group);
74-
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP)
75-
result.push_back(memory_scope::work_group);
76-
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE)
77-
result.push_back(memory_scope::device);
78-
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM)
79-
result.push_back(memory_scope::system);
80-
return result;
81-
}
82-
8349
#ifndef __SYCL_DEVICE_ONLY__
8450
static constexpr std::memory_order getStdMemoryOrder(sycl::memory_order order) {
8551
switch (order) {

sycl/source/detail/device_info.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sycl/info/info_desc.hpp>
2424
#include <sycl/memory_enums.hpp>
2525
#include <sycl/platform.hpp>
26+
#include <ur_api.h> // for ur_memory_order_capability_flags_t
2627

2728
#include <chrono>
2829
#include <sstream>
@@ -34,6 +35,38 @@ namespace sycl {
3435
inline namespace _V1 {
3536
namespace detail {
3637

38+
inline std::vector<memory_order>
39+
readMemoryOrderBitfield(ur_memory_order_capability_flags_t bits) {
40+
std::vector<memory_order> result;
41+
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED)
42+
result.push_back(memory_order::relaxed);
43+
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE)
44+
result.push_back(memory_order::acquire);
45+
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE)
46+
result.push_back(memory_order::release);
47+
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL)
48+
result.push_back(memory_order::acq_rel);
49+
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST)
50+
result.push_back(memory_order::seq_cst);
51+
return result;
52+
}
53+
54+
inline std::vector<memory_scope>
55+
readMemoryScopeBitfield(ur_memory_scope_capability_flags_t bits) {
56+
std::vector<memory_scope> result;
57+
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM)
58+
result.push_back(memory_scope::work_item);
59+
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP)
60+
result.push_back(memory_scope::sub_group);
61+
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP)
62+
result.push_back(memory_scope::work_group);
63+
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE)
64+
result.push_back(memory_scope::device);
65+
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM)
66+
result.push_back(memory_scope::system);
67+
return result;
68+
}
69+
3770
inline std::vector<info::fp_config>
3871
read_fp_bitfield(ur_device_fp_capability_flags_t bits) {
3972
std::vector<info::fp_config> result;

sycl/source/detail/helpers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <detail/helpers.hpp>
10+
911
#include <detail/scheduler/commands.hpp>
1012
#include <sycl/detail/helpers.hpp>
1113

@@ -30,7 +32,8 @@ void waitEvents(std::vector<sycl::event> DepEvents) {
3032
}
3133
}
3234

33-
void markBufferAsInternal(const std::shared_ptr<buffer_impl> &BufImpl) {
35+
__SYCL_EXPORT void
36+
markBufferAsInternal(const std::shared_ptr<buffer_impl> &BufImpl) {
3437
BufImpl->markAsInternal();
3538
}
3639

sycl/source/detail/helpers.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//==---------------- helpers.cpp - SYCL helpers ---------------------------==//
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+
#include <ur_api.h>
10+
11+
#include <memory>
12+
#include <tuple>
13+
#include <vector>
14+
15+
namespace sycl {
16+
inline namespace _V1 {
17+
class event;
18+
19+
namespace detail {
20+
class CGExecKernel;
21+
class queue_impl;
22+
using QueueImplPtr = std::shared_ptr<sycl::detail::queue_impl>;
23+
class RTDeviceBinaryImage;
24+
25+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
26+
void waitEvents(std::vector<sycl::event> DepEvents);
27+
#endif
28+
29+
std::tuple<const RTDeviceBinaryImage *, ur_program_handle_t>
30+
retrieveKernelBinary(const QueueImplPtr &, const char *KernelName,
31+
CGExecKernel *CGKernel = nullptr);
32+
} // namespace detail
33+
} // namespace _V1
34+
} // namespace sycl

sycl/source/detail/jit_compiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#if SYCL_EXT_JIT_ENABLE
1010
#include <KernelFusion.h>
1111
#include <detail/device_image_impl.hpp>
12+
#include <detail/helpers.hpp>
1213
#include <detail/jit_compiler.hpp>
1314
#include <detail/kernel_bundle_impl.hpp>
1415
#include <detail/kernel_impl.hpp>

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <detail/context_impl.hpp>
1212
#include <detail/event_impl.hpp>
13+
#include <detail/helpers.hpp>
1314
#include <detail/host_pipe_map_entry.hpp>
1415
#include <detail/kernel_bundle_impl.hpp>
1516
#include <detail/kernel_impl.hpp>

sycl/source/handler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <detail/global_handler.hpp>
1515
#include <detail/graph_impl.hpp>
1616
#include <detail/handler_impl.hpp>
17+
#include <detail/helpers.hpp>
1718
#include <detail/host_task.hpp>
1819
#include <detail/image_impl.hpp>
1920
#include <detail/kernel_bundle_impl.hpp>

sycl/test/include_deps/sycl_accessor.hpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// CHECK-NEXT: atomic.hpp
1515
// CHECK-NEXT: detail/helpers.hpp
1616
// CHECK-NEXT: memory_enums.hpp
17-
// CHECK-NEXT: ur_api.h
1817
// CHECK-NEXT: CL/__spirv/spirv_vars.hpp
1918
// CHECK-NEXT: multi_ptr.hpp
2019
// CHECK-NEXT: aliases.hpp
@@ -66,6 +65,7 @@
6665
// CHECK-NEXT: CL/cl_platform.h
6766
// CHECK-NEXT: CL/cl_ext.h
6867
// CHECK-NEXT: detail/string.hpp
68+
// CHECK-NEXT: ur_api.h
6969
// CHECK-NEXT: detail/common.hpp
7070
// CHECK-NEXT: detail/is_device_copyable.hpp
7171
// CHECK-NEXT: detail/owner_less_base.hpp

sycl/test/include_deps/sycl_detail_core.hpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// CHECK-NEXT: atomic.hpp
1616
// CHECK-NEXT: detail/helpers.hpp
1717
// CHECK-NEXT: memory_enums.hpp
18-
// CHECK-NEXT: ur_api.h
1918
// CHECK-NEXT: CL/__spirv/spirv_vars.hpp
2019
// CHECK-NEXT: multi_ptr.hpp
2120
// CHECK-NEXT: aliases.hpp
@@ -67,6 +66,7 @@
6766
// CHECK-NEXT: CL/cl_platform.h
6867
// CHECK-NEXT: CL/cl_ext.h
6968
// CHECK-NEXT: detail/string.hpp
69+
// CHECK-NEXT: ur_api.h
7070
// CHECK-NEXT: detail/common.hpp
7171
// CHECK-NEXT: detail/is_device_copyable.hpp
7272
// CHECK-NEXT: detail/owner_less_base.hpp

0 commit comments

Comments
 (0)