-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathEvent.cpp
More file actions
74 lines (63 loc) · 1.91 KB
/
Copy pathEvent.cpp
File metadata and controls
74 lines (63 loc) · 1.91 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
/*******************************************************
* Copyright (c) 2022, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <Event.hpp>
#include <err_oneapi.hpp>
#include <events.hpp>
#include <platform.hpp>
#include <af/event.h>
#include <memory>
#include <memory>
using std::make_unique;
using std::unique_ptr;
namespace arrayfire {
namespace oneapi {
/// \brief Creates a new event and marks it in the queue
Event makeEvent(sycl::queue& queue) {
Event e;
if (e.create() == 0) { e.mark(queue); }
return e;
}
af_event createEvent() {
auto e = make_unique<Event>();
// Ensure the default CL command queue is initialized
getQueue();
if (e->create() != 0) {
AF_ERROR("Could not create event", AF_ERR_RUNTIME);
}
Event& ref = *e.release();
return getHandle(ref);
}
void markEventOnActiveQueue(af_event eventHandle) {
Event& event = getEvent(eventHandle);
// Use the currently-active stream
if (event.mark(getQueue()) != 0) {
AF_ERROR("Could not mark event on active queue", AF_ERR_RUNTIME);
}
}
void enqueueWaitOnActiveQueue(af_event eventHandle) {
Event& event = getEvent(eventHandle);
// Use the currently-active stream
if (event.enqueueWait(getQueue()) != 0) {
AF_ERROR("Could not enqueue wait on active queue for event",
AF_ERR_RUNTIME);
}
}
void block(af_event eventHandle) {
Event& event = getEvent(eventHandle);
if (event.block() != 0) {
AF_ERROR("Could not block on active queue for event", AF_ERR_RUNTIME);
}
}
af_event createAndMarkEvent() {
af_event handle = createEvent();
markEventOnActiveQueue(handle);
return handle;
}
} // namespace oneapi
} // namespace arrayfire