Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / gpu / ocl_user_event.h
1 /*
2 // Copyright (c) 2018 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
18 #pragma once
19
20 #include "ocl_base_event.h"
21 #include "api/CPP/profiling.hpp"
22
23 #ifdef _WIN32
24 #pragma warning(push)
25 #pragma warning(disable: 4250) //Visual Studio warns us about inheritance via dominance but it's done intentionally so turn it off
26 #endif
27
28 namespace cldnn { namespace gpu {
29
30 struct user_event : public base_event, public cldnn::user_event
31 {
32     user_event(std::shared_ptr<gpu_toolkit> ctx) 
33         : base_event(ctx)
34         , cldnn::user_event(false)
35     {}
36
37     void set_impl() override;
38     void attach_event(bool set)
39     {
40         _event = cl::UserEvent(get_context()->context());
41         //we need to reset the timer(since attach_ocl_event is called only when this object is being reused)
42         _timer = cldnn::instrumentation::timer<>(); 
43         if (set)
44         {
45             set_impl();
46             _set = set;
47         }
48     }
49     bool get_profiling_info_impl(std::list<cldnn_profiling_interval>& info) override;
50
51 protected:
52     cldnn::instrumentation::timer<> _timer;
53     std::unique_ptr<cldnn::instrumentation::profiling_period_basic> _duration;
54 };
55
56 #ifdef _WIN32
57 #pragma warning(pop)
58 #endif
59
60 } }