Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ondrej Vysocky
meric
Commits
a98af2e0
Commit
a98af2e0
authored
Feb 15, 2019
by
Ondrej Vysocky
Browse files
ENH both core and uncore frequencies specified in Hz
#62
parent
bbc69ee4
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/basis/utils.h
View file @
a98af2e0
...
...
@@ -7,6 +7,7 @@
#include <sstream>
#include <iomanip>
#include <sys/stat.h>
#include <algorithm>
#ifdef VERBOSE
#define MERIC_INFO std::cout
...
...
@@ -28,6 +29,28 @@ struct mutils {
return
time
.
tv_sec
+
time
.
tv_nsec
/
1e9
;
}
static
long
frequencyToHz
(
const
std
::
string
&
data
)
{
if
(
data
==
""
||
data
.
find_first_of
(
"0123456789"
)
!=
0
)
return
-
1
;
size_t
const
n
=
data
.
find_first_not_of
(
"0123456789"
);
if
(
n
==
std
::
string
::
npos
)
return
std
::
stol
(
data
);
const
long
frequency
=
std
::
stol
(
data
.
substr
(
0
,
n
));
std
::
string
units
=
data
.
substr
(
n
,
data
.
size
()
-
n
);
std
::
transform
(
units
.
begin
(),
units
.
end
(),
units
.
begin
(),
::
toupper
);
if
(
units
==
"HZ"
)
return
frequency
;
else
if
(
units
==
"KHZ"
)
return
frequency
*
1000
;
else
if
(
units
==
"MHZ"
)
return
frequency
*
1000000
;
else
if
(
units
==
"GHZ"
)
return
frequency
*
1000000000
;
else
return
-
1
;
}
static
timespec
stringToTime
(
const
std
::
string
&
data
)
{
timespec
time
;
...
...
src/meric/meric.cpp
View file @
a98af2e0
...
...
@@ -46,8 +46,8 @@ int Meric::getDefaultParameters()
int
ret
=
0
;
//OBLIGATORY SECTION
defaultParameter
.
nthreads
=
mutils
::
getenv
(
"MERIC_NUM_THREADS"
,
-
1
);
defaultParameter
.
frequency
=
mutils
::
getenv
(
"MERIC_FREQUENCY"
,
-
1
);
defaultParameter
.
uncoreFrequency
=
mutils
::
getenv
(
"MERIC_UNCORE_FREQUENCY"
,
-
1
);
defaultParameter
.
frequency
=
mutils
::
frequencyToHz
(
mutils
::
getenv
(
"MERIC_FREQUENCY"
,
""
)
);
defaultParameter
.
uncoreFrequency
=
mutils
::
frequencyToHz
(
mutils
::
getenv
(
"MERIC_UNCORE_FREQUENCY"
,
""
)
);
#if defined (HAVE_CPUFREQ_H) || HAVE_X86_ADAPT_H
if
(
defaultParameter
.
frequency
<
0
)
...
...
@@ -59,6 +59,7 @@ int Meric::getDefaultParameters()
{
Meric
::
outputFilenameInfo
+=
"CF_"
;
}
#endif
#ifdef HAVE_X86_ADAPT_H
...
...
@@ -304,12 +305,12 @@ RegionParameters Meric::getRegionSettings(json_object_element_s * data)
if
(
"FREQUENCY"
==
std
::
string
(
set
->
name
->
string
))
{
if
(
defaultParameter
.
frequency
!=
0
)
param
.
frequency
=
std
::
stoi
(
std
::
string
(((
struct
json_string_s
*
)
set
->
value
->
payload
)
->
string
));
param
.
frequency
=
mutils
::
frequencyToHz
(
std
::
string
(((
struct
json_string_s
*
)
set
->
value
->
payload
)
->
string
));
}
else
if
(
"UNCORE_FREQUENCY"
==
std
::
string
(
set
->
name
->
string
))
{
if
(
defaultParameter
.
uncoreFrequency
!=
0
)
param
.
uncoreFrequency
=
std
::
stoi
(
std
::
string
(((
struct
json_string_s
*
)
set
->
value
->
payload
)
->
string
));
param
.
uncoreFrequency
=
mutils
::
frequencyToHz
(
std
::
string
(((
struct
json_string_s
*
)
set
->
value
->
payload
)
->
string
));
}
else
if
(
"NUM_THREADS"
==
std
::
string
(
set
->
name
->
string
))
{
...
...
src/wrapper/environmentwrapper.cpp
View file @
a98af2e0
...
...
@@ -12,10 +12,10 @@ using namespace meric;
//systemLimits Environment::FreqLimits [4];
systemLimits
Environment
::
FreqLimits
[]
=
{
[
SYS_HASWELL
]
=
{
3300000
,
2500000
,
1200000
,
30
,
30
,
12
},
[
SYS_JETSON
]
=
{
1734000
,
518400
,
102000
,
1600000
,
408000
,
40800
},
[
SYS_HASWELL
]
=
{
3300000
000
,
2500000
0
00
,
1200000
00
0
,
30
00000000
,
3000000000
,
1200000000
},
[
SYS_JETSON
]
=
{
1734000
000
,
518400
000
,
102000
0
00
,
1600000
0
00
,
408000
000
,
40800
000
},
[
SYS_THUNDER
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
},
//DVFS+UFS not supported
[
SYS_DAVIDE
]
=
{
4023000
,
4023000
,
2061000
,
-
1
,
-
1
,
-
1
},
//UFS not supported
[
SYS_DAVIDE
]
=
{
4023000
000
,
4023000
00
0
,
2061000
000
,
-
1
,
-
1
,
-
1
},
//UFS not supported
[
SYS_OTHER
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
}
};
...
...
@@ -98,16 +98,16 @@ void Environment::getFrequenciesLimits()
{
//CORE freq
std
::
ifstream
frequencyBounderyFile
;
std
::
string
freqBound
;
std
::
string
freqBound
;
//files has the value in KHz
frequencyBounderyFile
.
open
(
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
);
frequencyBounderyFile
>>
freqBound
;
frequencyBounderyFile
.
close
();
FreqLimits
[
SYS_OTHER
].
maxCoreFreq
=
std
::
sto
i
(
freqBound
);
FreqLimits
[
SYS_OTHER
].
maxCoreFreq
=
std
::
sto
l
(
freqBound
)
*
1000
;
FreqLimits
[
SYS_OTHER
].
defaultCoreFreq
=
FreqLimits
[
SYS_OTHER
].
maxCoreFreq
;
frequencyBounderyFile
.
open
(
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"
);
frequencyBounderyFile
>>
freqBound
;
frequencyBounderyFile
.
close
();
FreqLimits
[
SYS_OTHER
].
minCoreFreq
=
std
::
sto
i
(
freqBound
);
FreqLimits
[
SYS_OTHER
].
minCoreFreq
=
std
::
sto
l
(
freqBound
)
*
1000
;
//UnCORE freq
#ifdef HAVE_X86_ADAPT_H
...
...
@@ -115,11 +115,11 @@ void Environment::getFrequenciesLimits()
int
adaptHandlerUncore
=
x86_adapt_lookup_ci_name
(
X86_ADAPT_DIE
,
"Intel_UNCORE_MAX_RATIO"
);
uint64_t
setting
;
x86_adapt_get_setting
(
fd
,
adaptHandlerUncore
,
&
setting
);
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
=
(
int
)
setting
;
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
=
setting
*
100000000
;
FreqLimits
[
SYS_OTHER
].
defaultUncoreFreq
=
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
;
adaptHandlerUncore
=
x86_adapt_lookup_ci_name
(
X86_ADAPT_DIE
,
"Intel_UNCORE_MIN_RATIO"
);
x86_adapt_get_setting
(
fd
,
adaptHandlerUncore
,
&
setting
);
FreqLimits
[
SYS_OTHER
].
minUncoreFreq
=
(
int
)
setting
;
FreqLimits
[
SYS_OTHER
].
minUncoreFreq
=
setting
*
100000000
;
struct
stat
info
;
std
::
string
uncoreFrequencyDefaultFile
=
std
::
string
(
MERIC_PATH
)
+
"/build/ucfRestore.csv"
;
...
...
@@ -150,8 +150,8 @@ void Environment::getFrequenciesLimits()
FreqLimits
[
SYS_OTHER
].
defaultUncoreFreq
=
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
;
}
#endif
MERIC_INFO
<<
"CORE FREQ limits [Hz]: "
<<
FreqLimits
[
SYS_OTHER
].
maxCoreFreq
<<
'\t'
<<
FreqLimits
[
SYS_OTHER
].
minCoreFreq
<<
std
::
endl
;
MERIC_INFO
<<
"UNCORE FREQ limits [
100M
Hz]: "
<<
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
<<
'\t'
<<
FreqLimits
[
SYS_OTHER
].
minUncoreFreq
<<
std
::
endl
;
MERIC_INFO
<<
"CORE FREQ limits
[Hz]: "
<<
FreqLimits
[
SYS_OTHER
].
maxCoreFreq
<<
'\t'
<<
FreqLimits
[
SYS_OTHER
].
minCoreFreq
<<
std
::
endl
;
MERIC_INFO
<<
"UNCORE FREQ limits [Hz]: "
<<
FreqLimits
[
SYS_OTHER
].
maxUncoreFreq
<<
'\t'
<<
FreqLimits
[
SYS_OTHER
].
minUncoreFreq
<<
std
::
endl
;
}
void
Environment
::
init
(
int
system
,
RegionParameters
defaultParameter
,
int
rank
)
...
...
@@ -415,7 +415,7 @@ void Environment::uncoreFrequency(uint64_t maxFreq, uint64_t minFreq, int socket
{
std
::
ofstream
uncoreFile
;
uncoreFile
.
open
(
"/sys/kernel/debug/clock/override.emc/rate"
);
uncoreFile
<<
maxFreq
<<
"000"
;
uncoreFile
<<
maxFreq
;
uncoreFile
.
close
();
MERIC_INFO
<<
"JETSON set uncore frequency to: "
<<
maxFreq
<<
std
::
endl
;
}
...
...
@@ -460,8 +460,8 @@ void Environment::uncoreFrequency(uint64_t maxFreq, uint64_t minFreq, int socket
}
};
setFreq
(
adaptHandlerUncoreMax
,
maxFreq
);
setFreq
(
adaptHandlerUncoreMin
,
minFreq
);
setFreq
(
adaptHandlerUncoreMax
,
maxFreq
/
100000000
);
setFreq
(
adaptHandlerUncoreMin
,
minFreq
/
100000000
);
if
(
x86_adapt_put_device
(
X86_ADAPT_DIE
,
die
))
std
::
cerr
<<
"X86ADAPT ERROR: error while closing file descriptor
\n
"
;
...
...
src/wrapper/environmentwrapper.h
View file @
a98af2e0
...
...
@@ -43,20 +43,20 @@ enum mode {MODE_HDEEM, MODE_RAPL, MODE_BOTH, MODE_RUN, MODE_JETSON, MODE_THUNDER
enum
system
{
SYS_HASWELL
,
SYS_JETSON
,
SYS_THUNDER
,
SYS_DAVIDE
,
SYS_OTHER
};
struct
RegionParameters
{
double
frequency
;
uint64_t
uncoreFrequency
;
long
frequency
;
//must be able to carry -1
long
uncoreFrequency
;
//must be able to carry -1
int
nthreads
;
};
struct
systemLimits
{
int
maxCoreFreq
;
int
defaultCoreFreq
;
int
minCoreFreq
;
int
maxUncoreFreq
;
int
defaultUncoreFreq
;
int
minUncoreFreq
;
struct
systemLimits
{
//Hz
u
int
64_t
maxCoreFreq
;
u
int
64_t
defaultCoreFreq
;
u
int
64_t
minCoreFreq
;
u
int
64_t
maxUncoreFreq
;
u
int
64_t
defaultUncoreFreq
;
u
int
64_t
minUncoreFreq
;
};
const
int
CPUFREQ_FREQ_MULT
=
100000
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment