SWDEV-393362 - Move setData() from profilingEnd() to profilingBegin() to eliminate a possible data race

- Introduce a state variable to indicate if HwProfiling is enabled to
eliminate a possible data race of vector<> signals_.

Change-Id: Id504cc76d7fa9f7e6455587dd232b60ccbbb735b
Cette révision appartient à :
Sourabh Betigeri a créé et Sourabh Betigeri a révisé 2023-05-04 17:19:25 -04:00
1 Parent 0a7708f982
révision afa28cdf44
2 fichiers modifiés
+11 -8

Aucun fichier ne correspond à votre recherche

+5 -6
Voir le fichier
@@ -1386,8 +1386,8 @@ address VirtualGPU::allocKernelArguments(size_t size, size_t alignment) {
// ================================================================================================
/* profilingBegin, when profiling is enabled, creates a timestamp to save in
* virtualgpu's timestamp_, and calls start() to get the current host
* timestamp.
* virtualgpu's timestamp_, saves the pointer timestamp_ to the command's data
* and then calls start() to get the current host timestamp.
*/
void VirtualGPU::profilingBegin(amd::Command& command, bool drmProfiling) {
if (command.profilingInfo().enabled_) {
@@ -1398,6 +1398,7 @@ void VirtualGPU::profilingBegin(amd::Command& command, bool drmProfiling) {
}
// Without barrier profiling will wait for each individual signal
timestamp_ = new Timestamp(this, command);
command.setData(timestamp_);
timestamp_->start();
}
@@ -1423,15 +1424,13 @@ void VirtualGPU::profilingBegin(amd::Command& command, bool drmProfiling) {
// ================================================================================================
/* profilingEnd, when profiling is enabled, checks to see if a signal was
* created for whatever command we are running and calls end() to get the
* current host timestamp if no signal is available. It then saves the pointer
* timestamp_ to the command's data.
* current host timestamp if no signal is available.
*/
void VirtualGPU::profilingEnd(amd::Command& command) {
if (command.profilingInfo().enabled_) {
if (!timestamp_->HwProfiling()) {
if (timestamp_->HwProfiling() == false) {
timestamp_->end();
}
command.setData(timestamp_);
timestamp_ = nullptr;
}
if (AMD_DIRECT_DISPATCH) {