Ejemplo n.º 1
0
WELS_THREAD_ERROR_CODE    WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* pInfo) {
#ifdef ANDROID_NDK
  pInfo->ProcessorCount = android_getCpuCount();
  return WELS_THREAD_ERROR_OK;
#elif defined(LINUX)

  cpu_set_t cpuset;

  CPU_ZERO (&cpuset);

  if (!sched_getaffinity (0, sizeof (cpuset), &cpuset))
    pInfo->ProcessorCount = CPU_COUNT (&cpuset);
  else
    pInfo->ProcessorCount = 1;

  return WELS_THREAD_ERROR_OK;

#else

  size_t len = sizeof (pInfo->ProcessorCount);

  if (sysctlbyname (HW_NCPU_NAME, &pInfo->ProcessorCount, &len, NULL, 0) == -1)
    pInfo->ProcessorCount = 1;

  return WELS_THREAD_ERROR_OK;

#endif//LINUX
}
Ejemplo n.º 2
0
int CAndroidFeatures::GetCPUCount()
{
  static int count = -1;

  if (count == -1)
  {
    count = android_getCpuCount();
  }
  return count;
}
Ejemplo n.º 3
0
static bool isChangeFPSFun() {
    if( !hasCalled ) {
        if( android_getCpuCount() > 4 ) {
            isChangeFPS = true;
        }
        else {
            isChangeFPS = false;
        }
        hasCalled = true;
    }
}
Ejemplo n.º 4
0
unsigned int system_hardware_threads( void )
{
#if FOUNDATION_PLATFORM_APPLE
	return _system_process_info_processor_count();
#elif FOUNDATION_PLATFORM_ANDROID
	return android_getCpuCount();
#else
	cpu_set_t prevmask, testmask;
	CPU_ZERO( &prevmask );
	CPU_ZERO( &testmask );
	sched_getaffinity( 0, sizeof( prevmask ), &prevmask ); //Get current mask
	sched_setaffinity( 0, sizeof( testmask ), &testmask ); //Set zero mask
	sched_getaffinity( 0, sizeof( testmask ), &testmask ); //Get mask for all CPUs
	sched_setaffinity( 0, sizeof( prevmask ), &prevmask ); //Reset current mask
	unsigned int num = CPU_COUNT( &testmask );
	return ( num > 1 ? num : 1 );
#endif
}
Ejemplo n.º 5
0
 jint Java_ws_websca_benchscaw_MainActivity_getCpuCount( JNIEnv* env,
         jobject thiz )
 {
     return (jint)android_getCpuCount();
 }
Ejemplo n.º 6
0
ThrdCnt SysInfo::ThreadCount()
{
    return C_FCAST<u32>(android_getCpuCount());
}
Ejemplo n.º 7
0
u32 SysInfo::CoreCount()
{
    return C_FCAST<u32>(android_getCpuCount());
}
Ejemplo n.º 8
0
Archivo: hw.c Proyecto: yoanlcq/FATE
size_t fe_hw_get_cpu_count(void) {
    return android_getCpuCount();
}
Ejemplo n.º 9
0
ParticleEngine::ParticleEngine(uint max_part_nbr, bool isAuto, uint threadNb) :
		m_hasFailed(false), m_isAuto(isAuto) {
	LOGI("Engine initialization : %d particles\n", max_part_nbr);

#ifdef ANDROID
	LOGI("Cpu count : %d\n", android_getCpuCount());
#endif
	m_threadNb = threadNb;
#ifdef ANDROID
	if (threadNb == 0)
	m_threadNb = android_getCpuCount() - 1;
#endif

	if (m_threadNb < 1)
		m_threadNb = 1;

	if (max_part_nbr < m_threadNb) {
		max_part_nbr = m_threadNb;
	}
	max_part_nbr -= max_part_nbr % m_threadNb;

	m_threads = new (std::nothrow) pthread_t[m_threadNb];
	m_args = new (std::nothrow) ThreadArg[m_threadNb];
	if (m_threads == 0 || m_args == 0) {
		LOGE("Cannot allocate %d threads.\n", m_threadNb);
		// exceptions disabled
		m_hasFailed = true;
		m_threadNb = 0;
		return;
		//throw EngineException(MEM_ALLOC_THREAD_ERROR_MSG);
	}
	m_part_nbr = m_isAuto ? 1000 : max_part_nbr;
	m_max_part_nbr = max_part_nbr;
	m_gravity = GRAVITY;
	m_pos.x = 0;
	m_pos.y = GROUND_Y;
	m_pos.z = 0;
	m_user.x = 0;
	m_user.y = 0;
	m_user.z = 0;
	m_frameNb = 0;
	m_emit = true;
	m_timeSlept = 0;
	m_pause = true;
	m_randomCursor = -LIMIT_Y;
	m_randomSpeed = 0;

	m_hasWave = false;

	initFunctions();

	if (m_hasFailed = initParticles()) {
		m_threadNb = 0;
		return;
	}

	for (unsigned int i = 0; i < m_threadNb; ++i) {
		m_args[i].die = false;
		m_args[i].id = i;
		pthread_mutex_init(&m_args[i].mutex, 0);
		pthread_mutex_lock(&m_args[i].mutex);
		m_args[i].paused = true;
		m_args[i].engine = this;
		pthread_create(m_threads + i, 0, threadFunc, m_args + i);
	}
	LOGI("Engine Loaded\n");
}