e5c1f4540b4c0ab2d330f7c362f53a6a938cfa75
[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_H
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 int gmx_omp_get_num_procs(void)
45 {
46 #ifdef GMX_OPENMP
47     return omp_get_num_procs();
48 #else
49     return 1;
50 #endif
51 }
52
53 int gmx_omp_get_thread_num(void)
54 {
55 #ifdef GMX_OPENMP
56     return omp_get_thread_num();
57 #else
58     return 0;
59 #endif
60 }
61
62 void gmx_omp_set_num_threads(int num_threads)
63 {
64 #ifdef GMX_OPENMP
65     omp_set_num_threads(num_threads);
66 #else
67     return;
68 #endif
69 }