Home | History | Annotate | Download | only in cuda
      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 #ifndef TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_EVENT_H_
     17 #define TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_EVENT_H_
     18 
     19 #include "tensorflow/stream_executor/cuda/cuda_driver.h"
     20 #include "tensorflow/stream_executor/cuda/cuda_stream.h"
     21 #include "tensorflow/stream_executor/event.h"
     22 #include "tensorflow/stream_executor/lib/status.h"
     23 
     24 namespace perftools {
     25 namespace gputools {
     26 namespace cuda {
     27 
     28 // CUDAEvent wraps a CUevent in the platform-independent EventInterface
     29 // interface.
     30 class CUDAEvent : public internal::EventInterface {
     31  public:
     32   explicit CUDAEvent(CUDAExecutor* parent);
     33 
     34   ~CUDAEvent() override;
     35 
     36   // Populates the CUDA-platform-specific elements of this object.
     37   port::Status Init();
     38 
     39   // Deallocates any platform-specific elements of this object. This is broken
     40   // out (not part of the destructor) to allow for error reporting.
     41   port::Status Destroy();
     42 
     43   // Inserts the event at the current position into the specified stream.
     44   port::Status Record(CUDAStream* stream);
     45 
     46   // Polls the CUDA platform for the event's current status.
     47   Event::Status PollForStatus();
     48 
     49   // The underlying CUDA event element.
     50   const CUevent& cuda_event();
     51 
     52  private:
     53   // The Executor used to which this object and CUevent are bound.
     54   CUDAExecutor* parent_;
     55 
     56   // The underlying CUDA event element.
     57   CUevent cuda_event_;
     58 };
     59 
     60 }  // namespace cuda
     61 }  // namespace gputools
     62 }  // namespace perftools
     63 
     64 #endif  // TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_EVENT_H_
     65