NFFT 3.5.3alpha
thread.c
1/*
2 * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "infft.h"
20
21#ifdef _OPENMP
22#include <omp.h>
23#endif
24
25INT Y(get_num_threads)(void)
26{
27#ifdef _OPENMP
28 INT nthreads;
29 #pragma omp parallel default(shared)
30 {
31 INT n = (INT)omp_get_num_threads();
32 #pragma omp master
33 {
34 nthreads = n;
35 }
36 }
37 return nthreads;
38#else
39 return 1;
40#endif
41}
42
43void Y(set_num_threads)(INT nthreads)
44{
45#ifdef _OPENMP
46 /* Already created plans may still use old number of threads for FFT step! */
47 omp_set_num_threads(nthreads);
48#endif
49}
50
51INT Y(has_threads_enabled)(void)
52{
53#ifdef _OPENMP
54 return 1;
55#else
56 return 0;
57#endif
58}
59
Internal header file for auxiliary definitions and functions.