|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#include "vulkan_device.h" |
| 21 | + |
| 22 | +namespace tvm { |
| 23 | +namespace runtime { |
| 24 | +namespace vulkan { |
| 25 | + |
| 26 | +VulkanStreamProfiler::VulkanStreamProfiler(const VulkanDevice* device) |
| 27 | + : device_(device), curr_state_(READY), available_(device->UseDebugUtilsLabel()) {} |
| 28 | + |
| 29 | +void AmdRgpProfiler::capture() { |
| 30 | + if (!available_) { |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + // Trigger RGP capture by using dummy present and switch state from READY to RUNNING |
| 35 | + if (curr_state_ == READY) { |
| 36 | + VkDebugUtilsLabelEXT frame_end_label = { |
| 37 | + VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameEnd", {0.0f, 0.0f, 0.0f, 0.0f}}; |
| 38 | + device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT( |
| 39 | + device_->Queue(), &frame_end_label); |
| 40 | + |
| 41 | + VkDebugUtilsLabelEXT frame_begin_label = { |
| 42 | + VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameBegin", {0.0f, 0.0f, 0.0f, 0.0f}}; |
| 43 | + device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT( |
| 44 | + device_->Queue(), &frame_begin_label); |
| 45 | + |
| 46 | + // Set state as RUNNING |
| 47 | + curr_state_ = RUNNING; |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +} // namespace vulkan |
| 52 | +} // namespace runtime |
| 53 | +} // namespace tvm |
0 commit comments