forked from llnl/camp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamp-adaptivecpp.patch
More file actions
106 lines (101 loc) · 4.56 KB
/
Copy pathcamp-adaptivecpp.patch
File metadata and controls
106 lines (101 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff --git a/include/camp/resource/sycl.hpp b/include/camp/resource/sycl.hpp
index 6f32a0f..808d5c3 100644
--- a/include/camp/resource/sycl.hpp
+++ b/include/camp/resource/sycl.hpp
@@ -57,7 +57,12 @@ namespace resources
if (!qu.is_in_order()) {
::camp::throw_re("Queue is not in_order.");
}
- m_event = qu.submit([&](::sycl::handler& CAMP_UNUSED_ARG(h)) {});
+ // The command group needs a real operation in it: AdaptiveCpp
+ // rejects an empty one ("Command queue evaluation did not result in
+ // the creation of events") rather than handing back an event. The
+ // queue is in_order, so an empty task still marks this point in it.
+ m_event = qu.submit(
+ [&](::sycl::handler& h) { h.single_task([]() {}); });
}
SyclEvent(SyclEvent const&) = delete;
@@ -200,7 +205,13 @@ namespace resources
using value_second_type =
std::pair<int, std::array<sycl::queue, num_queues>>;
using queueMap_type = std::map<const sycl::context*, value_second_type>;
- static queueMap_type queueMap;
+ // Intentionally immortal: the queues held here must outlive every
+ // other static object. Destroying a sycl::queue calls back into the
+ // SYCL runtime, and with AdaptiveCpp that runtime is itself torn down
+ // by a static destructor, so a normal function-local static races it
+ // at exit and segfaults in allocation_tracker::unregister_allocation.
+ // Leaking the map keeps destruction order out of the picture.
+ static queueMap_type& queueMap = *new queueMap_type();
static const typename queueMap_type::iterator queueMap_end =
queueMap.end();
thread_local typename queueMap_type::iterator cachedContextIter =
@@ -222,7 +233,7 @@ namespace resources
if (cachedContextIter == queueMap_end) {
cachedContextIter = queueMap.find(syclContext);
if (cachedContextIter == queueMap_end) {
- static constexpr auto gpuSelector = sycl::gpu_selector_v;
+ static constexpr auto gpuSelector = sycl::default_selector_v;
static const sycl::property_list propertyList =
sycl::property_list(sycl::property::queue::in_order());
@@ -320,8 +331,12 @@ namespace resources
void wait_for(SyclEvent const& e)
{
- qu.submit(
- [&](::sycl::handler& h) { h.depends_on(e.getSyclEvent_t()); });
+ // As above, depends_on alone is not an operation; pair it with an
+ // empty task so the command group is valid on every backend.
+ qu.submit([&](::sycl::handler& h) {
+ h.depends_on(e.getSyclEvent_t());
+ h.single_task([]() {});
+ });
}
void wait_for(Event const& e)
diff --git a/test/resource.cpp b/test/resource.cpp
index b4ab090..06c4920 100644
--- a/test/resource.cpp
+++ b/test/resource.cpp
@@ -1155,7 +1155,7 @@ TEST(CampResource, StreamSelect)
#endif
#ifdef CAMP_HAVE_SYCL
{
- auto gpuSelector = sycl::gpu_selector_v;
+ auto gpuSelector = sycl::default_selector_v;
sycl::property_list propertyList =
sycl::property_list(sycl::property::queue::in_order());
sycl::context context;
@@ -1258,7 +1258,7 @@ TEST(CampResource, GetEvent)
#endif
#ifdef CAMP_HAVE_SYCL
{
- auto gpuSelector = sycl::gpu_selector_v;
+ auto gpuSelector = sycl::default_selector_v;
sycl::property_list propertyList =
sycl::property_list(sycl::property::queue::in_order());
sycl::context context;
@@ -1306,7 +1306,7 @@ TEST(CampEvent, Get)
#endif
#ifdef CAMP_HAVE_SYCL
{
- auto gpuSelector = sycl::gpu_selector_v;
+ auto gpuSelector = sycl::default_selector_v;
sycl::property_list propertyList =
sycl::property_list(sycl::property::queue::in_order());
sycl::context context;
@@ -1371,7 +1371,7 @@ TEST(CampEvent, GetConst)
#endif
#ifdef CAMP_HAVE_SYCL
{
- auto gpuSelector = sycl::gpu_selector_v;
+ auto gpuSelector = sycl::default_selector_v;
sycl::property_list propertyList =
sycl::property_list(sycl::property::queue::in_order());
sycl::context context;
@@ -1859,7 +1859,7 @@ TEST(CampResourceSycl, Helpers)
Sycl::set_thread_default_context(new_context);
ASSERT_EQ(Sycl::get_thread_default_context(), new_context);
- auto gpuSelector = sycl::gpu_selector_v;
+ auto gpuSelector = sycl::default_selector_v;
sycl::property_list ordered_properties =
sycl::property_list(sycl::property::queue::in_order());
sycl::queue ordered_queue(new_context, gpuSelector, ordered_properties);