Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
compass-github-pull
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
steinbac
compass-github-pull
Commits
9c5d6fae
Commit
9c5d6fae
authored
Aug 17, 2018
by
Peter Steinbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added handling of AMD brand and device strings
parent
7c6fa88d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
26 deletions
+92
-26
include/detail/rt/x86_impl.hpp
include/detail/rt/x86_impl.hpp
+34
-11
single_include/compass.hpp
single_include/compass.hpp
+58
-15
No files found.
include/detail/rt/x86_impl.hpp
View file @
9c5d6fae
...
...
@@ -90,27 +90,50 @@ namespace compass {
std
::
string
brand_str
=
compass
::
runtime
::
detail
::
brand
(
ct
::
x86_tag
());
std
::
string
vendor
=
compass
::
runtime
::
detail
::
vendor
(
ct
::
x86_tag
());
std
::
size_t
find_pos
=
0
;
bool
is_intel
=
false
;
bool
is_amd
=
false
;
//remove Genuine in Vendor string if present, Intel host
if
((
find_pos
=
vendor
.
find
(
"Genuine"
))
!=
std
::
string
::
npos
){
vendor
.
erase
(
find_pos
,
7
);
is_intel
=
true
;
}
//remove Authentic in Vendor string if present, AMD host, e.g. AMD EPYC 7401P 24-Core Processor
if
((
find_pos
=
vendor
.
find
(
"Authentic"
))
!=
std
::
string
::
npos
){
vendor
.
erase
(
find_pos
,
9
);
is_amd
=
true
;
}
std
::
string
value
=
""
;
if
(
brand_str
.
find
(
vendor
)
!=
std
::
string
::
npos
){
//based on the Intel chip test strings that are known
auto
second_bracket_itr
=
brand_str
.
rfind
(
")"
);
auto
last_at_itr
=
brand_str
.
rfind
(
"@"
);
value
=
brand_str
.
substr
(
second_bracket_itr
+
1
,
last_at_itr
-
(
second_bracket_itr
+
1
));
if
((
find_pos
=
brand_str
.
find
(
vendor
))
!=
std
::
string
::
npos
){
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
if
(
is_intel
){
//based on the Intel chip test strings that are known
auto
second_bracket_itr
=
brand_str
.
rfind
(
")"
);
auto
last_at_itr
=
brand_str
.
rfind
(
"@"
);
value
=
brand_str
.
substr
(
second_bracket_itr
+
1
,
last_at_itr
-
(
second_bracket_itr
+
1
));
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
//TODO: why run this 2 times?
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
value
.
erase
(
std
::
remove_if
(
value
.
begin
(),
value
.
end
(),
isspace
),
value
.
end
());
}
value
.
erase
(
std
::
remove_if
(
value
.
begin
(),
value
.
end
(),
isspace
),
value
.
end
());
if
(
is_amd
){
auto
end_itr
=
brand_str
.
rfind
(
"Processor"
);
value
=
brand_str
.
substr
(
find_pos
+
4
,
end_itr
-
4
);
}
}
return
value
;
...
...
single_include/compass.hpp
View file @
9c5d6fae
...
...
@@ -752,12 +752,14 @@ namespace compass {
public:
static
const
cacheline
&
get
(){
static
cacheline
instance
;
return
instance
;
}
static
const
cacheline
&
get
(){
static
cacheline
instance
;
return
instance
;
}
static
std
::
uint32_t
levels_available
(
ct
::
x86_tag
){
return
cacheline
::
get
().
ebx_data_
.
size
();
}
static
std
::
uint32_t
level
(
int
_lvl
,
ct
::
x86_tag
){
...
...
@@ -815,6 +817,10 @@ namespace compass {
return
instance
;
}
static
std
::
uint32_t
levels_available
(
ct
::
x86_tag
){
return
cache
::
get
().
ebx_data_
.
size
();
}
static
std
::
uint32_t
level
(
int
_lvl
,
ct
::
x86_tag
){
if
(
_lvl
<=
0
){
...
...
@@ -934,27 +940,50 @@ namespace compass {
std
::
string
brand_str
=
compass
::
runtime
::
detail
::
brand
(
ct
::
x86_tag
());
std
::
string
vendor
=
compass
::
runtime
::
detail
::
vendor
(
ct
::
x86_tag
());
std
::
size_t
find_pos
=
0
;
bool
is_intel
=
false
;
bool
is_amd
=
false
;
if
((
find_pos
=
vendor
.
find
(
"Genuine"
))
!=
std
::
string
::
npos
){
vendor
.
erase
(
find_pos
,
7
);
is_intel
=
true
;
}
if
((
find_pos
=
vendor
.
find
(
"Authentic"
))
!=
std
::
string
::
npos
){
vendor
.
erase
(
find_pos
,
9
);
is_amd
=
true
;
}
std
::
string
value
=
""
;
if
(
brand_str
.
find
(
vendor
)
!=
std
::
string
::
npos
){
if
(
(
find_pos
=
brand_str
.
find
(
vendor
)
)
!=
std
::
string
::
npos
){
auto
second_bracket_itr
=
brand_str
.
rfind
(
")"
);
auto
last_at_itr
=
brand_str
.
rfind
(
"@"
);
value
=
brand_str
.
substr
(
second_bracket_itr
+
1
,
last_at_itr
-
(
second_bracket_itr
+
1
));
if
(
is_intel
){
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
auto
second_bracket_itr
=
brand_str
.
rfind
(
")"
);
auto
last_at_itr
=
brand_str
.
rfind
(
"@"
);
value
=
brand_str
.
substr
(
second_bracket_itr
+
1
,
last_at_itr
-
(
second_bracket_itr
+
1
));
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
if
((
find_pos
=
value
.
find
(
" CPU "
))
!=
std
::
string
::
npos
){
value
.
erase
(
find_pos
,
5
);
}
value
.
erase
(
std
::
remove_if
(
value
.
begin
(),
value
.
end
(),
isspace
),
value
.
end
());
}
value
.
erase
(
std
::
remove_if
(
value
.
begin
(),
value
.
end
(),
isspace
),
value
.
end
());
if
(
is_amd
){
auto
end_itr
=
brand_str
.
rfind
(
"Processor"
);
value
=
brand_str
.
substr
(
find_pos
+
4
,
end_itr
-
4
);
}
}
return
value
;
...
...
@@ -1154,6 +1183,13 @@ namespace compass {
struct
cacheline
{
static
std
::
uint32_t
levels_available
(){
using
current_arch_t
=
ct
::
arch
::
type
;
return
compass
::
runtime
::
detail
::
size
::
cacheline
::
levels_available
(
current_arch_t
());
}
static
std
::
uint32_t
level
(
int
_lvl
){
using
current_arch_t
=
ct
::
arch
::
type
;
...
...
@@ -1164,6 +1200,13 @@ namespace compass {
struct
cache
{
static
std
::
uint32_t
levels_available
(){
using
current_arch_t
=
ct
::
arch
::
type
;
return
compass
::
runtime
::
detail
::
size
::
cache
::
levels_available
(
current_arch_t
());
}
static
std
::
uint32_t
level
(
int
_lvl
){
using
current_arch_t
=
ct
::
arch
::
type
;
...
...
Write
Preview
Markdown
is supported
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