예제 #1
0
파일: libnuma.c 프로젝트: Agobin/chapel
qthread_worker_id_t INTERNAL guess_num_workers_per_shep(qthread_shepherd_id_t nshepherds)
{                                      /*{{{ */
    size_t       cpu_count = 1;
    unsigned int guess     = 1;

    qthread_debug(AFFINITY_CALLS, "guessing workers for %i shepherds\n",
                  (int)nshepherds);
#ifdef HAVE_NUMA_NUM_THREAD_CPUS
    /* note: not numa_num_configured_cpus(), just in case an
     * artificial limit has been imposed. */
    cpu_count = numa_num_thread_cpus();
    qthread_debug(AFFINITY_DETAILS, "numa_num_thread_cpus returned %i\n",
                  nshepherds);
#elif defined(HAVE_NUMA_BITMASK_NBYTES)
    cpu_count = 0;
    for (size_t b = 0; b < numa_bitmask_nbytes(numa_all_cpus_ptr) * 8; b++) {
        cpu_count += numa_bitmask_isbitset(numa_all_cpus_ptr, b);
    }
    qthread_debug(AFFINITY_DETAILS,
                  "after checking through the all_cpus_ptr, I counted %i cpus\n",
                  (int)cpu_count);
#else  /* ifdef HAVE_NUMA_NUM_THREAD_CPUS */
    cpu_count = numa_max_node() + 1;
    qthread_debug(AFFINITY_DETAILS, "numa_max_node() returned %i\n", nshepherds);
#endif  /* ifdef HAVE_NUMA_NUM_THREAD_CPUS */
    guess = cpu_count / nshepherds;
    if (guess == 0) {
        guess = 1;
    }
    qthread_debug(AFFINITY_DETAILS, "guessing %i workers per shepherd\n",
                  (int)guess);
    return guess;
}                                      /*}}} */
예제 #2
0
파일: cpu.c 프로젝트: aclements/thesis
// XXX Should be CPU_GetSetCount or maybe CPUSet_Count
int
CPU_GetCount(CPU_Set_t *cs)
{
        int bit, bits = numa_bitmask_nbytes(cs) * 8, count = 0;
        for (bit = 0; bit <= bits; bit++)
                if (numa_bitmask_isbitset(cs, bit))
                        count++;
        return count;
}
예제 #3
0
파일: cpu.c 프로젝트: aclements/thesis
static int
cpuSetMax(CPU_Set_t *cs)
{
        int bit, bits = numa_bitmask_nbytes(cs) * 8;
        for (bit = bits - 1; bit >= 0; bit--)
                if (numa_bitmask_isbitset(cs, bit))
                        break;
        return bit + 1;
}
예제 #4
0
파일: common.cpp 프로젝트: zheng-da/FlashX
int numa_get_mem_node()
{
	struct bitmask *bmp = numa_get_membind();
	int nbytes = numa_bitmask_nbytes(bmp);
	int num_nodes = 0;
	int node_id = -1;
	int i;
	for (i = 0; i < nbytes * 8; i++)
		if (numa_bitmask_isbitset(bmp, i)) {
			num_nodes++;
			node_id = i;
		}
	assert(num_nodes == 1);
	return node_id;
}