| 24 | namespace gpu { |
| 25 | |
| 26 | bool GpuTimer::Init() { |
| 27 | CHECK(start_event_ == nullptr && stop_event_ == nullptr); |
| 28 | GpuContext* context = parent_->gpu_context(); |
| 29 | port::Status status = GpuDriver::InitEvent(context, &start_event_, |
| 30 | GpuDriver::EventFlags::kDefault); |
| 31 | if (!status.ok()) { |
| 32 | LOG(ERROR) << status; |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | status = GpuDriver::InitEvent(context, &stop_event_, |
| 37 | GpuDriver::EventFlags::kDefault); |
| 38 | if (!status.ok()) { |
| 39 | LOG(ERROR) << status; |
| 40 | status = GpuDriver::DestroyEvent(context, &start_event_); |
| 41 | if (!status.ok()) { |
| 42 | LOG(ERROR) << status; |
| 43 | } |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | CHECK(start_event_ != nullptr && stop_event_ != nullptr); |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | void GpuTimer::Destroy() { |
| 52 | GpuContext* context = parent_->gpu_context(); |
nothing calls this directly
no test coverage detected