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-bordeaux1.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 - mulll.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 16741-1378b1c) Lines: 25 25 100.0 %
Date: 2014-08-17 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : #line 2 "../src/kernel/none/mulll.h"
       2                 :            : /* Copyright (C) 2000  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                 :            : #define LOCAL_HIREMAINDER
      17                 :            : extern ulong hiremainder;
      18                 :            : 
      19                 :            : /* Version Peter Montgomery */
      20                 :            : /*
      21                 :            :  *      Assume (for presentation) that BITS_IN_LONG = 32.
      22                 :            :  *      Then 0 <= xhi, xlo, yhi, ylo <= 2^16 - 1.  Hence
      23                 :            :  *
      24                 :            :  * -2^31 + 2^16 <= (xhi-2^15)*(ylo-2^15) + (xlo-2^15)*(yhi-2^15) <= 2^31.
      25                 :            :  *
      26                 :            :  *      If xhi*ylo + xlo*yhi = 2^32*overflow + xymid, then
      27                 :            :  *
      28                 :            :  * -2^32 + 2^16 <= 2^32*overflow + xymid - 2^15*(xhi + ylo + xlo + yhi) <= 0.
      29                 :            :  *
      30                 :            :  * 2^16*overflow <= (xhi+xlo+yhi+ylo)/2 - xymid/2^16 <= 2^16*overflow + 2^16-1
      31                 :            :  *
      32                 :            :  *       This inequality was derived using exact (rational) arithmetic;
      33                 :            :  *       it remains valid when we truncate the two middle terms.
      34                 :            :  */
      35                 :            : 
      36                 :            : #if !defined(INLINE)
      37                 :            : extern long mulll(ulong x, ulong y);
      38                 :            : extern long addmul(ulong x, ulong y);
      39                 :            : #else
      40                 :            : 
      41                 :            : #if defined(__GNUC__) && !defined(DISABLE_INLINE)
      42                 :            : #undef LOCAL_HIREMAINDER
      43                 :            : #define LOCAL_HIREMAINDER register ulong hiremainder
      44                 :            : 
      45                 :            : #define mulll(x, y) \
      46                 :            : __extension__ ({ \
      47                 :            :   const ulong __x = (x), __y = (y);\
      48                 :            :   const ulong __xlo = LOWWORD(__x), __xhi = HIGHWORD(__x); \
      49                 :            :   const ulong __ylo = LOWWORD(__y), __yhi = HIGHWORD(__y); \
      50                 :            :   ulong __xylo,__xymid,__xyhi,__xymidhi,__xymidlo; \
      51                 :            :   ulong __xhl,__yhl; \
      52                 :            :  \
      53                 :            :   __xylo = __xlo*__ylo; __xyhi = __xhi*__yhi; \
      54                 :            :   __xhl = __xhi+__xlo; __yhl = __yhi+__ylo; \
      55                 :            :   __xymid = __xhl*__yhl - (__xyhi+__xylo); \
      56                 :            :  \
      57                 :            :   __xymidhi = HIGHWORD(__xymid); \
      58                 :            :   __xymidlo = __xymid << BITS_IN_HALFULONG; \
      59                 :            :  \
      60                 :            :   __xylo += __xymidlo; \
      61                 :            :   hiremainder = __xyhi + __xymidhi + (__xylo < __xymidlo) \
      62                 :            :      + ((((__xhl + __yhl) >> 1) - __xymidhi) & HIGHMASK); \
      63                 :            :  \
      64                 :            :   __xylo; \
      65                 :            : })
      66                 :            : 
      67                 :            : #define addmul(x, y) \
      68                 :            : __extension__ ({                                           \
      69                 :            :   const ulong __x = (x), __y = (y);\
      70                 :            :   const ulong __xlo = LOWWORD(__x), __xhi = HIGHWORD(__x); \
      71                 :            :   const ulong __ylo = LOWWORD(__y), __yhi = HIGHWORD(__y); \
      72                 :            :   ulong __xylo,__xymid,__xyhi,__xymidhi,__xymidlo; \
      73                 :            :   ulong __xhl,__yhl; \
      74                 :            :  \
      75                 :            :   __xylo = __xlo*__ylo; __xyhi = __xhi*__yhi; \
      76                 :            :   __xhl = __xhi+__xlo; __yhl = __yhi+__ylo; \
      77                 :            :   __xymid = __xhl*__yhl - (__xyhi+__xylo); \
      78                 :            :  \
      79                 :            :   __xylo += hiremainder; __xyhi += (__xylo < hiremainder); \
      80                 :            :  \
      81                 :            :   __xymidhi = HIGHWORD(__xymid); \
      82                 :            :   __xymidlo = __xymid << BITS_IN_HALFULONG; \
      83                 :            :  \
      84                 :            :   __xylo += __xymidlo; \
      85                 :            :   hiremainder = __xyhi + __xymidhi + (__xylo < __xymidlo) \
      86                 :            :      + ((((__xhl + __yhl) >> 1) - __xymidhi) & HIGHMASK); \
      87                 :            :  \
      88                 :            :   __xylo; \
      89                 :            : })
      90                 :            : 
      91                 :            : #else
      92                 :            : 
      93                 :            : INLINE long
      94                 : 3149727793 : mulll(ulong x, ulong y)
      95                 :            : {
      96                 : 3149727793 :   const ulong xlo = LOWWORD(x), xhi = HIGHWORD(x);
      97                 : 3149727793 :   const ulong ylo = LOWWORD(y), yhi = HIGHWORD(y);
      98                 :            :   ulong xylo,xymid,xyhi,xymidhi,xymidlo;
      99                 :            :   ulong xhl,yhl;
     100                 :            : 
     101                 : 3149727793 :   xylo = xlo*ylo; xyhi = xhi*yhi;
     102                 : 3149727793 :   xhl = xhi+xlo; yhl = yhi+ylo;
     103                 : 3149727793 :   xymid = xhl*yhl - (xyhi+xylo);
     104                 :            : 
     105                 : 3149727793 :   xymidhi = HIGHWORD(xymid);
     106                 : 3149727793 :   xymidlo = xymid << BITS_IN_HALFULONG;
     107                 :            : 
     108                 : 3149727793 :   xylo += xymidlo;
     109                 : 6299455586 :   hiremainder = xyhi + xymidhi + (xylo < xymidlo)
     110                 : 3149727793 :      + ((((xhl + yhl) >> 1) - xymidhi) & HIGHMASK);
     111                 :            : 
     112                 : 3149727793 :   return xylo;
     113                 :            : }
     114                 :            : 
     115                 :            : INLINE long
     116                 :10876344193 : addmul(ulong x, ulong y)
     117                 :            : {
     118                 :10876344193 :   const ulong xlo = LOWWORD(x), xhi = HIGHWORD(x);
     119                 :10876344193 :   const ulong ylo = LOWWORD(y), yhi = HIGHWORD(y);
     120                 :            :   ulong xylo,xymid,xyhi,xymidhi,xymidlo;
     121                 :            :   ulong xhl,yhl;
     122                 :            : 
     123                 :10876344193 :   xylo = xlo*ylo; xyhi = xhi*yhi;
     124                 :10876344193 :   xhl = xhi+xlo; yhl = yhi+ylo;
     125                 :10876344193 :   xymid = xhl*yhl - (xyhi+xylo);
     126                 :            : 
     127                 :10876344193 :   xylo += hiremainder; xyhi += (xylo < hiremainder);
     128                 :            : 
     129                 :10876344193 :   xymidhi = HIGHWORD(xymid);
     130                 :10876344193 :   xymidlo = xymid << BITS_IN_HALFULONG;
     131                 :            : 
     132                 :10876344193 :   xylo += xymidlo;
     133                 :21752688386 :   hiremainder = xyhi + xymidhi + (xylo < xymidlo)
     134                 :10876344193 :      + ((((xhl + yhl) >> 1) - xymidhi) & HIGHMASK);
     135                 :            : 
     136                 :10876344193 :   return xylo;
     137                 :            : }
     138                 :            : #endif
     139                 :            : 
     140                 :            : #endif

Generated by: LCOV version 1.9