31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 int isched_topo_init(
void)
39 int isched_topo_world_size()
41 hwloc_obj_t obj = hwloc_get_obj_by_type(
topology, HWLOC_OBJ_MACHINE, 0 );
42 return hwloc_get_nbobjs_inside_cpuset_by_type(
topology, obj->cpuset, HWLOC_OBJ_CORE);
51 int main(
int argc,
char *argv[] )
55 char procname[BUF_MAX];
58 int world_size, world_rank;
59 int intra_size, intra_rank;
60 int nbthread, intra_nbthread;
62 MPI_Init( &argc, &argv );
63 MPI_Comm_size( MPI_COMM_WORLD, &world_size );
64 MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
77 rc = gethostname(procname, BUF_MAX-1);
78 procname[BUF_MAX-1] =
'\0';
79 len = strlen( procname );
85 for (i = 0; i < len; i++) {
86 color = color*256*
sizeof(char) + procname[i];
92 MPI_Comm_split( MPI_COMM_WORLD, color, key, &intra_comm );
93 MPI_Comm_size( intra_comm, &intra_size );
94 MPI_Comm_rank( intra_comm, &intra_rank );
102 nbthread = isched_topo_world_size();
104 intra_nbthread = nbthread / intra_size;
106 intra_nbthread = (intra_nbthread < 1) ? 1 : intra_nbthread;
109 if ( world_rank == 0 ) {
110 printf(
" Number of MPI processes: %d\n"
111 " Number of nodes: %d\n"
112 " Number of cores per node: %d\n"
113 " Number of cores per process: %d\n",
114 world_size, world_size / intra_size,
115 nbthread, intra_nbthread );
122 char corelists[2*BUF_MAX];
124 rc = sprintf( c,
"[%2d - %s] :", world_rank, procname );
126 for(i=0; i<intra_nbthread; i++) {
127 rc = sprintf( c,
"%2d ", intra_nbthread * intra_rank + i );
130 printf(
"%s\n", corelists );
static hwloc_topology_t topology