From 39f0c3e82158b5339bb42bed0cc81c23a9eabf63 Mon Sep 17 00:00:00 2001 From: Ramesh Errabolu Date: Mon, 28 Aug 2017 12:53:58 -0500 Subject: [PATCH] Add Iommu Perf Cntrs Change-Id: I1cf3f00a959a923462634a62263707a267ae18af [ROCm/ROCR-Runtime commit: 3980b4268b9781b9e09ef6c88bde923818b04c4b] --- .../samples/common/hsa_perf_cntrs.cpp | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/projects/rocr-runtime/samples/common/hsa_perf_cntrs.cpp b/projects/rocr-runtime/samples/common/hsa_perf_cntrs.cpp index 24b38c80cd..a4b8e2df63 100644 --- a/projects/rocr-runtime/samples/common/hsa_perf_cntrs.cpp +++ b/projects/rocr-runtime/samples/common/hsa_perf_cntrs.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "hsa.h" #include "tools/inc/hsa_ext_profiler.h" #include "tools/inc/amd_hsa_tools_interfaces.h" @@ -82,15 +84,30 @@ hsa_status_t RocrPerfCntrApp::Init(hsa_agent_t agent) { CntrInfo* info = NULL; cntrList_.reserve(23); - // Event for number of Waves - info = new CntrInfo(0x4, "SQ_SQ_PERF_SEL_WAVES", NULL, - 0x0E, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_Exact); - cntrList_.push_back(info); + char *cntrChoice = getenv("IOMMU"); + if (cntrChoice == NULL) { + // Event for number of Waves + info = new CntrInfo(0x4, "SQ_SQ_PERF_SEL_WAVES", NULL, + 0x0E, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_Exact); + cntrList_.push_back(info); + + // Event for number of Threads + info = new CntrInfo(0xE, "SQ_SQ_PERF_SEL_ITEMS", NULL, + 0x0E, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_Exact); + cntrList_.push_back(info); - // Event for number of Threads - info = new CntrInfo(0xE, "SQ_SQ_PERF_SEL_ITEMS", NULL, - 0x0E, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_Exact); - cntrList_.push_back(info); + } else { + + // Program to collect event number 4 + info = new CntrInfo(0x4, "Iommu_Cntr_4", NULL, + 0x63, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_None); + cntrList_.push_back(info); + + // Program to collect event number 6 + info = new CntrInfo(0x6, "Iommu_Cntr_6", NULL, + 0x63, NULL, 0x00, 0xFFFFFFFF, CntrValCnf_None); + cntrList_.push_back(info); + } // Create an instance of Perf Mgr