HiRep 0.1
Loading...
Searching...
No Matches
hr_omp.h
Go to the documentation of this file.
1/***************************************************************************\
2 * Copyright (c) 2014, Claudio Pica *
3 * All rights reserved. *
4 \***************************************************************************/
5
11#ifndef HR_OMP_H
12#define HR_OMP_H
13
14#define _DO_PRAGMA(s) _Pragma(#s)
15
16#ifdef _OPENMP
17#define _OMP_PRAGMA(s) _DO_PRAGMA(omp s)
18
19#include <omp.h>
20
21//define OpenMP behavior
22#define _omp_parallel parallel default(shared)
23#define _omp_for for \
24 schedule(static)
25#define _omp_sum(...) reduction(+ : __VA_ARGS__)
26#define _omp_max(...) reduction(max : __VA_ARGS__)
27#define _omp_min(...) reduction(min : __VA_ARGS__)
28
29#define hr_threadId() omp_get_thread_num()
30
31#else //to avoid compilation warnings
32#define _OMP_PRAGMA(s)
33#define hr_threadId() ((int)(0))
34#endif
35
36#define _OMP_BARRIER _OMP_PRAGMA(barrier)
37
38#define _OMP_PARALLEL_FOR \
39 _OMP_PRAGMA(_omp_parallel) \
40 _OMP_PRAGMA(_omp_for)
41
42#endif