Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / gpu / ocl_user_event.cpp
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 #include "ocl_user_event.h"
18
19
20 using namespace cldnn::gpu;
21
22 void user_event::set_impl()
23 {
24     //we simulate "wrapper_cast" here to cast from cl::Event to cl::UserEvent which both wrap the same cl_event
25     //casting is valid as long as cl::UserEvent does not add any members to cl::Event (which it shouldn't)
26     static_assert(sizeof(cl::UserEvent) == sizeof(cl::Event) && alignof(cl::UserEvent) == alignof(cl::Event), "cl::UserEvent does not match cl::Event");
27     static_cast<cl::UserEvent&&>(get()).setStatus(CL_COMPLETE);
28     _duration = std::unique_ptr<cldnn::instrumentation::profiling_period_basic>(
29                             new cldnn::instrumentation::profiling_period_basic(_timer.uptime()));
30     _attached = true;
31 }
32
33 bool user_event::get_profiling_info_impl(std::list<cldnn_profiling_interval>& info) {
34     if (_duration == nullptr)
35     {
36         return false;
37     }
38     
39     info.push_back({ "duration", static_cast<uint64_t>(_duration->value().count()) });
40     return true;
41 }