source: CIVL/examples/mpi-omp/AMG2013/utilities/hypre_memory.h

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[2aa6644]1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13/******************************************************************************
14 *
15 * Header file for memory management utilities
16 *
17 *****************************************************************************/
18
19#ifndef hypre_MEMORY_HEADER
20#define hypre_MEMORY_HEADER
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/*--------------------------------------------------------------------------
27 * Use "Debug Malloc Library", dmalloc
28 *--------------------------------------------------------------------------*/
29
30#ifdef HYPRE_MEMORY_DMALLOC
31
32#define hypre_InitMemoryDebug(id) hypre_InitMemoryDebugDML(id)
33#define hypre_FinalizeMemoryDebug() hypre_FinalizeMemoryDebugDML()
34
35#define hypre_TAlloc(type, count) \
36( (type *)hypre_MAllocDML((unsigned int)(sizeof(type) * (count)),\
37 __FILE__, __LINE__) )
38
39#define hypre_CTAlloc(type, count) \
40( (type *)hypre_CAllocDML((unsigned int)(count), (unsigned int)sizeof(type),\
41 __FILE__, __LINE__) )
42
43#define hypre_TReAlloc(ptr, type, count) \
44( (type *)hypre_ReAllocDML((char *)ptr,\
45 (unsigned int)(sizeof(type) * (count)),\
46 __FILE__, __LINE__) )
47
48#define hypre_TFree(ptr) \
49( hypre_FreeDML((char *)ptr, __FILE__, __LINE__), ptr = NULL )
50
51/*--------------------------------------------------------------------------
52 * Use standard memory routines
53 *--------------------------------------------------------------------------*/
54
55#else
56
57#define hypre_InitMemoryDebug(id)
58#define hypre_FinalizeMemoryDebug()
59
60#define hypre_TAlloc(type, count) \
61( (type *)hypre_MAlloc((unsigned int)(sizeof(type) * (count))) )
62
63#define hypre_CTAlloc(type, count) \
64( (type *)hypre_CAlloc((unsigned int)(count), (unsigned int)sizeof(type)) )
65
66#define hypre_TReAlloc(ptr, type, count) \
67( (type *)hypre_ReAlloc((char *)ptr, (unsigned int)(sizeof(type) * (count))) )
68
69#define hypre_TFree(ptr) \
70( hypre_Free((char *)ptr), ptr = NULL )
71
72#endif
73
74
75#ifdef HYPRE_USE_PTHREADS
76
77#define hypre_SharedTAlloc(type, count) \
78( (type *)hypre_SharedMAlloc((unsigned int)(sizeof(type) * (count))) )
79
80
81#define hypre_SharedCTAlloc(type, count) \
82( (type *)hypre_SharedCAlloc((unsigned int)(count),\
83 (unsigned int)sizeof(type)) )
84
85#define hypre_SharedTReAlloc(ptr, type, count) \
86( (type *)hypre_SharedReAlloc((char *)ptr,\
87 (unsigned int)(sizeof(type) * (count))) )
88
89#define hypre_SharedTFree(ptr) \
90( hypre_SharedFree((char *)ptr), ptr = NULL )
91
92#else
93
94#define hypre_SharedTAlloc(type, count) hypre_TAlloc(type, (count))
95#define hypre_SharedCTAlloc(type, count) hypre_CTAlloc(type, (count))
96#define hypre_SharedTReAlloc(type, count) hypre_TReAlloc(type, (count))
97#define hypre_SharedTFree(ptr) hypre_TFree(ptr)
98
99#endif
100
101/*--------------------------------------------------------------------------
102 * Prototypes
103 *--------------------------------------------------------------------------*/
104
105/* hypre_memory.c */
106int hypre_OutOfMemory( int size );
107char *hypre_MAlloc( int size );
108char *hypre_CAlloc( int count , int elt_size );
109char *hypre_ReAlloc( char *ptr , int size );
110void hypre_Free( char *ptr );
111char *hypre_SharedMAlloc( int size );
112char *hypre_SharedCAlloc( int count , int elt_size );
113char *hypre_SharedReAlloc( char *ptr , int size );
114void hypre_SharedFree( char *ptr );
115double *hypre_IncrementSharedDataPtr( double *ptr , int size );
116
117/* memory_dmalloc.c */
118int hypre_InitMemoryDebugDML( int id );
119int hypre_FinalizeMemoryDebugDML( void );
120char *hypre_MAllocDML( int size , char *file , int line );
121char *hypre_CAllocDML( int count , int elt_size , char *file , int line );
122char *hypre_ReAllocDML( char *ptr , int size , char *file , int line );
123void hypre_FreeDML( char *ptr , char *file , int line );
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif
Note: See TracBrowser for help on using the repository browser.