Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - kernel/none - divll_pre.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 21343-6216058) Lines: 48 48 100.0 %
Date: 2017-11-19 06:21:17 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #line 2 "../src/kernel/none/divll_pre.h"
       2             : /* Copyright (C) 2014  The PARI group.
       3             : 
       4             : This file is part of the PARI/GP package.
       5             : 
       6             : PARI/GP is free software; you can redistribute it and/or modify it under the
       7             : terms of the GNU General Public License as published by the Free Software
       8             : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       9             : ANY WARRANTY WHATSOEVER.
      10             : 
      11             : Check the License for details. You should have received a copy of it, along
      12             : with the package; see the file 'COPYING'. If not, write to the Free Software
      13             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14             : 
      15             : #undef  LOCAL_HIREMAINDER
      16             : extern ulong hiremainder;
      17             : #if defined(INLINE) && defined(__GNUC__) && !defined(DISABLE_INLINE)
      18             : #define LOCAL_HIREMAINDER register ulong hiremainder
      19             : #else
      20             : #define LOCAL_HIREMAINDER
      21             : #endif
      22             : 
      23             : #if defined(INLINE) && defined(__GNUC__) && !defined(DISABLE_INLINE)
      24             : INLINE ulong /* precompute inverse of n */
      25   732824037 : get_Fl_red(ulong n)
      26             : {
      27             :   LOCAL_HIREMAINDER;
      28   732824037 :   n <<= bfffo(n);
      29   732824037 :   hiremainder = ~n;
      30   732824037 :   return divll(~0UL, n);
      31             : }
      32             : #else
      33             : INLINE ulong /* precompute inverse of n */
      34   168675963 : get_Fl_red(ulong n)
      35             : {
      36   168675963 :   ulong q, oldhi = hiremainder;
      37   168675963 :   n <<= bfffo(n);
      38   168675963 :   hiremainder = ~n;
      39   168675963 :   q = divll(~0UL, n);
      40   168675963 :   hiremainder = oldhi;
      41   168675963 :   return q;
      42             : }
      43             : #endif
      44             : 
      45             : INLINE ulong /* requires u1 <= n, n normalised */
      46  2329320924 : divll_pre_normalized(ulong u1, ulong u0, ulong n, ulong ninv, ulong *pt_r)
      47             : {
      48             :   ulong q0, q1, r;
      49             :   LOCAL_HIREMAINDER;
      50             :   LOCAL_OVERFLOW;
      51  2329320924 :   q0 = mulll(ninv, u1); q1 = hiremainder;
      52  2329320924 :   q0 = addll(q0, u0);
      53  2329320924 :   q1 = addllx(q1+1, u1);
      54  2329320924 :   r = u0 - q1 * n;
      55  2329320924 :   if (r > q0)
      56             :   {
      57  1560295572 :     r += n; q1--;
      58             :   }
      59  2329320924 :   if (r >= n)
      60             :   {
      61     3239410 :     r -= n; q1++;
      62             :   }
      63  2329320924 :   *pt_r = r; return q1;
      64             : }
      65             : 
      66             : INLINE ulong /* requires u1 <= n, n normalised */
      67 10798488191 : remll_pre_normalized(ulong u1, ulong u0, ulong n, ulong ninv)
      68             : {
      69             :   ulong q0, q1, r;
      70             :   LOCAL_HIREMAINDER;
      71             :   LOCAL_OVERFLOW;
      72 10798488191 :   q0 = mulll(ninv, u1); q1 = hiremainder;
      73 10798488191 :   q0 = addll(q0, u0);
      74 10798488191 :   q1 = addllx(q1, u1);
      75 10798488191 :   r = u0 - (q1 + 1) * n;
      76 10798488191 :   if (r >= q0)
      77  8080920457 :     r += n;
      78 10798488191 :   return r < n ? r : r - n;
      79             : }
      80             : 
      81             : INLINE ulong /* reduce <a_hi, a_lo> mod n */
      82 10687824956 : remll_pre(ulong a_hi, ulong a_lo, ulong n, ulong ninv)
      83             : {
      84 10687824956 :   int norm = bfffo(n);
      85 10687824956 :   int bits = BITS_IN_LONG - norm;
      86 10687824956 :   ulong sn = n << norm;
      87 10687824956 :   if (a_hi >= n) /* reduce a_hi first */
      88             :   {
      89     8684792 :     const ulong u1 = norm ? a_hi >> bits : 0;
      90     8684792 :     const ulong u0 = a_hi << norm;
      91     8684792 :     a_hi = remll_pre_normalized(u1, u0, sn, ninv) >> norm;
      92             :   }
      93             :   /* now reduce <a_hi, a_lo> */
      94             :   {
      95 10687835956 :     const ulong u1 = ((a_hi << norm) | (norm ? a_lo >> bits: 0));
      96 10687835956 :     const ulong u0 =   a_lo << norm;
      97 10687835956 :     return remll_pre_normalized(u1, u0, sn, ninv) >> norm;
      98             :   }
      99             : }
     100             : 
     101             : #if !defined(INLINE)
     102             : extern ulong divll_pre(ulong a_lo, ulong n, ulong ninv);
     103             : #else
     104             : 
     105             : #if defined(__GNUC__) && !defined(DISABLE_INLINE)
     106             : #define divll_pre(a, n, ninv)                                           \
     107             : __extension__ ({                                                        \
     108             :   ulong __a = (a);                                                      \
     109             :   ulong __n = (n);                                                      \
     110             :   int norm = bfffo(__n);                                                \
     111             :   int bits = BITS_IN_LONG - norm;                                       \
     112             :   ulong r, sn = __n << norm;                                            \
     113             :   const ulong u1 = ((hiremainder << norm) | (norm ? __a >> bits: 0));   \
     114             :   const ulong u0 = __a << norm;                                         \
     115             :   const ulong q = divll_pre_normalized(u1, u0, sn, ninv, &r);           \
     116             :   hiremainder = r>>norm; q;                                             \
     117             :               })
     118             : 
     119             : #else /* __GNUC__ */
     120             : INLINE ulong
     121   572149035 : divll_pre(ulong a_lo, ulong n, ulong ninv)
     122             : {
     123   572149035 :   int norm = bfffo(n);
     124   572149035 :   int bits = BITS_IN_LONG - norm;
     125   572149035 :   ulong r, sn = n << norm;
     126   572149035 :   const ulong u1 = ((hiremainder << norm) | (norm ? a_lo >> bits: 0));
     127   572149035 :   const ulong u0 = a_lo << norm;
     128   572149035 :   const ulong q  = divll_pre_normalized(u1, u0, sn, ninv, &r);
     129   572149035 :   hiremainder = r>>norm; return q;
     130             : }
     131             : #endif /* __GNUC__ */
     132             : 
     133             : #endif

Generated by: LCOV version 1.11