aligator  0.12.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
threads.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef ALIGATOR_MULTITHREADING
4#include <omp.h>
5#endif
6
7namespace aligator {
8
10namespace omp {
11
12#ifdef ALIGATOR_MULTITHREADING
13inline std::size_t get_available_threads() {
14 return std::size_t(omp_get_max_threads());
15}
16
18inline std::size_t get_current_threads() {
19 return std::size_t(omp_get_num_threads());
20}
21
23inline std::size_t get_thread_id() { return std::size_t(omp_get_thread_num()); }
24
25inline void set_default_options(std::size_t num_threads, bool dynamic = true) {
26 omp_set_num_threads(int(num_threads));
27 omp_set_dynamic(int(dynamic));
28}
29#else
30inline std::size_t get_available_threads() { return 0; }
31
33inline std::size_t get_current_threads() { return 0; }
34
36inline std::size_t get_thread_id() { return 0; }
37
38inline void set_default_options(std::size_t, bool = true) {}
39
40#endif
41
42} // namespace omp
43
44} // namespace aligator
Utilities to set parallelism options.
Definition threads.hpp:10
std::size_t get_current_threads()
Get the current number of threads.
Definition threads.hpp:33
std::size_t get_thread_id()
Get the current thread ID.
Definition threads.hpp:36
void set_default_options(std::size_t, bool=true)
Definition threads.hpp:38
std::size_t get_available_threads()
Definition threads.hpp:30
Main package namespace.