File: helloworld.c

package info (click to toggle)
mpi4py 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,672 kB
  • ctags: 7,083
  • sloc: python: 15,291; ansic: 7,099; makefile: 711; f90: 158; sh: 156; cpp: 121
file content (27 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#define MPICH_SKIP_MPICXX 1
#define OMPI_SKIP_MPICXX  1
#include <mpi.h>
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif
extern void sayhello(MPI_Comm);
#ifdef __cplusplus
}
#endif

void sayhello(MPI_Comm comm) {
  int size, rank;
  char pname[MPI_MAX_PROCESSOR_NAME]; int len;
  if (comm == MPI_COMM_NULL) {
    printf("You passed MPI_COMM_NULL !!!\n");
    return;
  }
  MPI_Comm_size(comm, &size);
  MPI_Comm_rank(comm, &rank);
  MPI_Get_processor_name(pname, &len);
  pname[len] = 0;
  printf("Hello, World! I am process %d of %d on %s.\n",
         rank, size, pname);
}