~ubuntu-branches/ubuntu/saucy/nwchem/saucy

« back to all changes in this revision

Viewing changes to src/tools/ga-4-3/armci-portals/src/shmtest.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2012-02-09 20:02:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120209200241-jgk03qfsphal4ug2
Tags: 6.1-1
* New upstream release.

[ Michael Banck ]
* debian/patches/02_makefile_flags.patch: Updated.
* debian/patches/02_makefile_flags.patch: Use internal blas and lapack code.
* debian/patches/02_makefile_flags.patch: Define GCC4 for LINUX and LINUX64
  (Closes: #632611 and LP: #791308).
* debian/control (Build-Depends): Added openssh-client.
* debian/rules (USE_SCALAPACK, SCALAPACK): Removed variables (Closes:
  #654658).
* debian/rules (LIBDIR, USE_MPIF4, ARMCI_NETWORK): New variables.
* debian/TODO: New file.
* debian/control (Build-Depends): Removed libblas-dev, liblapack-dev and
  libscalapack-mpi-dev.
* debian/patches/04_show_testsuite_diff_output.patch: New patch, shows the
  diff output for failed tests.
* debian/patches/series: Adjusted.
* debian/testsuite: Optionally run all tests if "all" is passed as option.
* debian/rules: Run debian/testsuite with "all" if DEB_BUILD_OPTIONS
  contains "checkall".

[ Daniel Leidert ]
* debian/control: Used wrap-and-sort. Added Vcs-Svn and Vcs-Browser fields.
  (Priority): Moved to extra according to policy section 2.5.
  (Standards-Version): Bumped to 3.9.2.
  (Description): Fixed a typo.
* debian/watch: Added.
* debian/patches/03_hurd-i386_define_path_max.patch: Added.
  - Define MAX_PATH if not defines to fix FTBFS on hurd.
* debian/patches/series: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: shmtest.c,v 1.6 2003-10-22 22:12:21 d3h325 Exp $ */
 
2
#include <sys/types.h>
 
3
#include <sys/ipc.h>
 
4
#include <sys/shm.h>
 
5
#include <sys/param.h>
 
6
#include <errno.h>
 
7
#include <stdio.h>
 
8
 
 
9
#ifdef SUN
 
10
char *shmat();
 
11
#endif
 
12
 
 
13
int armci_test_allocate(long size)
 
14
{
 
15
   char *ptr;
 
16
   long id = (long)shmget(IPC_PRIVATE, (size_t) size, (int) (IPC_CREAT |00600));
 
17
   if (id <0L) return 0;
 
18
#if 0
 
19
   /* attach to segment */
 
20
   ptr =  shmat((int) id, (char *) NULL, 0);
 
21
#else 
 
22
   ptr = (char *) NULL;
 
23
#endif
 
24
 
 
25
   /* delete segment id */
 
26
   if(shmctl( (int) id, IPC_RMID,(struct shmid_ds *)NULL))
 
27
      fprintf(stderr,"failed to remove shm id=%d\n",id);
 
28
 
 
29
   /* test pointer */
 
30
   if (((long)ptr) == -1L) return 0;
 
31
   else return 1;
 
32
}
 
33
 
 
34
    
 
35
/* parameters that define range and granularity of search for shm segment size  
 
36
 * UBOUND is chosen to be < 2GB to avoid overflowing on 32-bit systems
 
37
 * smaller PAGE gives more accurate results but with more search steps
 
38
 * LBOUND  is set to amount that is considered insufficient for our purposes 
 
39
 */
 
40
 
 
41
#define PAGE 131072L
 
42
#define UBOUND 2*4096*PAGE
 
43
#define LBOUND 4*PAGE
 
44
 
 
45
int verbose=1;
 
46
 
 
47
/*\ determine the max shmem segment size using bisection
 
48
\*/
 
49
void armci_shmem_init()
 
50
{
 
51
long x,i, y=0L;
 
52
long upper_bound=UBOUND;
 
53
long lower_bound=0;
 
54
     x = upper_bound;
 
55
     for(i=1;;i++){
 
56
        long step;
 
57
        int rc = armci_test_allocate(x);
 
58
        if(rc){
 
59
          if(verbose)printf("test %d size=%ld bytes: success\n",i,x);
 
60
          y=lower_bound = x;
 
61
          step = (upper_bound -x)>>1;
 
62
          if(step < 16*PAGE) break;
 
63
          x += step;
 
64
        }else{
 
65
          if(verbose)printf("test %d size=%ld bytes: failed\n",i,x);
 
66
          upper_bound = x;
 
67
          step = (x-lower_bound)>>1;
 
68
          if(step< PAGE || x < LBOUND) break;
 
69
          x -= step;
 
70
        }
 
71
      }
 
72
      if(verbose){
 
73
        if(x<LBOUND)
 
74
          printf("no usable amount (%d bytes) of shared memory available\n",LBOUND);
 
75
        else printf("%ld bytes segment size, %d calls \n",y,i);
 
76
      }else{
 
77
         printf("%d\n",y);
 
78
      }
 
79
}
 
80
 
 
81
 
 
82
main(int argc, char **argv)
 
83
{
 
84
  if(argc>1) verbose=0;
 
85
  if(verbose)printf("Searching for max shared memory segment size (SHMMAX) using bisection\n");
 
86
  armci_shmem_init();
 
87
}
 
88