-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathEvent.hpp
More file actions
66 lines (50 loc) · 1.59 KB
/
Copy pathEvent.hpp
File metadata and controls
66 lines (50 loc) · 1.59 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
/*******************************************************
* 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
********************************************************/
#pragma once
#include <common/EventBase.hpp>
#include <af/event.h>
#include <sycl/sycl.hpp>
namespace arrayfire {
namespace oneapi {
class OneAPIEventPolicy {
public:
using EventType = sycl::event *;
using QueueType = sycl::queue;
using ErrorType = int;
static ErrorType createAndMarkEvent(EventType *e) noexcept {
*e = new sycl::event;
return 0;
}
static ErrorType markEvent(EventType *e, QueueType stream) noexcept {
**e = stream.ext_oneapi_submit_barrier();
return 0;
}
static ErrorType waitForEvent(EventType *e, QueueType stream) noexcept {
stream.ext_oneapi_submit_barrier({**e});
return 0;
}
static ErrorType syncForEvent(EventType *e) noexcept {
(*e)->wait();
return 0;
}
static ErrorType destroyEvent(EventType *e) noexcept {
delete *e;
return 0;
}
};
using Event = common::EventBase<OneAPIEventPolicy>;
/// \brief Creates a new event and marks it in the queue
Event makeEvent(sycl::queue &queue);
af_event createEvent();
void markEventOnActiveQueue(af_event eventHandle);
void enqueueWaitOnActiveQueue(af_event eventHandle);
void block(af_event eventHandle);
af_event createAndMarkEvent();
} // namespace oneapi
} // namespace arrayfire