Home | History | Annotate | Download | only in stream_executor
      1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #include "tensorflow/stream_executor/event.h"
     17 
     18 #include "tensorflow/stream_executor/stream_executor_internal.h"
     19 #include "tensorflow/stream_executor/stream_executor_pimpl.h"
     20 #include "tensorflow/stream_executor/stream.h"
     21 
     22 namespace perftools {
     23 namespace gputools {
     24 
     25 Event::Event(StreamExecutor* stream_exec)
     26     : stream_exec_(stream_exec),
     27       implementation_(
     28           stream_exec_->implementation()->CreateEventImplementation()) {}
     29 
     30 Event::~Event() {
     31   auto status = stream_exec_->DeallocateEvent(this);
     32   if (!status.ok()) {
     33     LOG(ERROR) << status.error_message();
     34   }
     35 }
     36 
     37 bool Event::Init() {
     38   auto status = stream_exec_->AllocateEvent(this);
     39   if (!status.ok()) {
     40     LOG(ERROR) << status.error_message();
     41     return false;
     42   }
     43 
     44   return true;
     45 }
     46 
     47 Event::Status Event::PollForStatus() {
     48   return stream_exec_->PollForEventStatus(this);
     49 }
     50 
     51 }  // namespace gputools
     52 }  // namespace perftools
     53