introduce gmx_omp wrapper for the OpenMP API
[alexxy/gromacs.git] / src / gmxlib / gmx_omp.c
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
2  *
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  *          GROningen MAchine for Chemical Simulations
9  *
10  * Written by the Gromacs development team under coordination of
11  * David van der Spoel, Berk Hess, and Erik Lindahl.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * To help us fund GROMACS development, we humbly ask that you cite
19  * the research papers on the package. Check out http://www.gromacs.org
20  *
21  * And Hey:
22  * Gnomes, ROck Monsters And Chili Sauce
23  */
24
25 #ifdef HAVE_CONFIG
26 #include "config.h"
27 #endif
28
29 #ifdef GMX_OPENMP
30 #include <omp.h>
31 #endif
32
33 #include "gmx_omp.h"
34
35 int gmx_omp_get_max_threads(void)
36 {
37 #ifdef GMX_OPENMP
38     return omp_get_max_threads();
39 #else
40     return 1;
41 #endif
42 }
43
44
45 int gmx_omp_get_thread_num(void)
46 {
47 #ifdef GMX_OPENMP
48     return omp_get_thread_num();
49 #else
50     return 0;
51 #endif
52 }
53
54 void gmx_omp_set_num_threads(int num_threads)
55 {
56 #ifdef GMX_OPENMP
57     omp_set_num_threads(num_threads);
58 #else
59     return;
60 #endif
61 }