1
1

Add a test program to help diagnose binding issues

Этот коммит содержится в:
Ralph Castain 2016-06-23 06:26:44 -07:00
родитель 2992d6d238
Коммит 380cc8f040
2 изменённых файлов: 62 добавлений и 1 удалений

Просмотреть файл

@ -1,4 +1,4 @@
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster early_abort debugger singleton_client_server intercomm_create spawn_tree init-exit77 mpi_info info_spawn server client paccept pconnect ring hello.sapp
PROGS = mpi_no_op mpi_barrier hello hello_nodename abort multi_abort simple_spawn concurrent_spawn spawn_multiple mpi_spin delayed_abort loop_spawn loop_child bad_exit pubsub hello_barrier segv accept connect hello_output hello_show_help crisscross read_write ziatest slave reduce-hang ziaprobe ziatest bcast_loop parallel_w8 parallel_w64 parallel_r8 parallel_r64 sio sendrecv_blaster early_abort debugger singleton_client_server intercomm_create spawn_tree init-exit77 mpi_info info_spawn server client paccept pconnect ring hello.sapp binding
all: $(PROGS)

61
orte/test/mpi/binding.c Обычный файл
Просмотреть файл

@ -0,0 +1,61 @@
/* -*- C -*-
*
* $HEADER$
*
* The most basic of MPI applications
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
#include "opal/mca/hwloc/hwloc.h"
#include "mpi.h"
#include "orte/util/proc_info.h"
int main(int argc, char* argv[])
{
int rank, size, rc;
hwloc_cpuset_t cpus;
char *bindings;
cpu_set_t *mask;
int nrcpus, c;
size_t csize;
char hostname[1024];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
gethostname(hostname, 1024);
cpus = hwloc_bitmap_alloc();
rc = hwloc_get_cpubind(opal_hwloc_topology, cpus, HWLOC_CPUBIND_PROCESS);
hwloc_bitmap_list_asprintf(&bindings, cpus);
printf("[%s;%d] Hello, World, I am %d of %d [%d local peers]: get_cpubind: %d bitmap %s\n",
hostname, (int)getpid(), rank, size, orte_process_info.num_local_peers, rc,
(NULL == bindings) ? "NULL" : bindings);
nrcpus = sysconf(_SC_NPROCESSORS_ONLN);
mask = CPU_ALLOC(nrcpus);
csize = CPU_ALLOC_SIZE(nrcpus);
CPU_ZERO_S(csize, mask);
if ( sched_getaffinity(0, csize, mask) == -1 ) {
CPU_FREE(mask);
perror("sched_getaffinity");
return -1;
}
for ( c = 0; c < nrcpus; c++ ) {
if ( CPU_ISSET_S(c, csize, mask) ) {
printf("[%s:%d] CPU %d is set\n", hostname, (int)getpid(), c);
}
}
CPU_FREE(mask);
MPI_Finalize();
return 0;
}