Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
backend_openblas.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <uni20/config.hpp>
4
5#include <string>
6
13#if !UNI20_BACKEND_OPENBLAS
14#error "backend_openblas.hpp requires UNI20_BACKEND_OPENBLAS"
15#endif
16
17namespace uni20
18{
19namespace blas::openblas
20{
21namespace detail
22{
23extern "C"
24{
25 void openblas_set_num_threads(int num_threads);
26 int openblas_get_num_threads();
27 int openblas_get_num_procs();
28 char* openblas_get_config();
29 char* openblas_get_corename();
30 int openblas_get_parallel();
31}
32
37inline std::string copy_string(char const* value) { return value == nullptr ? std::string{} : std::string(value); }
38} // namespace detail
39
42enum class ParallelMode : int
43{
44 sequential = 0,
45 thread = 1,
46 openmp = 2
47};
48
52inline std::string config() { return detail::copy_string(detail::openblas_get_config()); }
53
57inline std::string core_name() { return detail::copy_string(detail::openblas_get_corename()); }
58
62inline void set_num_threads(int threads) { detail::openblas_set_num_threads(threads); }
63
67inline int num_threads() { return detail::openblas_get_num_threads(); }
68
72inline int num_procs() { return detail::openblas_get_num_procs(); }
73
77inline ParallelMode parallel_mode() { return static_cast<ParallelMode>(detail::openblas_get_parallel()); }
78} // namespace blas::openblas
79} // namespace uni20
locale_t value
Definition data_table.cpp:49
int num_threads()
Return the current number of OpenBLAS worker threads.
Definition backend_openblas.hpp:67
std::string config()
Return the OpenBLAS build configuration string.
Definition backend_openblas.hpp:52
ParallelMode parallel_mode()
Return the OpenBLAS parallel runtime mode.
Definition backend_openblas.hpp:77
ParallelMode
OpenBLAS parallel runtime mode.
Definition backend_openblas.hpp:43
std::string core_name()
Return the OpenBLAS CPU core name selected by the library.
Definition backend_openblas.hpp:57
int num_procs()
Return the processor count reported by OpenBLAS.
Definition backend_openblas.hpp:72
void set_num_threads(int threads)
Set the number of OpenBLAS worker threads.
Definition backend_openblas.hpp:62
Definition async/async.hpp:26