Skip to content

Commit ec268c1

Browse files
Tidying up impl files
1 parent e78c2e2 commit ec268c1

File tree

10 files changed

+158
-170
lines changed

10 files changed

+158
-170
lines changed

sycl/include/sycl/ext/oneapi/experimental/graph.hpp

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@
3030

3131
namespace sycl {
3232
inline namespace _V1 {
33-
3433
class handler;
3534
class queue;
3635
class device;
3736
class node;
37+
38+
namespace detail {
39+
class CG;
40+
} // namespace detail
41+
3842
namespace ext {
3943
namespace oneapi {
4044
namespace experimental {
41-
42-
// Forward declare ext::oneapi::experimental classes
4345
template <graph_state State> class command_graph;
4446
class dynamic_command_group;
4547

4648
namespace detail {
47-
// Forward declare ext::oneapi::experimental::detail classes
4849
class graph_impl;
4950
class exec_graph_impl;
5051

@@ -203,11 +204,23 @@ class __SYCL_EXPORT modifiable_command_graph
203204
/// @param verbose If true, print additional information about the nodes such
204205
/// as kernel args or memory access where applicable.
205206
#ifdef ___INTEL_PREVIEW_BREAKING_CHANGES
206-
inline void print_graph(const std::string path, bool verbose = false) const {
207+
void print_graph(const std::string path, bool verbose = false) const {
207208
print_graph(sycl::detail::string_view{path}, verbose);
208209
}
209210
#else
210-
inline void print_graph(const std::string path, bool verbose = false) const;
211+
#ifdef __SYCL_GRAPH_IMPL_CPP
212+
// Magic combination found by trial and error:
213+
__SYCL_EXPORT
214+
#if _WIN32
215+
inline
216+
#endif
217+
#else
218+
inline
219+
#endif
220+
void
221+
print_graph(const std::string path, bool verbose = false) const {
222+
print_graph(sycl::detail::string_view{path}, verbose);
223+
}
211224
#endif
212225

213226
/// Get a list of all nodes contained in this graph.
@@ -271,13 +284,6 @@ class __SYCL_EXPORT modifiable_command_graph
271284
static void checkNodePropertiesAndThrow(const property_list &Properties);
272285
};
273286

274-
#ifndef ___INTEL_PREVIEW_BREAKING_CHANGES
275-
inline void modifiable_command_graph::print_graph(const std::string path,
276-
bool verbose) const {
277-
print_graph(sycl::detail::string_view{path}, verbose);
278-
}
279-
#endif
280-
281287
// Templateless executable command-graph base class.
282288
class __SYCL_EXPORT executable_command_graph
283289
: public sycl::detail::OwnerLessBase<executable_command_graph> {
@@ -331,6 +337,56 @@ class __SYCL_EXPORT executable_command_graph
331337

332338
std::shared_ptr<detail::exec_graph_impl> impl;
333339
};
340+
341+
class dynamic_command_group_impl
342+
: public std::enable_shared_from_this<dynamic_command_group_impl> {
343+
public:
344+
dynamic_command_group_impl(
345+
const command_graph<graph_state::modifiable> &Graph);
346+
347+
/// Returns the index of the active command-group
348+
size_t getActiveIndex() const { return MActiveCGF; }
349+
350+
/// Returns the number of CGs in the dynamic command-group.
351+
size_t getNumCGs() const { return MCommandGroups.size(); }
352+
353+
/// Set the index of the active command-group.
354+
/// @param Index The new index.
355+
void setActiveIndex(size_t Index);
356+
357+
/// Instantiates a command-group object for each CGF in the list.
358+
/// @param CGFList List of CGFs to finalize with a handler into CG objects.
359+
void
360+
finalizeCGFList(const std::vector<std::function<void(handler &)>> &CGFList);
361+
362+
/// Retrieve CG at the currently active index
363+
/// @param Shared pointer to the active CG object.
364+
std::shared_ptr<sycl::detail::CG> getActiveCG() const {
365+
return MCommandGroups[MActiveCGF];
366+
}
367+
368+
unsigned long long getID() const { return MID; }
369+
370+
/// Type of the CGs in this dynamic command-group
371+
sycl::detail::CGType MCGType = sycl::detail::CGType::None;
372+
373+
/// Graph this dynamic command-group is associated with.
374+
std::shared_ptr<graph_impl> MGraph;
375+
376+
/// Index of active command-group
377+
std::atomic<size_t> MActiveCGF;
378+
379+
/// List of command-groups for dynamic command-group nodes
380+
std::vector<std::shared_ptr<sycl::detail::CG>> MCommandGroups;
381+
382+
/// List of nodes using this dynamic command-group.
383+
std::vector<std::weak_ptr<node_impl>> MNodes;
384+
385+
private:
386+
unsigned long long MID;
387+
// Used for std::hash in order to create a unique hash for the instance.
388+
inline static std::atomic<unsigned long long> NextAvailableID = 0;
389+
};
334390
} // namespace detail
335391

336392
/// Graph in the modifiable state.

sycl/source/detail/graph_dynamic_impl.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@
88

99
#define __SYCL_GRAPH_DYNAMIC_PARAM_IMPL_CPP
1010

11-
#include <detail/graph_dynamic_impl.hpp>
12-
#include <detail/graph_impl.hpp>
13-
#include <detail/handler_impl.hpp>
14-
#include <detail/kernel_arg_mask.hpp>
15-
#include <detail/program_manager/program_manager.hpp>
16-
#include <detail/queue_impl.hpp>
17-
#include <detail/scheduler/commands.hpp>
18-
#include <detail/sycl_mem_obj_t.hpp>
19-
#include <stack>
20-
#include <sycl/detail/common.hpp>
21-
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp> // for checking graph properties
22-
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
23-
#include <sycl/detail/string_view.hpp>
24-
#endif
25-
#include <sycl/feature_test.hpp>
26-
#include <sycl/queue.hpp>
11+
#include "graph_dynamic_impl.hpp"
12+
#include <detail/cg.hpp> // for CG
13+
#include <detail/handler_impl.hpp> // for handler_impl
14+
#include <detail/sycl_mem_obj_t.hpp> // for SYCLMemObjT
15+
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
16+
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp> // for checkGraphPropertiesAndThrow
17+
#include <sycl/ext/oneapi/experimental/graph.hpp> // for command_graph
2718

2819
namespace sycl {
2920
inline namespace _V1 {

sycl/source/detail/graph_dynamic_impl.hpp

Lines changed: 18 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,33 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/cg_types.hpp>
12-
#include <sycl/detail/os_util.hpp>
13-
#include <sycl/ext/oneapi/experimental/graph.hpp>
14-
#include <sycl/ext/oneapi/experimental/raw_kernel_arg.hpp>
15-
16-
#include <detail/accessor_impl.hpp>
17-
#include <detail/cg.hpp>
18-
#include <detail/graph_node_impl.hpp>
19-
#include <detail/host_task.hpp>
20-
#include <detail/kernel_impl.hpp>
21-
#include <detail/sycl_mem_obj_t.hpp>
22-
23-
#include <cstring>
24-
#include <fstream>
25-
#include <functional>
26-
#include <iomanip>
27-
#include <list>
28-
#include <set>
29-
#include <shared_mutex>
30-
#include <vector>
11+
#include <detail/accessor_impl.hpp> // for LocalAccessorImplHost
12+
#include <sycl/detail/cg_types.hpp> // for CGType
13+
#include <sycl/ext/oneapi/experimental/raw_kernel_arg.hpp> // for raw_kernel_arg
14+
15+
#include <cstring> // for memcpy
16+
#include <vector> // for vector
3117

3218
namespace sycl {
3319
inline namespace _V1 {
20+
21+
// Forward declarations
3422
class handler;
3523

24+
namespace detail {
25+
26+
// Forward declarations
27+
class CG;
28+
} // namespace detail
29+
3630
namespace ext {
3731
namespace oneapi {
3832
namespace experimental {
3933
namespace detail {
4034

41-
class dynamic_command_group_impl
42-
: public std::enable_shared_from_this<dynamic_command_group_impl> {
43-
public:
44-
dynamic_command_group_impl(
45-
const command_graph<graph_state::modifiable> &Graph);
46-
47-
/// Returns the index of the active command-group
48-
size_t getActiveIndex() const { return MActiveCGF; }
49-
50-
/// Returns the number of CGs in the dynamic command-group.
51-
size_t getNumCGs() const { return MCommandGroups.size(); }
52-
53-
/// Set the index of the active command-group.
54-
/// @param Index The new index.
55-
void setActiveIndex(size_t Index);
56-
57-
/// Instantiates a command-group object for each CGF in the list.
58-
/// @param CGFList List of CGFs to finalize with a handler into CG objects.
59-
void
60-
finalizeCGFList(const std::vector<std::function<void(handler &)>> &CGFList);
61-
62-
/// Retrieve CG at the currently active index
63-
/// @param Shared pointer to the active CG object.
64-
std::shared_ptr<sycl::detail::CG> getActiveCG() const {
65-
return MCommandGroups[MActiveCGF];
66-
}
67-
68-
unsigned long long getID() const { return MID; }
69-
70-
/// Type of the CGs in this dynamic command-group
71-
sycl::detail::CGType MCGType = sycl::detail::CGType::None;
72-
73-
/// Graph this dynamic command-group is associated with.
74-
std::shared_ptr<graph_impl> MGraph;
75-
76-
/// Index of active command-group
77-
std::atomic<size_t> MActiveCGF;
78-
79-
/// List of command-groups for dynamic command-group nodes
80-
std::vector<std::shared_ptr<sycl::detail::CG>> MCommandGroups;
81-
82-
/// List of nodes using this dynamic command-group.
83-
std::vector<std::weak_ptr<node_impl>> MNodes;
84-
85-
private:
86-
unsigned long long MID;
87-
// Used for std::hash in order to create a unique hash for the instance.
88-
inline static std::atomic<unsigned long long> NextAvailableID = 0;
89-
};
35+
// Forward declarations
36+
class node_impl;
37+
class dynamic_command_group_impl;
9038

9139
class dynamic_parameter_impl {
9240
public:
@@ -234,7 +182,7 @@ class dynamic_local_accessor_impl : public dynamic_parameter_impl {
234182
void updateCGLocalAccessor(std::shared_ptr<sycl::detail::CG> &CG,
235183
int ArgIndex, range<3> NewAllocationSize);
236184

237-
detail::LocalAccessorImplHost LAccImplHost;
185+
sycl::detail::LocalAccessorImplHost LAccImplHost;
238186
};
239187

240188
} // namespace detail

sycl/source/detail/graph_impl.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//==--------- graph_impl.cpp - SYCL graph extension -----------------------==//
1+
//==--------- graph_impl.cpp - SYCL graph extension ------------------------==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,22 +8,26 @@
88

99
#define __SYCL_GRAPH_IMPL_CPP
1010

11-
#include <detail/graph_impl.hpp>
12-
#include <detail/graph_node_impl.hpp>
13-
#include <detail/handler_impl.hpp>
14-
#include <detail/kernel_arg_mask.hpp>
15-
#include <detail/program_manager/program_manager.hpp>
16-
#include <detail/queue_impl.hpp>
17-
#include <detail/scheduler/commands.hpp>
18-
#include <detail/sycl_mem_obj_t.hpp>
19-
#include <stack>
20-
#include <sycl/detail/common.hpp>
11+
#include "graph_impl.hpp"
12+
#include <detail/cg.hpp> // for CG, CGExecKernel, CGHostTask, ArgDesc, NDRDescT
13+
#include <detail/event_impl.hpp> // for event_impl
14+
#include <detail/graph_dynamic_impl.hpp> // for dynamic classes
15+
#include <detail/graph_node_impl.hpp> // for node_impl
16+
#include <detail/handler_impl.hpp> // for handler_impl
17+
#include <detail/kernel_arg_mask.hpp> // for KernelArgMask
18+
#include <detail/kernel_impl.hpp> // for kernel_impl
19+
#include <detail/program_manager/program_manager.hpp> // ProgramManager
20+
#include <detail/queue_impl.hpp> // for queue_impl
21+
#include <detail/sycl_mem_obj_t.hpp> // for SYCLMemObjT
22+
#include <stack> // for stack
23+
#include <sycl/detail/common.hpp> // for tls_code_loc_t etc..
24+
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
2125
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp> // for checking graph properties
2226
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
23-
#include <sycl/detail/string_view.hpp>
27+
#include <sycl/detail/string_view.hpp> // for string_view
2428
#endif
25-
#include <sycl/feature_test.hpp>
26-
#include <sycl/queue.hpp>
29+
#include <sycl/feature_test.hpp> // for testing
30+
#include <sycl/queue.hpp> // for queue
2731

2832
namespace sycl {
2933
inline namespace _V1 {

sycl/source/detail/graph_impl.hpp

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,49 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/cg_types.hpp>
12-
#include <sycl/detail/os_util.hpp>
13-
#include <sycl/ext/oneapi/experimental/graph.hpp>
14-
15-
#include <detail/cg.hpp>
16-
#include <detail/event_impl.hpp>
17-
#include <detail/graph_dynamic_impl.hpp>
18-
#include <detail/graph_memory_pool.hpp>
19-
#include <detail/graph_node_impl.hpp>
20-
#include <detail/host_task.hpp>
21-
#include <detail/kernel_impl.hpp>
22-
#include <detail/sycl_mem_obj_t.hpp>
23-
24-
#include <cstring>
25-
#include <fstream>
26-
#include <functional>
27-
#include <iomanip>
28-
#include <list>
29-
#include <set>
30-
#include <shared_mutex>
31-
#include <vector>
11+
#include <sycl/detail/cg_types.hpp> // for CGType
12+
#include <sycl/detail/os_util.hpp> // for OS utils
13+
14+
#include <detail/event_impl.hpp> // for event_impl
15+
#include <detail/graph_memory_pool.hpp> // for graph_mem_pool
16+
#include <detail/graph_node_impl.hpp> // for node_impl
17+
18+
#include <fstream> // for fstream
19+
#include <functional> // for function
20+
#include <list> // for list
21+
#include <memory> // for shared_ptr
22+
#include <set> // for set
23+
#include <shared_mutex> // for shared_mutex
24+
#include <vector> // for vector
3225

3326
namespace sycl {
3427
inline namespace _V1 {
28+
29+
// Forward declarations
3530
class handler;
3631

3732
namespace detail {
33+
34+
// Forward declarations
3835
class SYCLMemObjT;
3936
class queue_impl;
37+
class NDRDescT;
38+
class ArgDesc;
39+
class CG;
4040
} // namespace detail
4141

4242
namespace ext {
4343
namespace oneapi {
4444
namespace experimental {
45+
46+
// Forward declarations
47+
template <graph_state State> class command_graph;
48+
4549
namespace detail {
4650

51+
// Forward declarations
52+
class dynamic_command_group_impl;
53+
4754
class partition {
4855
public:
4956
/// Constructor.
@@ -858,7 +865,6 @@ class exec_graph_impl {
858865
// handling for them during update().
859866
bool MContainsHostTask = false;
860867
};
861-
862868
} // namespace detail
863869
} // namespace experimental
864870
} // namespace oneapi

sycl/source/detail/graph_memory_pool.cpp

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

1616
namespace sycl {
1717
inline namespace _V1 {
18+
1819
namespace ext {
1920
namespace oneapi {
2021
namespace experimental {

0 commit comments

Comments
 (0)