diff options
author | 2015-11-06 16:27:58 -0800 | |
---|---|---|
committer | 2015-11-06 16:27:58 -0800 | |
commit | f41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch) | |
tree | ef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/stream_executor/event.cc |
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation
using data flow graphs.
Base CL: 107276108
Diffstat (limited to 'tensorflow/stream_executor/event.cc')
-rw-r--r-- | tensorflow/stream_executor/event.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tensorflow/stream_executor/event.cc b/tensorflow/stream_executor/event.cc new file mode 100644 index 0000000000..79c3d39f24 --- /dev/null +++ b/tensorflow/stream_executor/event.cc @@ -0,0 +1,48 @@ +#include "tensorflow/stream_executor/event.h" + +#include "tensorflow/stream_executor/stream_executor_internal.h" +#include "tensorflow/stream_executor/stream_executor_pimpl.h" +#include "tensorflow/stream_executor/stream.h" + +namespace perftools { +namespace gputools { + +internal::EventInterface* CreateEventImplementation( + StreamExecutor* stream_exec) { + PlatformKind platform_kind = stream_exec->platform_kind(); + switch (platform_kind) { + case PlatformKind::kCuda: + return (*internal::MakeCUDAEventImplementation())(stream_exec); + default: + LOG(FATAL) << "Cannot create event implementation for platform kind: " + << PlatformKindString(platform_kind); + } +} + +Event::Event(StreamExecutor* stream_exec) + : implementation_(CreateEventImplementation(stream_exec)), + stream_exec_(stream_exec) {} + +Event::~Event() { + auto status = stream_exec_->DeallocateEvent(this); + if (!status.ok()) { + LOG(ERROR) << status.error_message(); + } +} + +bool Event::Init() { + auto status = stream_exec_->AllocateEvent(this); + if (!status.ok()) { + LOG(ERROR) << status.error_message(); + return false; + } + + return true; +} + +Event::Status Event::PollForStatus() { + return stream_exec_->PollForEventStatus(this); +} + +} // namespace gputools +} // namespace perftools |