13 #include <shogun/lib/config.h> 23 #include <sys/types.h> 24 #include <sys/sysctl.h> 39 omp_set_num_threads(num_threads);
49 omp_set_num_threads(num_threads);
62 num_cpus = std::thread::hardware_concurrency();
70 #if defined(LINUX) && defined(_SC_NPROCESSORS_ONLN) 71 return sysconf(_SC_NPROCESSORS_ONLN);
74 size_t size=
sizeof(num);
75 if (!sysctlbyname(
"hw.ncpu", &num, &size, NULL, 0))
77 #elif defined(_MSC_VER) 79 GetSystemInfo(&sysinfo);
80 num_cpus = sysinfo.dwNumberOfProcessors;
88 #if !defined(HAVE_PTHREAD) && !defined(HAVE_OPENMP) 93 omp_set_num_threads(num_threads);
104 return m_refcount->
ref();
114 int32_t rc = m_refcount->
unref();
void set_num_threads(int32_t n)
int32_t get_num_cpus() const
int32_t get_num_threads() const
SG_FORCED_INLINE int32_t ref()
SG_FORCED_INLINE int32_t unref()
Class Parallel provides helper functions for multithreading.
all of classes and functions are contained in the shogun namespace
int32_t ref_count() const
SG_FORCED_INLINE int32_t ref_count()