File: test_malloc_group.c

package info (click to toggle)
armci-mpi 0.0~git20160222-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,756 kB
  • sloc: ansic: 12,698; sh: 229; makefile: 53; fortran: 44
file content (59 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download | duplicates (6)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (C) 2010. See COPYRIGHT in top-level directory.
 */

#include <stdio.h>
#include <stdlib.h>

#include <armci.h>
#include <armcix.h>

#define PART_SIZE 1
#define DATA_SZ   100*sizeof(int)

int main(int argc, char **argv) {
  int          me, nproc, grp_me, grp_nproc;
  ARMCI_Group  g_world, g_new;
  void       **base_ptrs;

  MPI_Init(&argc, &argv);
  ARMCI_Init();

  MPI_Comm_rank(MPI_COMM_WORLD, &me);
  MPI_Comm_size(MPI_COMM_WORLD, &nproc);

  base_ptrs = malloc(sizeof(void*)*nproc);

  if (me == 0) printf("ARMCI Group test starting on %d procs\n", nproc);

  ARMCI_Group_get_world(&g_world);
  
  if (me == 0) printf(" + Creating odd/even groups\n");

  ARMCIX_Group_split(&g_world, me%2, me, &g_new);

  ARMCI_Group_rank(&g_new, &grp_me);
  ARMCI_Group_size(&g_new, &grp_nproc);

  if (me == 0) printf(" + Performing group allocation\n");
  ARMCI_Malloc_group(base_ptrs, DATA_SZ, &g_new);
  ARMCI_Barrier();

  if (me == 0) printf(" + Freeing group allocation\n");

  ARMCI_Free_group(base_ptrs[grp_me], &g_new);
  ARMCI_Barrier();

  if (me == 0) printf(" + Freeing group\n");

  ARMCI_Group_free(&g_new);

  if (me == 0) printf(" + done\n");

  free(base_ptrs);

  ARMCI_Finalize();
  MPI_Finalize();

  return 0;
}