Removes system CPU measurement for Chrome build.
It does not work on Chrome Windows, and is anyway not needed for Chrome. Review URL: http://webrtc-codereview.appspot.com/243006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@902 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f15fbc379d
commit
c58ef08da2
@ -13,7 +13,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "cpu_wrapper.h"
|
#include "cpu_info.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -79,7 +79,7 @@ bool VideoProcessorImpl::Init() {
|
|||||||
// Init the encoder and decoder
|
// Init the encoder and decoder
|
||||||
WebRtc_UWord32 nbr_of_cores = 1;
|
WebRtc_UWord32 nbr_of_cores = 1;
|
||||||
if (!config_.use_single_core) {
|
if (!config_.use_single_core) {
|
||||||
nbr_of_cores = CpuWrapper::DetectNumberOfCores();
|
nbr_of_cores = CpuInfo::DetectNumberOfCores();
|
||||||
}
|
}
|
||||||
WebRtc_Word32 init_result =
|
WebRtc_Word32 init_result =
|
||||||
encoder_->InitEncode(&config_.codec_settings, nbr_of_cores,
|
encoder_->InitEncode(&config_.codec_settings, nbr_of_cores,
|
||||||
|
27
src/system_wrappers/interface/cpu_info.h
Normal file
27
src/system_wrappers/interface/cpu_info.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_
|
||||||
|
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
class CpuInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static WebRtc_UWord32 DetectNumberOfCores();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CpuInfo() {}
|
||||||
|
static WebRtc_UWord32 _numberOfCores;
|
||||||
|
};
|
||||||
|
} // namespace webrtc
|
||||||
|
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_INFO_H_
|
@ -17,8 +17,6 @@ namespace webrtc {
|
|||||||
class CpuWrapper
|
class CpuWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static WebRtc_UWord32 DetectNumberOfCores();
|
|
||||||
|
|
||||||
static CpuWrapper* CreateCpu();
|
static CpuWrapper* CreateCpu();
|
||||||
virtual ~CpuWrapper() {}
|
virtual ~CpuWrapper() {}
|
||||||
|
|
||||||
@ -42,10 +40,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CpuWrapper() {}
|
CpuWrapper() {}
|
||||||
|
|
||||||
private:
|
|
||||||
static WebRtc_UWord32 _numberOfCores;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_
|
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_WRAPPER_H_
|
||||||
|
@ -11,67 +11,18 @@
|
|||||||
#include "cpu_wrapper.h"
|
#include "cpu_wrapper.h"
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
|
||||||
#include "engine_configurations.h"
|
|
||||||
#include "cpu_windows.h"
|
#include "cpu_windows.h"
|
||||||
#elif defined(WEBRTC_MAC)
|
#elif defined(WEBRTC_MAC)
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include "cpu_mac.h"
|
#include "cpu_mac.h"
|
||||||
#elif defined(WEBRTC_MAC_INTEL)
|
#elif defined(WEBRTC_MAC_INTEL)
|
||||||
#include "cpu_mac.h"
|
#include "cpu_mac.h"
|
||||||
#elif defined(WEBRTC_ANDROID)
|
#elif defined(WEBRTC_ANDROID)
|
||||||
// Not implemented yet, might be possible to use Linux implementation
|
// Not implemented yet, might be possible to use Linux implementation
|
||||||
#else // defined(WEBRTC_LINUX)
|
#else // defined(WEBRTC_LINUX)
|
||||||
#include <sys/sysinfo.h>
|
|
||||||
#include "cpu_linux.h"
|
#include "cpu_linux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "trace.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
WebRtc_UWord32 CpuWrapper::_numberOfCores = 0;
|
|
||||||
|
|
||||||
WebRtc_UWord32 CpuWrapper::DetectNumberOfCores()
|
|
||||||
{
|
|
||||||
if (!_numberOfCores)
|
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
_numberOfCores = static_cast<WebRtc_UWord32>(si.dwNumberOfProcessors);
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
|
||||||
"Available number of cores:%d", _numberOfCores);
|
|
||||||
|
|
||||||
#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
|
|
||||||
_numberOfCores = get_nprocs();
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
|
||||||
"Available number of cores:%d", _numberOfCores);
|
|
||||||
|
|
||||||
#elif (defined(WEBRTC_MAC) || defined(WEBRTC_MAC_INTEL))
|
|
||||||
int name[] = {CTL_HW, HW_AVAILCPU};
|
|
||||||
int ncpu;
|
|
||||||
size_t size = sizeof(ncpu);
|
|
||||||
if(0 == sysctl(name, 2, &ncpu, &size, NULL, 0))
|
|
||||||
{
|
|
||||||
_numberOfCores = static_cast<WebRtc_UWord32>(ncpu);
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
|
||||||
"Available number of cores:%d", _numberOfCores);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceError, kTraceUtility, -1,
|
|
||||||
"Failed to get number of cores");
|
|
||||||
_numberOfCores = 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
WEBRTC_TRACE(kTraceWarning, kTraceUtility, -1,
|
|
||||||
"No function to get number of cores");
|
|
||||||
_numberOfCores = 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return _numberOfCores;
|
|
||||||
}
|
|
||||||
|
|
||||||
CpuWrapper* CpuWrapper::CreateCpu()
|
CpuWrapper* CpuWrapper::CreateCpu()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
22
src/system_wrappers/source/cpu_dummy.cc
Normal file
22
src/system_wrappers/source/cpu_dummy.cc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "cpu_wrapper.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
CpuWrapper* CpuWrapper::CreateCpu()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
72
src/system_wrappers/source/cpu_info.cc
Normal file
72
src/system_wrappers/source/cpu_info.cc
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cpu_info.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <Windows.h>
|
||||||
|
#elif defined(WEBRTC_MAC)
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#elif defined(WEBRTC_MAC_INTEL)
|
||||||
|
// Intentionally empty
|
||||||
|
#elif defined(WEBRTC_ANDROID)
|
||||||
|
// Not implemented yet, might be possible to use Linux implementation
|
||||||
|
#else // defined(WEBRTC_LINUX)
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
WebRtc_UWord32 CpuInfo::_numberOfCores = 0;
|
||||||
|
|
||||||
|
WebRtc_UWord32 CpuInfo::DetectNumberOfCores()
|
||||||
|
{
|
||||||
|
if (!_numberOfCores)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
_numberOfCores = static_cast<WebRtc_UWord32>(si.dwNumberOfProcessors);
|
||||||
|
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
||||||
|
"Available number of cores:%d", _numberOfCores);
|
||||||
|
|
||||||
|
#elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID)
|
||||||
|
_numberOfCores = get_nprocs();
|
||||||
|
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
||||||
|
"Available number of cores:%d", _numberOfCores);
|
||||||
|
|
||||||
|
#elif (defined(WEBRTC_MAC) || defined(WEBRTC_MAC_INTEL))
|
||||||
|
int name[] = {CTL_HW, HW_AVAILCPU};
|
||||||
|
int ncpu;
|
||||||
|
size_t size = sizeof(ncpu);
|
||||||
|
if(0 == sysctl(name, 2, &ncpu, &size, NULL, 0))
|
||||||
|
{
|
||||||
|
_numberOfCores = static_cast<WebRtc_UWord32>(ncpu);
|
||||||
|
WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1,
|
||||||
|
"Available number of cores:%d", _numberOfCores);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceUtility, -1,
|
||||||
|
"Failed to get number of cores");
|
||||||
|
_numberOfCores = 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
WEBRTC_TRACE(kTraceWarning, kTraceUtility, -1,
|
||||||
|
"No function to get number of cores");
|
||||||
|
_numberOfCores = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return _numberOfCores;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
@ -11,20 +11,22 @@
|
|||||||
#include "system_wrappers/interface/cpu_wrapper.h"
|
#include "system_wrappers/interface/cpu_wrapper.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "system_wrappers/interface/cpu_info.h"
|
||||||
#include "system_wrappers/interface/trace.h"
|
#include "system_wrappers/interface/trace.h"
|
||||||
|
|
||||||
|
using webrtc::CpuInfo;
|
||||||
using webrtc::CpuWrapper;
|
using webrtc::CpuWrapper;
|
||||||
using webrtc::Trace;
|
using webrtc::Trace;
|
||||||
|
|
||||||
// Only utilizes some of the cpu_wrapper.h code. Does not very anything except
|
// Only utilizes some of the cpu_info.h and cpu_wrapper.h code. Does not verify
|
||||||
// that it doesn't crash.
|
// anything except that it doesn't crash.
|
||||||
// TODO(kjellander): Improve this test so it verifies the implementation
|
// TODO(kjellander): Improve this test so it verifies the implementation
|
||||||
// executes as expected.
|
// executes as expected.
|
||||||
TEST(CpuWrapperTest, Usage) {
|
TEST(CpuWrapperTest, Usage) {
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
Trace::SetTraceFile("cpu_wrapper_unittest.txt");
|
Trace::SetTraceFile("cpu_wrapper_unittest.txt");
|
||||||
Trace::SetLevelFilter(webrtc::kTraceAll);
|
Trace::SetLevelFilter(webrtc::kTraceAll);
|
||||||
printf("Number of cores detected:%u\n", CpuWrapper::DetectNumberOfCores());
|
printf("Number of cores detected:%u\n", CpuInfo::DetectNumberOfCores());
|
||||||
CpuWrapper* cpu = CpuWrapper::CreateCpu();
|
CpuWrapper* cpu = CpuWrapper::CreateCpu();
|
||||||
WebRtc_UWord32 numCores;
|
WebRtc_UWord32 numCores;
|
||||||
WebRtc_UWord32* cores;
|
WebRtc_UWord32* cores;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
'../interface/aligned_malloc.h',
|
'../interface/aligned_malloc.h',
|
||||||
'../interface/atomic32_wrapper.h',
|
'../interface/atomic32_wrapper.h',
|
||||||
'../interface/condition_variable_wrapper.h',
|
'../interface/condition_variable_wrapper.h',
|
||||||
|
'../interface/cpu_info.h',
|
||||||
'../interface/cpu_wrapper.h',
|
'../interface/cpu_wrapper.h',
|
||||||
'../interface/cpu_features_wrapper.h',
|
'../interface/cpu_features_wrapper.h',
|
||||||
'../interface/critical_section_wrapper.h',
|
'../interface/critical_section_wrapper.h',
|
||||||
@ -57,6 +58,8 @@
|
|||||||
'condition_variable_posix.h',
|
'condition_variable_posix.h',
|
||||||
'condition_variable_windows.h',
|
'condition_variable_windows.h',
|
||||||
'cpu.cc',
|
'cpu.cc',
|
||||||
|
'cpu_dummy.cc',
|
||||||
|
'cpu_info.cc',
|
||||||
'cpu_linux.h',
|
'cpu_linux.h',
|
||||||
'cpu_mac.h',
|
'cpu_mac.h',
|
||||||
'cpu_windows.h',
|
'cpu_windows.h',
|
||||||
@ -141,6 +144,15 @@
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
['build_with_chromium==1', {
|
||||||
|
'sources!': [
|
||||||
|
'cpu.cc',
|
||||||
|
],
|
||||||
|
}, {
|
||||||
|
'sources!': [
|
||||||
|
'cpu_dummy.cc',
|
||||||
|
],
|
||||||
|
}]
|
||||||
] # conditions
|
] # conditions
|
||||||
},
|
},
|
||||||
], # targets
|
], # targets
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "vie_shared_data.h"
|
#include "vie_shared_data.h"
|
||||||
#include "vie_defines.h"
|
#include "vie_defines.h"
|
||||||
|
|
||||||
#include "cpu_wrapper.h"
|
#include "cpu_info.h"
|
||||||
#include "critical_section_wrapper.h"
|
#include "critical_section_wrapper.h"
|
||||||
#include "process_thread.h"
|
#include "process_thread.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
@ -30,7 +30,7 @@ ViESharedData::ViESharedData()
|
|||||||
: _instanceId(++_instanceCounter),
|
: _instanceId(++_instanceCounter),
|
||||||
_apiCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_apiCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_isInitialized(false),
|
_isInitialized(false),
|
||||||
_numberOfCores(CpuWrapper::DetectNumberOfCores()),
|
_numberOfCores(CpuInfo::DetectNumberOfCores()),
|
||||||
_viePerformanceMonitor(ViEPerformanceMonitor(_instanceId)),
|
_viePerformanceMonitor(ViEPerformanceMonitor(_instanceId)),
|
||||||
_channelManager(*new ViEChannelManager(_instanceId, _numberOfCores,
|
_channelManager(*new ViEChannelManager(_instanceId, _numberOfCores,
|
||||||
_viePerformanceMonitor)),
|
_viePerformanceMonitor)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user