root/orte/test/mpi/hello.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /* -*- C -*-
   2  *
   3  * $HEADER$
   4  *
   5  * The most basic of MPI applications
   6  */
   7 
   8 #include <stdio.h>
   9 #include "opal/mca/hwloc/base/base.h"
  10 #include "mpi.h"
  11 
  12 #include "orte/util/proc_info.h"
  13 
  14 int main(int argc, char* argv[])
  15 {
  16     int rank, size, rc;
  17     hwloc_cpuset_t cpus;
  18     char *bindings = NULL;
  19     pid_t pid;
  20 
  21     MPI_Init(&argc, &argv);
  22     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  23     MPI_Comm_size(MPI_COMM_WORLD, &size);
  24     pid = getpid();
  25 
  26     printf("[%lu] Rank %d: getting topology\n", (unsigned long)pid, rank);
  27     fflush(stdout);
  28     if (OPAL_SUCCESS == opal_hwloc_base_get_topology()) {
  29         cpus = hwloc_bitmap_alloc();
  30         rc = hwloc_get_cpubind(opal_hwloc_topology, cpus, HWLOC_CPUBIND_PROCESS);
  31         hwloc_bitmap_list_asprintf(&bindings, cpus);
  32     }
  33 
  34     printf("Hello, World, I am %d of %d [%d local peers]: get_cpubind: %d bitmap %s\n",
  35            rank, size, orte_process_info.num_local_peers, rc,
  36            (NULL == bindings) ? "NULL" : bindings);
  37 
  38     MPI_Finalize();
  39     return 0;
  40 }

/* [<][>][^][v][top][bottom][index][help] */