BioDynaMo  v1.05.120-25dc9790
numa.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_UTIL_NUMA_H_
16 #define CORE_UTIL_NUMA_H_
17 
18 #ifdef USE_NUMA
19 
20 #include <numa.h>
21 
22 #else
23 
24 #include <omp.h>
25 
26 inline int numa_available() { return 0; }
27 inline int numa_num_configured_nodes() { return 1; }
28 inline int numa_num_configured_cpus() { return omp_get_max_threads(); }
29 inline int numa_run_on_node(int) { return 0; }
30 inline int numa_node_of_cpu(int) { return 0; }
31 inline int numa_move_pages(int pid, unsigned long count, void **pages,
32  const int *nodes, int *status, int flags) {
33  *status = 0;
34  return 0;
35 }
36 inline void *numa_alloc_onnode(uint64_t size, int nid) { return malloc(size); }
37 inline void numa_free(void *p, uint64_t) { free(p); }
38 
39 // on linux in <sched.h>, but missing on MacOS
40 inline int sched_getcpu() { return 0; }
41 
42 #endif // USE_NUMA
43 
44 #endif // CORE_UTIL_NUMA_H_
numa_node_of_cpu
int numa_node_of_cpu(int)
Definition: numa.h:30
numa_num_configured_cpus
int numa_num_configured_cpus()
Definition: numa.h:28
numa_move_pages
int numa_move_pages(int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags)
Definition: numa.h:31
numa_free
void numa_free(void *p, uint64_t)
Definition: numa.h:37
sched_getcpu
int sched_getcpu()
Definition: numa.h:40
numa.h
numa_num_configured_nodes
int numa_num_configured_nodes()
Definition: numa.h:27
numa_alloc_onnode
void * numa_alloc_onnode(uint64_t size, int nid)
Definition: numa.h:36
numa_run_on_node
int numa_run_on_node(int)
Definition: numa.h:29
numa_available
int numa_available()
Definition: numa.h:26