Commit 15aec608 authored by Kenneth Raffenetti's avatar Kenneth Raffenetti Committed by Pavan Balaji
Browse files

example program to display processor affinity



Add a program in the hydra examples directory for use with the hydra
binding/mapping options. This program will print out which CPUs it
is allowed to run on according to the OS.

Refs #1858
Signed-off-by: Pavan Balaji's avatarPavan Balaji <balaji@mcs.anl.gov>
parent bec02c2a
#define PATH_MAX 1000
#include "mpi.h"
#include <stdio.h>
int main(int argc, char **argv)
{
int rank, size, namelen;
FILE *fp;
char path[PATH_MAX];
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Get_processor_name(processor_name,&namelen);
fp = popen("grep Cpus_allowed_list /proc/$$/status", "r");
while (fgets(path, PATH_MAX, fp) != NULL) {
printf("%s[%d]: %s", processor_name, rank, path);
}
pclose(fp);
fflush(stdout);
MPI_Finalize();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment