Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
0db04cbb
Commit
0db04cbb
authored
14 years ago
by
Mark Palange (Mani)
Browse files
Options
Downloads
Patches
Plain Diff
EXT-3780 WIP Adding newline to linux getCPUFeatureDesc output
parent
ab6d5044
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llcommon/llprocessor.cpp
+34
-2
34 additions, 2 deletions
indra/llcommon/llprocessor.cpp
indra/llcommon/llprocessor.h
+0
-161
0 additions, 161 deletions
indra/llcommon/llprocessor.h
indra/llcommon/llsys.cpp
+2
-72
2 additions, 72 deletions
indra/llcommon/llsys.cpp
with
36 additions
and
235 deletions
indra/llcommon/llprocessor.cpp
+
34
−
2
View file @
0db04cbb
...
...
@@ -240,7 +240,9 @@ class LLProcessorInfoImpl
std
::
string
getCPUFamilyName
()
const
{
return
getInfo
(
eFamilyName
,
"Unknown"
).
asString
();
}
std
::
string
getCPUBrandName
()
const
{
return
getInfo
(
eBrandName
,
"Unknown"
).
asString
();
}
std
::
string
getCPUFeatureDescription
()
const
// This is virtual to support a different linux format.
// *NOTE:Mani - I didn't want to screw up server use of this data...
virtual
std
::
string
getCPUFeatureDescription
()
const
{
std
::
ostringstream
out
;
out
<<
std
::
endl
<<
std
::
endl
;
...
...
@@ -671,6 +673,7 @@ class LLProcessorInfoDarwinImpl : public LLProcessorInfoImpl
};
#elif LL_LINUX
const
char
CPUINFO_FILE
[]
=
"/proc/cpuinfo"
;
class
LLProcessorInfoLinuxImpl
:
public
LLProcessorInfoImpl
{
...
...
@@ -820,6 +823,33 @@ class LLProcessorInfoLinuxImpl : public LLProcessorInfoImpl
# endif // LL_X86
}
std
::
string
getCPUFeatureDescription
()
const
{
std
::
ostringstream
s
;
// *NOTE:Mani - This is for linux only.
LLFILE
*
cpuinfo
=
LLFile
::
fopen
(
CPUINFO_FILE
,
"rb"
);
if
(
cpuinfo
)
{
char
line
[
MAX_STRING
];
memset
(
line
,
0
,
MAX_STRING
);
while
(
fgets
(
line
,
MAX_STRING
,
cpuinfo
))
{
line
[
strlen
(
line
)
-
1
]
=
' '
;
s
<<
line
;
s
<<
std
::
endl
;
}
fclose
(
cpuinfo
);
s
<<
std
::
endl
;
}
else
{
s
<<
"Unable to collect processor information"
<<
std
::
endl
;
}
return
s
.
str
();
}
};
...
...
@@ -839,11 +869,13 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL)
static
LLProcessorInfoDarwinImpl
the_impl
;
mImpl
=
&
the_impl
;
#else
#error "Unimplemented"
static
LLProcessorInfoLinuxImpl
the_impl
;
mImpl
=
&
the_impl
;
#endif // LL_MSVC
}
}
LLProcessorInfo
::~
LLProcessorInfo
()
{}
F64
LLProcessorInfo
::
getCPUFrequency
()
const
{
return
mImpl
->
getCPUFrequency
();
}
bool
LLProcessorInfo
::
hasSSE
()
const
{
return
mImpl
->
hasSSE
();
}
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llprocessor.h
+
0
−
161
View file @
0db04cbb
...
...
@@ -52,165 +52,4 @@ class LLProcessorInfo
LLProcessorInfoImpl
*
mImpl
;
};
# if 0
// Author: Benjamin Jurke
// File history: 27.02.2002 File created.
///////////////////////////////////////////
// Options:
///////////
#if LL_WINDOWS
#define PROCESSOR_FREQUENCY_MEASURE_AVAILABLE
#endif
#if LL_MSVC && _M_X64
# define LL_X86_64 1
# define LL_X86 1
#elif LL_MSVC && _M_IX86
# define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1
# define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) )
# define LL_X86 1
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
# define LL_PPC 1
#endif
struct
ProcessorExtensions
{
bool
FPU_FloatingPointUnit
;
bool
VME_Virtual8086ModeEnhancements
;
bool
DE_DebuggingExtensions
;
bool
PSE_PageSizeExtensions
;
bool
TSC_TimeStampCounter
;
bool
MSR_ModelSpecificRegisters
;
bool
PAE_PhysicalAddressExtension
;
bool
MCE_MachineCheckException
;
bool
CX8_COMPXCHG8B_Instruction
;
bool
APIC_AdvancedProgrammableInterruptController
;
unsigned
int
APIC_ID
;
bool
SEP_FastSystemCall
;
bool
MTRR_MemoryTypeRangeRegisters
;
bool
PGE_PTE_GlobalFlag
;
bool
MCA_MachineCheckArchitecture
;
bool
CMOV_ConditionalMoveAndCompareInstructions
;
bool
FGPAT_PageAttributeTable
;
bool
PSE36_36bitPageSizeExtension
;
bool
PN_ProcessorSerialNumber
;
bool
CLFSH_CFLUSH_Instruction
;
unsigned
int
CLFLUSH_InstructionCacheLineSize
;
bool
DS_DebugStore
;
bool
ACPI_ThermalMonitorAndClockControl
;
bool
EMMX_MultimediaExtensions
;
bool
MMX_MultimediaExtensions
;
bool
FXSR_FastStreamingSIMD_ExtensionsSaveRestore
;
bool
SSE_StreamingSIMD_Extensions
;
bool
SSE2_StreamingSIMD2_Extensions
;
bool
Altivec_Extensions
;
bool
SS_SelfSnoop
;
bool
HT_HyperThreading
;
unsigned
int
HT_HyterThreadingSiblings
;
bool
TM_ThermalMonitor
;
bool
IA64_Intel64BitArchitecture
;
bool
_3DNOW_InstructionExtensions
;
bool
_E3DNOW_InstructionExtensions
;
bool
AA64_AMD64BitArchitecture
;
};
struct
ProcessorCache
{
bool
bPresent
;
char
strSize
[
32
];
/* Flawfinder: ignore */
unsigned
int
uiAssociativeWays
;
unsigned
int
uiLineSize
;
bool
bSectored
;
char
strCache
[
128
];
/* Flawfinder: ignore */
};
struct
ProcessorL1Cache
{
ProcessorCache
Instruction
;
ProcessorCache
Data
;
};
struct
ProcessorTLB
{
bool
bPresent
;
char
strPageSize
[
32
];
/* Flawfinder: ignore */
unsigned
int
uiAssociativeWays
;
unsigned
int
uiEntries
;
char
strTLB
[
128
];
/* Flawfinder: ignore */
};
struct
ProcessorInfo
{
char
strVendor
[
16
];
/* Flawfinder: ignore */
unsigned
int
uiFamily
;
unsigned
int
uiExtendedFamily
;
char
strFamily
[
64
];
/* Flawfinder: ignore */
unsigned
int
uiModel
;
unsigned
int
uiExtendedModel
;
char
strModel
[
128
];
/* Flawfinder: ignore */
unsigned
int
uiStepping
;
unsigned
int
uiType
;
char
strType
[
64
];
/* Flawfinder: ignore */
unsigned
int
uiBrandID
;
char
strBrandID
[
64
];
/* Flawfinder: ignore */
char
strProcessorSerial
[
64
];
/* Flawfinder: ignore */
unsigned
long
MaxSupportedLevel
;
unsigned
long
MaxSupportedExtendedLevel
;
ProcessorExtensions
_Ext
;
ProcessorL1Cache
_L1
;
ProcessorCache
_L2
;
ProcessorCache
_L3
;
ProcessorCache
_Trace
;
ProcessorTLB
_Instruction
;
ProcessorTLB
_Data
;
};
// CProcessor
// ==========
// Class for detecting the processor name, type and available
// extensions as long as it's speed.
/////////////////////////////////////////////////////////////
class
CProcessor
{
// Constructor / Destructor:
////////////////////////////
public:
CProcessor
();
// Private vars:
////////////////
private:
F64
uqwFrequency
;
char
strCPUName
[
128
];
/* Flawfinder: ignore */
ProcessorInfo
CPUInfo
;
// Private functions:
/////////////////////
private:
bool
AnalyzeIntelProcessor
();
bool
AnalyzeAMDProcessor
();
bool
AnalyzeUnknownProcessor
();
bool
CheckCPUIDPresence
();
void
DecodeProcessorConfiguration
(
unsigned
int
cfg
);
void
TranslateProcessorConfiguration
();
void
GetStandardProcessorConfiguration
();
void
GetStandardProcessorExtensions
();
// Public functions:
////////////////////
public:
F64
GetCPUFrequency
(
unsigned
int
uiMeasureMSecs
);
const
ProcessorInfo
*
GetCPUInfo
();
bool
CPUInfoToText
(
char
*
strBuffer
,
unsigned
int
uiMaxLen
);
bool
WriteInfoTextFile
(
const
std
::
string
&
strFilename
);
};
#endif // 0
#endif // LLPROCESSOR_H
This diff is collapsed.
Click to expand it.
indra/llcommon/llsys.cpp
+
2
−
72
View file @
0db04cbb
...
...
@@ -58,7 +58,6 @@
# include <unistd.h>
# include <sys/sysinfo.h>
const
char
MEMINFO_FILE
[]
=
"/proc/meminfo"
;
const
char
CPUINFO_FILE
[]
=
"/proc/cpuinfo"
;
#elif LL_SOLARIS
# include <stdio.h>
# include <unistd.h>
...
...
@@ -518,65 +517,16 @@ LLCPUInfo::LLCPUInfo()
mHasSSE
=
proc
.
hasSSE
();
mHasSSE2
=
proc
.
hasSSE2
();
mHasAltivec
=
proc
.
hasAltivec
();
mCPUM
h
z
=
(
F64
)(
proc
.
getCPUFrequency
()
/
1000000.0
);
mCPUM
H
z
=
(
F64
)(
proc
.
getCPUFrequency
()
/
1000000.0
);
mFamily
=
proc
.
getCPUFamilyName
();
mCPUString
=
"Unknown"
;
#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
out
<<
proc
.
getCPUBrandName
();
if
(
200
<
mCPUMHz
&&
mCPUMHz
<
10000
)
// *NOTE: cpu speed is often way wrong, do a sanity check
{
out
<<
" ("
<<
mCPUMHz
<<
" MHz)"
;
}
mCPUString
=
out
.
str
();
#elif LL_LINUX
std
::
map
<
std
::
string
,
std
::
string
>
cpuinfo
;
LLFILE
*
cpuinfo_fp
=
LLFile
::
fopen
(
CPUINFO_FILE
,
"rb"
);
if
(
cpuinfo_fp
)
{
char
line
[
MAX_STRING
];
memset
(
line
,
0
,
MAX_STRING
);
while
(
fgets
(
line
,
MAX_STRING
,
cpuinfo_fp
))
{
// /proc/cpuinfo on Linux looks like:
// name\t*: value\n
char
*
tabspot
=
strchr
(
line
,
'\t'
);
if
(
tabspot
==
NULL
)
continue
;
char
*
colspot
=
strchr
(
tabspot
,
':'
);
if
(
colspot
==
NULL
)
continue
;
char
*
spacespot
=
strchr
(
colspot
,
' '
);
if
(
spacespot
==
NULL
)
continue
;
char
*
nlspot
=
strchr
(
line
,
'\n'
);
if
(
nlspot
==
NULL
)
nlspot
=
line
+
strlen
(
line
);
// Fallback to terminating NUL
std
::
string
linename
(
line
,
tabspot
);
std
::
string
llinename
(
linename
);
LLStringUtil
::
toLower
(
llinename
);
std
::
string
lineval
(
spacespot
+
1
,
nlspot
);
cpuinfo
[
llinename
]
=
lineval
;
}
fclose
(
cpuinfo_fp
);
}
# if LL_X86
std
::
string
flags
=
" "
+
cpuinfo
[
"flags"
]
+
" "
;
LLStringUtil
::
toLower
(
flags
);
mHasSSE
=
(
flags
.
find
(
" sse "
)
!=
std
::
string
::
npos
);
mHasSSE2
=
(
flags
.
find
(
" sse2 "
)
!=
std
::
string
::
npos
);
F64
mhz
;
if
(
LLStringUtil
::
convertToF64
(
cpuinfo
[
"cpu mhz"
],
mhz
)
&&
200.0
<
mhz
&&
mhz
<
10000.0
)
{
mCPUMHz
=
(
F64
)(
mhz
);
}
if
(
!
cpuinfo
[
"model name"
].
empty
())
mCPUString
=
cpuinfo
[
"model name"
];
# endif // LL_X86
#endif // LL_LINUX
}
bool
LLCPUInfo
::
hasAltivec
()
const
...
...
@@ -606,29 +556,9 @@ std::string LLCPUInfo::getCPUString() const
void
LLCPUInfo
::
stream
(
std
::
ostream
&
s
)
const
{
#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
// gather machine information.
s
<<
LLProcessorInfo
().
getCPUFeatureDescription
();
#else
// *NOTE: This works on linux. What will it do on other systems?
LLFILE
*
cpuinfo
=
LLFile
::
fopen
(
CPUINFO_FILE
,
"rb"
);
if
(
cpuinfo
)
{
char
line
[
MAX_STRING
];
memset
(
line
,
0
,
MAX_STRING
);
while
(
fgets
(
line
,
MAX_STRING
,
cpuinfo
))
{
line
[
strlen
(
line
)
-
1
]
=
' '
;
s
<<
line
;
}
fclose
(
cpuinfo
);
s
<<
std
::
endl
;
}
else
{
s
<<
"Unable to collect processor information"
<<
std
::
endl
;
}
#endif
// These are interesting as they reflect our internal view of the
// CPU's attributes regardless of platform
s
<<
"->mHasSSE: "
<<
(
U32
)
mHasSSE
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment