Skip to content

Commit 3f965cd

Browse files
committed
made adjustments as per Chinmay's recommendations
1 parent 922262e commit 3f965cd

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

amd/comgr/src/comgr-env.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,12 @@ bool needTimeStatistics() {
6060
}
6161

6262
uint32_t getGranularityUnitsPerSecond() {
63-
static const char *TimeStatisticsGranularity =
64-
getenv("AMD_COMGR_TIME_STATISTICS_GRANULARITY");
65-
if (!TimeStatisticsGranularity)
66-
return 1e3;
67-
StringRef G(TimeStatisticsGranularity);
63+
StringRef G = getTimeStatisticsGranularity();
6864
if (G == "us")
6965
return 1e6;
7066
else if (G == "ns")
7167
return 1e9;
72-
else
73-
return 1e3;
68+
return 1e3;
7469
}
7570

7671
llvm::StringRef getTimeStatisticsGranularity() {

amd/comgr/src/comgr-env.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ bool shouldEmitVerboseLogs();
2929
/// Return whether the environment requests time statistics collection.
3030
bool needTimeStatistics();
3131

32-
// Return granularity (ms, us, ns) units per second
32+
/// Return granularity (ms, us, ns) units per second
3333
uint32_t getGranularityUnitsPerSecond();
3434

35-
// Return granularity of time statistics (ms, us, ns)
35+
/// Return granularity of time statistics (ms, us, ns)
3636
llvm::StringRef getTimeStatisticsGranularity();
3737

3838
/// If environment variable LLVM_PATH is set, return the environment variable,

amd/comgr/src/time-stat/perf-timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class PerfTimerImpl {
1717
protected:
1818
long long CounterStart;
1919
double PCFreq;
20+
uint32_t GranularityPerSecond;
2021

2122
public:
2223
PerfTimerImpl() : CounterStart(0), PCFreq(0.0) {};

amd/comgr/src/time-stat/time-stat.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ProfilePoint::~ProfilePoint() {
104104
class PerfTimerWindows : public PerfTimerImpl {
105105

106106
public:
107-
PerfTimerWindows(){};
107+
PerfTimerWindows() {};
108108
virtual bool Init() override {
109109
LARGE_INTEGER li;
110110
if (QueryPerformanceCounter(&li))
@@ -120,7 +120,7 @@ class PerfTimerWindows : public PerfTimerImpl {
120120
}
121121
// QueryPerformanceFrequency returns counts per second
122122
// If we need milliseconds we divide by 10^3
123-
uint32_t GranularityPerSecond = env::getGranularityUnitsPerSecond();
123+
GranularityPerSecond = env::getGranularityUnitsPerSecond();
124124
PCFreq = li.QuadPart / GranularityPerSecond;
125125
return true;
126126
}
@@ -155,7 +155,7 @@ class PerfTimerPosix : public PerfTimerImpl {
155155
}
156156
// clock_getres returns counts per nanosecond
157157
// If we need milliseconds we multiply by 10^6
158-
uint32_t GranularityPerSecond = env::getGranularityUnitsPerSecond();
158+
GranularityPerSecond = env::getGranularityUnitsPerSecond();
159159
PCFreq = (Res.tv_sec * 1e9 + Res.tv_nsec) * (1e9 / GranularityPerSecond);
160160
return true;
161161
}

0 commit comments

Comments
 (0)