51f12d4d4605922e9589652d5371692a6006bec6
[alexxy/gromacs.git] / include / gmx_omp.h
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  * GROup of MAchos and Cynical Suckers
23  */
24
25 #ifndef GMX_OMP_H
26 #define GMX_OMP_H
27 #include "visibility.h"
28 #include "types/commrec.h"
29 #include "mdrun.h"
30
31 /* This module defines wrappers for OpenMP API functions and enables compiling
32  * code even when OpenMP is turned off in the build system.
33  * Therefore, OpenMP API functions should always be used through these wrappers
34  * and omp.h should never be directly included. Instead, this header should be
35  * used whenever OpenMP API functions are needed.
36  */
37
38 /*! Returns an integer equal to or greater than the number of threads
39  *  that would be available if a parallel region without num_threads were
40  *  defined at that point in the code. Acts as a wrapper for omp_set_num_threads(void). */
41 GMX_LIBGMX_EXPORT
42 int  gmx_omp_get_max_threads(void);
43
44 /*! Returns the number of processors available when the function is called.
45  *  Acts as a wrapper around omp_get_num_procs() */
46 int gmx_omp_get_num_procs(void);
47
48 /*! Returns the thread number of the thread executing within its thread team.
49  *  Acts as a wrapper for omp_get_thread_num(void). */
50 GMX_LIBGMX_EXPORT
51 int  gmx_omp_get_thread_num(void);
52
53 /*! Sets the number of threads in subsequent parallel regions, unless overridden
54  *  by a num_threads clause. Acts as a wrapper for omp_get_max_threads(void). */
55 GMX_LIBGMX_EXPORT
56 void gmx_omp_set_num_threads(int num_threads);
57
58 /*! Check for externally set thread affinity to avoid conflicts with GROMACS internal setting. */
59 GMX_LIBGMX_EXPORT
60 void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr,
61                                    gmx_hw_opt_t *hw_opt);
62
63 #endif /* GMX_OMP_H */