1 /* Copyright 2019 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_GPU_GPU_EVENT_H_ 17 #define TENSORFLOW_STREAM_EXECUTOR_GPU_GPU_EVENT_H_ 18 19 #include "tensorflow/stream_executor/event.h" 20 #include "tensorflow/stream_executor/gpu/gpu_driver.h" 21 #include "tensorflow/stream_executor/gpu/gpu_stream.h" 22 #include "tensorflow/stream_executor/lib/status.h" 23 24 namespace stream_executor { 25 namespace gpu { 26 27 // GpuEvent wraps a GpuEventHandle in the platform-independent EventInterface 28 // interface. 29 class GpuEvent : public internal::EventInterface { 30 public: 31 explicit GpuEvent(GpuExecutor* parent); 32 33 ~GpuEvent() override; 34 35 // Populates the CUDA-platform-specific elements of this object. 36 port::Status Init(); 37 38 // Deallocates any platform-specific elements of this object. This is broken 39 // out (not part of the destructor) to allow for error reporting. 40 port::Status Destroy(); 41 42 // Inserts the event at the current position into the specified stream. 43 port::Status Record(GpuStream* stream); 44 45 // Polls the CUDA platform for the event's current status. 46 Event::Status PollForStatus(); 47 48 // The underlying CUDA event element. 49 GpuEventHandle gpu_event(); 50 51 private: 52 // The Executor used to which this object and GpuEventHandle are bound. 53 GpuExecutor* parent_; 54 55 // The underlying CUDA event element. 56 GpuEventHandle gpu_event_; 57 }; 58 59 } // namespace gpu 60 } // namespace stream_executor 61 62 #endif // TENSORFLOW_STREAM_EXECUTOR_GPU_GPU_EVENT_H_ 63