StarPU Internal Handbook
malloc.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2013-2022 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 *
5 * StarPU is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or (at
8 * your option) any later version.
9 *
10 * StarPU is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
15 */
16
17#ifndef __ALLOC_H__
18#define __ALLOC_H__
19
20#pragma GCC visibility push(hidden)
21
24void _starpu_malloc_init(unsigned dst_node);
25void _starpu_malloc_shutdown(unsigned dst_node);
26
27int _starpu_malloc_flags_on_node(unsigned dst_node, void **A, size_t dim, int flags);
28int _starpu_free_flags_on_node(unsigned dst_node, void *A, size_t dim, int flags);
29
35int _starpu_malloc_willpin_on_node(unsigned dst_node);
36
46#ifdef STARPU_USE_MAX_FPGA
47// FIXME: Maxeler FPGAs want 192 byte alignment
48#define CHUNK_SIZE (128*1024*192)
49#define CHUNK_ALLOC_MAX (CHUNK_SIZE / 8)
50#define CHUNK_ALLOC_MIN (128*192)
51#else
52/* Size of each chunk, 32MiB granularity brings 128 chunks to be allocated in
53 * order to fill a 4GiB GPU. */
54#define CHUNK_SIZE (32*1024*1024)
55
56/* Maximum segment size we will allocate in chunks */
57#define CHUNK_ALLOC_MAX (CHUNK_SIZE / 8)
58
59/* Granularity of allocation, i.e. block size, StarPU will never allocate less
60 * than this.
61 * 16KiB (i.e. 64x64 float) granularity eats 2MiB RAM for managing a 4GiB GPU.
62 */
63#define CHUNK_ALLOC_MIN (16*1024)
64#endif
65
66/* Don't really deallocate chunks unless we have more than this many chunks
67 * which are completely free. */
68#define CHUNKS_NFREE 4
69
70/* Number of blocks */
71#define CHUNK_NBLOCKS (CHUNK_SIZE/CHUNK_ALLOC_MIN)
72
73/* Linked list for available segments */
74struct block
75{
76 int length; /* Number of consecutive free blocks */
77 int next; /* next free segment */
78};
79
80/* One chunk */
81LIST_TYPE(_starpu_chunk,
82 uintptr_t base;
83
84 /* Available number of blocks, for debugging */
85 int available;
86
87 /* Overestimation of the maximum size of available segments in this chunk */
88 int available_max;
89
90 /* Bitmap describing availability of the block */
91 /* Block 0 is always empty, and is just the head of the free segments list */
92 struct block bitmap[CHUNK_NBLOCKS+1];
93)
94
95#pragma GCC visibility pop
96
97#endif
int _starpu_malloc_willpin_on_node(unsigned dst_node)
Definition: malloc.h:75