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

« back to all changes in this revision

Viewing changes to src/tools/ga-4-3/armci/src/kr_malloc.h

  • 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
#ifndef KR_MALLOC_H /* K&R malloc */
 
2
#define KR_MALLOC_H
 
3
 
 
4
#ifdef CRAY
 
5
#define LOG_ALIGN 6
 
6
#elif defined(KSR)
 
7
#define LOG_ALIGN 7
 
8
#else
 
9
#define LOG_ALIGN 6
 
10
#endif
 
11
 
 
12
#define ALIGNMENT (1 << LOG_ALIGN)
 
13
 
 
14
#define KR_CTX_SHMEM     101
 
15
#define KR_CTX_LOCALMEM  102
 
16
 
 
17
union header{
 
18
  struct {
 
19
    unsigned valid1;            /* Token to check if is not overwritten */
 
20
    union header *ptr;          /* next block if on free list */
 
21
    int shmid;                  /* next block's shared memory id  */
 
22
    long shmoffset;             /* next block's shmem offset */
 
23
    size_t shmsize;             /* next block's shared memory segment size */
 
24
    size_t size;                /* size of this block*/
 
25
    unsigned valid2;            /* Another token acting as a guard */
 
26
  } s;
 
27
  char align[ALIGNMENT];        /* Align to ALIGNMENT byte boundary */
 
28
};
 
29
 
 
30
typedef union header Header;
 
31
 
 
32
typedef struct malloc_context {
 
33
  size_t usize;                 /* unit size in bytes */
 
34
  size_t nalloc;                /* No. of units of length ALIGNMENT */
 
35
  size_t max_nalloc;            /* Maximum  no. of units that can get */
 
36
  void * (*alloc_fptr)();       /* function pointer to memory alloc routine */
 
37
  size_t total;                 /* Amount request from system in units */
 
38
  long nchunk;                  /* No. of chunks of system memory */
 
39
  long inuse;                   /* Amount in use in units */
 
40
  long maxuse;                  /* Maximum value of inuse */
 
41
  long nfrags;                  /* No. of fragments divided into */
 
42
  long nmcalls;                 /* No. of calls to _armci_alloc() */
 
43
  long nfcalls;                 /* No. of calls to memfree */
 
44
  int ctx_type;                 /* context id. 
 
45
                                   -1 represents ctx_local context.
 
46
                                   otherwise, it is ctx_shmem context. */
 
47
  int shmid;                    /* first free block's (i.e.freep) shmem id */
 
48
  long shmoffset;               /* first free block's shmem offset */
 
49
  size_t shmsize;               /* first free block's shmem total size */
 
50
  Header base;                  /* empty list to get started */
 
51
  Header *freep;                /* start of free list */
 
52
  Header *usedp;                /* start of used list */
 
53
} context_t;
 
54
 
 
55
/* Memory required to store the shmem context in shared memory. This shmem
 
56
   context shuld be stored in shared memory and is stored in the first shared
 
57
   memory segment created (i.e.armci_krmalloc_init_ctxshmem) */
 
58
#define SHMEM_CTX_MEM   (sizeof(context_t)+sizeof(void*))
 
59
#define SHMEM_CTX_BYTES ((SHMEM_CTX_MEM + sizeof(Header) - 1)>>LOG_ALIGN) + 1; 
 
60
 
 
61
extern void kr_malloc_init(size_t usize, /* unit size in bytes */
 
62
                           size_t nalloc,
 
63
                           size_t max_nalloc,
 
64
                           void * (*alloc_fptr)(), /* memory alloc routine */
 
65
                           int debug,
 
66
                           context_t *ctx);
 
67
 
 
68
/*
 
69
  Returns data aligned on a quad boundary. Even if the request
 
70
  size is zero it returns a non-zero pointer.
 
71
*/
 
72
extern char *kr_malloc(size_t size, context_t *ctx);
 
73
 
 
74
/*
 
75
  Frees memory allocated by kr_malloc(). Ignores NULL pointers
 
76
  but must not be called twice for the same pointer or called
 
77
  with non-memalloc'ed pointers
 
78
*/
 
79
extern void  kr_free(char *ptr, context_t *ctx);
 
80
 
 
81
/*
 
82
  Print to standard output the usage statistics ... a wrapper
 
83
  for kr_malloc_stats();
 
84
*/
 
85
extern void kr_malloc_print_stats(context_t *ctx);
 
86
 
 
87
extern void kr_malloc_verify(context_t *ctx);
 
88
 
 
89
#endif