~ubuntu-branches/ubuntu/vivid/mpich/vivid-proposed

« back to all changes in this revision

Viewing changes to src/pm/hydra/examples/print_cpus_allowed.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-04-01 20:24:20 UTC
  • mfrom: (5.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20140401202420-t5ey1ia2klt5dkq3
Tags: 3.1-4
* [c3e3398] Disable test_primitives, which is unreliable on some platforms.
            (Closes: #743047)
* [265a699] Add minimal autotest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
 
2
/*
 
3
 *
 
4
 *  (C) 2014 by Argonne National Laboratory.
 
5
 *      See COPYRIGHT in top-level directory.
 
6
 */
 
7
#define PATH_MAX 1000
 
8
 
 
9
#include "mpi.h"
 
10
#include <stdio.h>
 
11
 
 
12
int main(int argc, char **argv)
 
13
{
 
14
    int rank, size, namelen;
 
15
    FILE *fp;
 
16
    char path[PATH_MAX];
 
17
    char processor_name[MPI_MAX_PROCESSOR_NAME];
 
18
 
 
19
    MPI_Init(&argc, &argv);
 
20
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
21
 
 
22
    MPI_Get_processor_name(processor_name, &namelen);
 
23
 
 
24
    fp = popen("grep Cpus_allowed_list /proc/$$/status", "r");
 
25
 
 
26
    while (fgets(path, PATH_MAX, fp) != NULL) {
 
27
        printf("%s[%d]: %s", processor_name, rank, path);
 
28
    }
 
29
 
 
30
    pclose(fp);
 
31
 
 
32
    fflush(stdout);
 
33
 
 
34
    MPI_Finalize();
 
35
 
 
36
    return 0;
 
37
}