Coverage Report

Created: 2025-12-31 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fftw3/kernel/buffered.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2003, 2007-14 Matteo Frigo
3
 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
 *
19
 */
20
21
/* routines shared by the various buffered solvers */
22
23
#include "kernel/ifftw.h"
24
25
0
#define DEFAULT_MAXNBUF ((INT)256)
26
27
/* approx. 512KB of buffers for complex data */
28
3.06k
#define MAXBUFSZ (256 * 1024 / (INT)(sizeof(R)))
29
30
INT X(nbuf)(INT n, INT vl, INT maxnbuf)
31
1.69k
{
32
1.69k
     INT i, nbuf, lb; 
33
34
1.69k
     if (!maxnbuf) 
35
0
    maxnbuf = DEFAULT_MAXNBUF;
36
37
1.69k
     nbuf = X(imin)(maxnbuf,
38
1.69k
        X(imin)(vl, X(imax)((INT)1, MAXBUFSZ / n)));
39
40
     /*
41
      * Look for a buffer number (not too small) that divides the
42
      * vector length, in order that we only need one child plan:
43
      */
44
1.69k
     lb = X(imax)(1, nbuf / 4);
45
2.42k
     for (i = nbuf; i >= lb; --i)
46
2.42k
          if (vl % i == 0)
47
1.69k
               return i;
48
49
     /* whatever... */
50
5
     return nbuf;
51
1.69k
}
52
53
197
#define SKEW 6 /* need to be even for SIMD */
54
197
#define SKEWMOD 8 
55
56
INT X(bufdist)(INT n, INT vl)
57
197
{
58
197
     if (vl == 1)
59
0
    return n;
60
197
     else 
61
    /* return smallest X such that X >= N and X == SKEW (mod SKEWMOD) */
62
197
    return n + X(modulo)(SKEW - n, SKEWMOD);
63
197
}
64
65
int X(toobig)(INT n)
66
1.36k
{
67
1.36k
     return n > MAXBUFSZ;
68
1.36k
}
69
70
/* TRUE if there exists i < which such that maxnbuf[i] and
71
   maxnbuf[which] yield the same value, in which case we canonicalize
72
   on the minimum value */
73
int X(nbuf_redundant)(INT n, INT vl, size_t which, 
74
          const INT *maxnbuf, size_t nmaxnbuf)
75
1.16k
{
76
1.16k
     size_t i;
77
1.16k
     (void)nmaxnbuf; /* UNUSED */
78
1.33k
     for (i = 0; i < which; ++i)
79
600
    if (X(nbuf)(n, vl, maxnbuf[i]) == X(nbuf)(n, vl, maxnbuf[which]))
80
431
         return 1;
81
738
     return 0;
82
1.16k
}