jaffarCommon
Loading...
Searching...
No Matches
parallel.hpp
Go to the documentation of this file.
1#pragma once
2
8#include <omp.h>
9#include <stddef.h>
10#include <stdint.h>
11
12namespace jaffarCommon
13{
14
15namespace parallel
16{
17
19#define JAFFAR_PARALLEL _Pragma("omp parallel")
20
22#define JAFFAR_PARALLEL_FOR _Pragma("omp parallel for")
23
25#define JAFFAR_MASTER _Pragma("omp master")
26
28#define JAFFAR_BARRIER _Pragma("omp barrier")
29
31#define JAFFAR_CRITICAL _Pragma("omp critical")
32
34typedef uint32_t threadId_t;
35
41__JAFFAR_COMMON__INLINE__ threadId_t getThreadId() { return (threadId_t)omp_get_thread_num(); }
42
48__JAFFAR_COMMON__INLINE__ size_t getThreadCount() { return (threadId_t)omp_get_num_threads(); }
49
55__JAFFAR_COMMON__INLINE__ void setThreadCount(const size_t threadCount) { omp_set_num_threads((threadId_t)threadCount); }
56
62__JAFFAR_COMMON__INLINE__ size_t getMaxThreadCount() { return (threadId_t)omp_get_max_threads(); }
63
64} // namespace parallel
65
66} // namespace jaffarCommon
__JAFFAR_COMMON__INLINE__ void setThreadCount(const size_t threadCount)
Definition parallel.hpp:55
uint32_t threadId_t
Type definition for thread identifier.
Definition parallel.hpp:34
__JAFFAR_COMMON__INLINE__ size_t getMaxThreadCount()
Definition parallel.hpp:62
__JAFFAR_COMMON__INLINE__ size_t getThreadCount()
Definition parallel.hpp:48
__JAFFAR_COMMON__INLINE__ threadId_t getThreadId()
Definition parallel.hpp:41