annotate src/fftw-3.3.8/threads/openmp.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents bd3cc4d1df30
children
rev   line source
cannam@167 1 /*
cannam@167 2 * Copyright (c) 2003, 2007-14 Matteo Frigo
cannam@167 3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
cannam@167 4 *
cannam@167 5 * This program is free software; you can redistribute it and/or modify
cannam@167 6 * it under the terms of the GNU General Public License as published by
cannam@167 7 * the Free Software Foundation; either version 2 of the License, or
cannam@167 8 * (at your option) any later version.
cannam@167 9 *
cannam@167 10 * This program is distributed in the hope that it will be useful,
cannam@167 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@167 13 * GNU General Public License for more details.
cannam@167 14 *
cannam@167 15 * You should have received a copy of the GNU General Public License
cannam@167 16 * along with this program; if not, write to the Free Software
cannam@167 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cannam@167 18 *
cannam@167 19 */
cannam@167 20
cannam@167 21 /* openmp.c: thread spawning via OpenMP */
cannam@167 22
cannam@167 23 #include "threads/threads.h"
cannam@167 24
cannam@167 25 #if !defined(_OPENMP)
cannam@167 26 #error OpenMP enabled but not using an OpenMP compiler
cannam@167 27 #endif
cannam@167 28
cannam@167 29 int X(ithreads_init)(void)
cannam@167 30 {
cannam@167 31 return 0; /* no error */
cannam@167 32 }
cannam@167 33
cannam@167 34 /* Distribute a loop from 0 to loopmax-1 over nthreads threads.
cannam@167 35 proc(d) is called to execute a block of iterations from d->min
cannam@167 36 to d->max-1. d->thr_num indicate the number of the thread
cannam@167 37 that is executing proc (from 0 to nthreads-1), and d->data is
cannam@167 38 the same as the data parameter passed to X(spawn_loop).
cannam@167 39
cannam@167 40 This function returns only after all the threads have completed. */
cannam@167 41 void X(spawn_loop)(int loopmax, int nthr, spawn_function proc, void *data)
cannam@167 42 {
cannam@167 43 int block_size;
cannam@167 44 spawn_data d;
cannam@167 45 int i;
cannam@167 46
cannam@167 47 A(loopmax >= 0);
cannam@167 48 A(nthr > 0);
cannam@167 49 A(proc);
cannam@167 50
cannam@167 51 if (!loopmax) return;
cannam@167 52
cannam@167 53 /* Choose the block size and number of threads in order to (1)
cannam@167 54 minimize the critical path and (2) use the fewest threads that
cannam@167 55 achieve the same critical path (to minimize overhead).
cannam@167 56 e.g. if loopmax is 5 and nthr is 4, we should use only 3
cannam@167 57 threads with block sizes of 2, 2, and 1. */
cannam@167 58 block_size = (loopmax + nthr - 1) / nthr;
cannam@167 59 nthr = (loopmax + block_size - 1) / block_size;
cannam@167 60
cannam@167 61 #pragma omp parallel for private(d)
cannam@167 62 for (i = 0; i < nthr; ++i) {
cannam@167 63 d.max = (d.min = i * block_size) + block_size;
cannam@167 64 if (d.max > loopmax)
cannam@167 65 d.max = loopmax;
cannam@167 66 d.thr_num = i;
cannam@167 67 d.data = data;
cannam@167 68 proc(&d);
cannam@167 69 }
cannam@167 70 }
cannam@167 71
cannam@167 72 void X(threads_cleanup)(void)
cannam@167 73 {
cannam@167 74 }
cannam@167 75
cannam@167 76 /* FIXME [Matteo Frigo 2015-05-25] What does "thread-safe"
cannam@167 77 mean for openmp? */
cannam@167 78 void X(threads_register_planner_hooks)(void)
cannam@167 79 {
cannam@167 80 }