aligator
0.19.0
A versatile and efficient C++ library for real-time constrained trajectory optimization.
Toggle main menu visibility
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
7
namespace
aligator
{
8
10
namespace
omp
{
11
12
#ifdef ALIGATOR_MULTITHREADING
13
inline
std::size_t
get_available_threads
() {
14
return
std::size_t(omp_get_max_threads());
15
}
16
18
inline
std::size_t
get_current_threads
() {
19
return
std::size_t(omp_get_num_threads());
20
}
21
23
inline
std::size_t
get_thread_id
() {
return
std::size_t(omp_get_thread_num()); }
24
25
inline
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
30
inline
std::size_t
get_available_threads
() {
return
0; }
31
33
inline
std::size_t
get_current_threads
() {
return
0; }
34
36
inline
std::size_t
get_thread_id
() {
return
0; }
37
38
inline
void
set_default_options
(std::size_t,
bool
=
true
) {}
39
40
#endif
41
42
}
// namespace omp
43
44
}
// namespace aligator
aligator::omp
Utilities to set parallelism options.
Definition
threads.hpp:10
aligator::omp::get_current_threads
std::size_t get_current_threads()
Get the current number of threads.
Definition
threads.hpp:18
aligator::omp::get_thread_id
std::size_t get_thread_id()
Get the current thread ID.
Definition
threads.hpp:23
aligator::omp::set_default_options
void set_default_options(std::size_t num_threads, bool dynamic=true)
Definition
threads.hpp:25
aligator::omp::get_available_threads
std::size_t get_available_threads()
Definition
threads.hpp:13
aligator
Main package namespace.
Definition
action-model-wrap.hpp:14
include
aligator
threads.hpp
Generated by
1.17.0