1 | /******************************************************************************* |
2 | * Copyright 2016-2022 Intel Corporation |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | *******************************************************************************/ |
16 | |
17 | #include <assert.h> |
18 | #include "oneapi/dnnl/dnnl.h" |
19 | |
20 | #include "c_types_map.hpp" |
21 | #include "engine.hpp" |
22 | #include "primitive_exec_types.hpp" |
23 | #include "primitive_iface.hpp" |
24 | #include "stream.hpp" |
25 | #include "utils.hpp" |
26 | |
27 | using namespace dnnl::impl; |
28 | using namespace dnnl::impl::status; |
29 | using namespace dnnl::impl::utils; |
30 | |
31 | status_t stream_t::enqueue_primitive( |
32 | const primitive_iface_t *primitive_iface, exec_ctx_t &ctx) { |
33 | return primitive_iface->execute(ctx); |
34 | } |
35 | |
36 | /* API */ |
37 | |
38 | status_t dnnl_stream_create( |
39 | stream_t **stream, engine_t *engine, unsigned flags) { |
40 | bool args_ok = !utils::any_null(stream, engine); |
41 | if (!args_ok) return invalid_arguments; |
42 | |
43 | return engine->create_stream(stream, flags); |
44 | } |
45 | |
46 | status_t dnnl_stream_get_engine(const stream_t *stream, engine_t **engine) { |
47 | if (any_null(stream, engine)) return invalid_arguments; |
48 | *engine = stream->engine(); |
49 | return success; |
50 | } |
51 | |
52 | status_t dnnl_stream_wait(stream_t *stream) { |
53 | bool args_ok = !any_null(stream); |
54 | if (!args_ok) return invalid_arguments; |
55 | |
56 | return stream->wait(); |
57 | } |
58 | |
59 | status_t dnnl_stream_destroy(stream_t *stream) { |
60 | delete stream; |
61 | return success; |
62 | } |
63 | |
64 | // vim: et ts=4 sw=4 cindent cino+=l0,\:4,N-s |
65 | |