File: simplelock.c

package info (click to toggle)
ga 5.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,472 kB
  • sloc: ansic: 192,963; fortran: 53,761; f90: 11,218; cpp: 5,784; makefile: 2,248; sh: 1,945; python: 1,734; perl: 534; csh: 134; asm: 106
file content (74 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download | duplicates (9)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#if HAVE_CONFIG_H
#   include "config.h"
#endif

#if HAVE_STDIO_H
#   include <stdio.h>
#endif
#if HAVE_STDLIB_H
#   include <stdlib.h>
#endif
#if HAVE_ASSERT_H
#   include <assert.h>
#endif
#if HAVE_UNISTD_H
#   include <unistd.h>
#endif

#include "armci.h"
#include "message.h"

int me, nproc;
extern void armcill_lock(int, int);
extern void armcill_unlock(int, int);


void test_lock()
{
  int i, mut;
  if (me == 0) {
    printf("\n");
  }
  for (mut = 0; mut < 16; mut++)
    for (i = 0; i < nproc; i++) {
#if FIXME_THESE_ARE_NOT_DEFINED_FOR_PORTALS
      armcill_lock(mut, i);
      armcill_unlock(mut, i);
#endif
      ARMCI_Barrier();
      if (me == 0) {
        printf(".");
        fflush(stdout);
      }
      ARMCI_Barrier();
    }
}


int main(int argc, char *argv[])
{
  armci_msg_init(&argc, &argv);
  ARMCI_Init_args(&argc, &argv);
  nproc = armci_msg_nproc();
  me = armci_msg_me();

  if (me == 0) {
    printf("ARMCI test program for lock(%d processes)\n", nproc);
    fflush(stdout);
    sleep(1);
  }

  test_lock();

  ARMCI_Barrier();
  if (me == 0) {
    printf("test passed\n");
    fflush(stdout);
  }
  sleep(2);

  ARMCI_Barrier();
  ARMCI_Finalize();
  armci_msg_finalize();
  return(0);
}