-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Runtime][Vulkan] Add RGP support to TVM for vulkan device
RGP(Raedon GPU Profiler) is a tool used to analyze the applications run on AMD GPU. RGP captures the data based on VKPresent and provides the hardware specific information. Allowing the developer to optimize the application. To add RGP support to TVM, debug labels "AmdFrameBegin" and "AmdFrameEnd" need to be inserted into the vulkan queue.These Labels helps the RGP tool to understand the start|end of frame when no present is available. Thus enabling the RGP tool to capture and analyze the data. At runtime, set the envirnoment variable "TVM_USE_AMD_RGP=1" to start inserting the Debug Labels into the vulkan queue. Signed-off-by: Wilkin Chau <Wing-Ki.ChauWilkin@amd.com> Signed-off-by: Anurag Kumar Vulisha <AnuragKumar.Vulisha@amd.com>
- Loading branch information
Showing
9 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include "vulkan_device.h" | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
namespace vulkan { | ||
|
||
VulkanStreamProfiler::VulkanStreamProfiler(const VulkanDevice* device) | ||
: device_(device), curr_state_(READY), available_(device->UseDebugUtilsLabel()) {} | ||
|
||
void AmdRgpProfiler::capture() { | ||
if (!available_) { | ||
return; | ||
} | ||
|
||
// Trigger RGP capture by using dummy present and switch state from READY to RUNNING | ||
if (curr_state_ == READY) { | ||
VkDebugUtilsLabelEXT frame_end_label = { | ||
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameEnd", {0.0f, 0.0f, 0.0f, 0.0f}}; | ||
device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT( | ||
device_->Queue(), &frame_end_label); | ||
|
||
VkDebugUtilsLabelEXT frame_begin_label = { | ||
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, NULL, "AmdFrameBegin", {0.0f, 0.0f, 0.0f, 0.0f}}; | ||
device_->queue_insert_debug_utils_label_functions->vkQueueInsertDebugUtilsLabelEXT( | ||
device_->Queue(), &frame_begin_label); | ||
|
||
// Set state as RUNNING | ||
curr_state_ = RUNNING; | ||
} | ||
} | ||
|
||
} // namespace vulkan | ||
} // namespace runtime | ||
} // namespace tvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef TVM_RUNTIME_VULKAN_VULKAN_AMDRGP_H_ | ||
#define TVM_RUNTIME_VULKAN_VULKAN_AMDRGP_H_ | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
namespace vulkan { | ||
|
||
class VulkanDevice; | ||
|
||
class VulkanStreamProfiler { | ||
public: | ||
enum state { READY = 0, RUNNING, RESET }; | ||
|
||
explicit VulkanStreamProfiler(const VulkanDevice* device); | ||
|
||
virtual ~VulkanStreamProfiler() {} | ||
|
||
virtual void reset() { curr_state_ = RESET; } | ||
|
||
virtual void ready() { | ||
if (curr_state_ == RESET) { | ||
curr_state_ = READY; | ||
} | ||
} | ||
|
||
virtual void capture() = 0; | ||
|
||
protected: | ||
const VulkanDevice* device_; | ||
state curr_state_; | ||
bool available_; | ||
}; | ||
|
||
class AmdRgpProfiler : public VulkanStreamProfiler { | ||
public: | ||
explicit AmdRgpProfiler(const VulkanDevice* device) : VulkanStreamProfiler(device) {} | ||
|
||
void capture(); | ||
}; | ||
|
||
} // namespace vulkan | ||
} // namespace runtime | ||
} // namespace tvm | ||
#endif // TVM_RUNTIME_VULKAN_VULKAN_AMDRGP_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters