M4RI  1.0.1
mmc.h
Go to the documentation of this file.
1 
9 #ifndef M4RI_MMC_H
10 #define M4RI_MMC_H
11 
12 /*******************************************************************
13 *
14 * M4RI: Linear Algebra over GF(2)
15 *
16 * Copyright (C) 2007, 2008 Gregory Bard <bard@fordham.edu>
17 * Copyright (C) 2008 Martin Albrecht <M.R.Albrecht@rhul.ac.uk>
18 *
19 * Distributed under the terms of the GNU General Public License (GPL)
20 * version 2 or higher.
21 *
22 * This code is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
26 *
27 * The full text of the GPL is available at:
28 *
29 * http://www.gnu.org/licenses/
30 *
31 ********************************************************************/
32 
33 #include <m4ri/misc.h>
34 
35 void *m4ri_mmc_malloc(size_t size);
36 void m4ri_mmc_free(void *condemned, size_t size);
37 void m4ri_mmc_cleanup(void);
38 
42 #define __M4RI_ENABLE_MMC
43 
47 #define __M4RI_MMC_NBLOCKS 16
48 
52 #define __M4RI_MMC_THRESHOLD __M4RI_CPU_L3_CACHE
53 
57 typedef struct _mm_block {
61  size_t size;
62 
66  void *data;
67 
68 } mmb_t;
69 
78 static inline void *m4ri_mmc_calloc(size_t count, size_t size) {
79  size_t total_size = count * size;
80  void *ret = m4ri_mmc_malloc(total_size);
81  memset((char*)ret, 0, total_size);
82  return ret;
83 }
84 
85 #endif // M4RI_MMC_H
struct _mm_block mmb_t
Tuple of pointer to allocated memory block and it's size.
void m4ri_mmc_free(void *condemned, size_t size)
Free the data pointed to by condemned of the given size.
Definition: mmc.c:83
Helper functions.
void * m4ri_mmc_malloc(size_t size)
Allocate size bytes.
Definition: mmc.c:42
void m4ri_mmc_cleanup(void)
Cleans up memory block cache.
Definition: mmc.c:125
static void * m4ri_mmc_calloc(size_t count, size_t size)
Allocate an array of count times size zeroed bytes.
Definition: mmc.h:78
void * data
Definition: mmc.h:66
size_t size
Definition: mmc.h:61
Tuple of pointer to allocated memory block and it's size.
Definition: mmc.h:57