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