Changeset 87bc94 in git


Ignore:
Timestamp:
Jul 22, 2020, 10:55:26 AM (4 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
4f08da74fad4e958f39dc85215b1f8be54d030f8
Parents:
6f87075ce049200dd1513865e0d9cfb1dd263987
Message:
opt: better inlining for coeffs
Location:
libpolys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/modulop.h

    r6f8707 r87bc94  
    169169}
    170170
    171 static inline BOOLEAN npIsZeroM (number  a, const coeffs)
    172 {
    173   return 0 == (long)a;
    174 }
    175171static inline BOOLEAN npIsOne (number a, const coeffs)
    176172{
  • libpolys/coeffs/modulop_inl.h

    r6f8707 r87bc94  
    3535}
    3636
     37#define npIsZeroM(A,B) (0==(long)A)
    3738static inline BOOLEAN npIsZero (number  a, const coeffs r)
    3839{
    3940  n_Test(a, r);
    4041
    41   return 0 == (long)a;
     42  return npIsZeroM(a,r);
    4243}
    4344
  • libpolys/polys/templates/p_Numbers.h

    r6f8707 r87bc94  
    5656#define n_Sub_RingGeneral(n1, n2, r)       n_Sub_FieldGeneral(n1, n2, r)
    5757#define n_InpMult_RingGeneral(n1, n2, r)   n_InpMult_FieldGeneral(n1, n2, r)
    58 
    59 static FORCE_INLINE void n_InpAdd_RingGeneral(number &n1, number n2, const coeffs r)
    60 {  assume(nCoeff_is_Ring(r)); n_InpAdd(n1, n2, r); }
     58#define n_InpAdd_RingGeneral(n1,n2,r)      n_InpAdd(n1, n2, r)
    6159#endif
    6260
    6361#include "coeffs/modulop.h"
     62#include "coeffs/modulop_inl.h"
    6463
    6564#define n_Copy_FieldZp(n, r)        n
    6665#define n_Delete_FieldZp(n, r)      do {} while (0)
    67 
    68 static FORCE_INLINE number n_Mult_FieldZp(number n1, number n2, const coeffs r)
    69 { STATISTIC(n_Mult); return npMultM(n1, n2, r); }
    70 
    71 #ifdef HAVE_NUMSTATS
    72 static FORCE_INLINE number n_Add_FieldZp(number n1, number n2, const coeffs r)
    73 { STATISTIC(n_Add); const number sum = npAddM(n1, n2, r);
    74   // avoid double counting
    75   if( npIsZeroM(sum,r) ) STATISTIC(n_CancelOut);
    76   return sum;
    77 }
    78 #else
    79 static FORCE_INLINE number n_Add_FieldZp(number n1, number n2, const coeffs r)
    80 { return npAddM(n1, n2, r); }
    81 #endif
    82 
    83 #ifdef HAVE_NUMSTATS
    84 static FORCE_INLINE number n_Sub_FieldZp(number n1, number n2, const coeffs r)
    85 { STATISTIC(n_Sub); const number d = npSubM(n1, n2, r);
    86   // avoid double counting
    87   if( npIsZeroM(d,r) ) STATISTIC(n_CancelOut);
    88   return d;
    89 }
    90 #else
    91 static FORCE_INLINE number n_Sub_FieldZp(number n1, number n2, const coeffs r)
    92 { return npSubM(n1, n2, r); }
    93 #endif
    94 
    95 static FORCE_INLINE BOOLEAN n_IsZero_FieldZp(number n, const coeffs r)
    96 { STATISTIC(n_IsZero); return npIsZeroM(n, r); }
    97 
    98 static FORCE_INLINE BOOLEAN n_Equal_FieldZp(number n1, number n2, const coeffs r)
    99 { STATISTIC(n_Equal); return  npEqualM(n1, n2, r); }
    100 
    101 static FORCE_INLINE number n_Neg_FieldZp(number n, const coeffs r)
    102 { STATISTIC(n_InpNeg); return npNegM(n, r); }
    103 
    104 static FORCE_INLINE void n_InpMult_FieldZp(number &n1, number n2, const coeffs r)
    105 { STATISTIC(n_InpMult); npInpMultM(n1, n2, r);  }
    106 
    107 #ifdef HAVE_NUMSTATS
    108 static FORCE_INLINE void n_InpAdd_FieldZp(number &n1, number n2, const coeffs r)
    109 {
    110   STATISTIC(n_InpAdd); n1=npAddM(n1, n2, r);
    111   // avoid double counting
    112   if( npIsZeroM(n1,r) ) STATISTIC(n_CancelOut);
    113 }
    114 #else
    115 static FORCE_INLINE void n_InpAdd_FieldZp(number &n1, number n2, const coeffs r)
    116 { n1=npAddM(n1, n2, r); }
    117 #endif
     66#define n_Mult_FieldZp(n1,n2,r)     npMultM(n1,n2,r)
     67#define n_Add_FieldZp(n1,n2,r)      npAddM(n1,n2,r)
     68#define n_Sub_FieldZp(n1,n2,r)      npSubM(n1,n2,r)
     69#define n_IsZero_FieldZp(n,r)       npIsZeroM(n,r)
     70#define n_Equal_FieldZp(n1,n2,r)    npEqualM(n1,n2,r)
     71#define n_Neg_FieldZp(n,r)          npNegM(n,r)
     72#define n_InpMult_FieldZp(n1,n2,r)  npInpMultM(n1,n2,r)
     73#define n_InpAdd_FieldZp(n1,n2,r)   npInpAddM(n1,n2,r)
    11874
    11975#define DO_LFORCE_INLINE
    12076#include "coeffs/longrat.cc" // for inlining... TODO: fix this Uglyness?!!!
    12177
    122 static FORCE_INLINE number n_Copy_FieldQ(number n, const coeffs r)
    123 { STATISTIC(n_Copy); return nlCopy(n, r); }
    124 
    125 static FORCE_INLINE void   n_Delete_FieldQ(number* n, const coeffs r)
    126 { STATISTIC(n_Delete); nlDelete(n,r); }
    127 
    128 static FORCE_INLINE number n_Mult_FieldQ(number n1, number n2, const coeffs r)
    129 { STATISTIC(n_Mult); return nlMult(n1,n2, r); }
    130 
    131 #ifdef HAVE_NUMSTATS
    132 static FORCE_INLINE number n_Add_FieldQ(number n1, number n2, const coeffs r)
    133 { STATISTIC(n_Add); const number sum = nlAdd(n1, n2, r);
    134   // avoid double counting
    135   if( nlIsZero(sum,r) ) STATISTIC(n_CancelOut);
    136   return sum;
    137 }
    138 #else
    139 static FORCE_INLINE number n_Add_FieldQ(number n1, number n2, const coeffs r)
    140 { return nlAdd(n1, n2, r); }
    141 #endif
    142 
    143 #ifdef HAVE_NUMSTATS
    144 static FORCE_INLINE number n_Sub_FieldQ(number n1, number n2, const coeffs r)
    145 { STATISTIC(n_Sub); const number d = nlSub(n1, n2, r);
    146   // avoid double counting
    147   if( nlIsZero(d,r) ) STATISTIC(n_CancelOut);
    148   return d;
    149 }
    150 #else
    151 static FORCE_INLINE number n_Sub_FieldQ(number n1, number n2, const coeffs r)
    152 { return nlSub(n1, n2, r); }
    153 #endif
    154 
    155 static FORCE_INLINE BOOLEAN n_IsZero_FieldQ(number n, const coeffs r)
    156 { STATISTIC(n_IsZero); return nlIsZero(n, r); }
    157 
    158 static FORCE_INLINE BOOLEAN n_Equal_FieldQ(number n1, number n2, const coeffs r)
    159 { STATISTIC(n_Equal); return  nlEqual(n1, n2, r); }
    160 
    161 static FORCE_INLINE number n_Neg_FieldQ(number n, const coeffs r)
    162 { STATISTIC(n_InpNeg); return nlNeg(n, r); }
    163 
    164 static FORCE_INLINE void n_InpMult_FieldQ(number &n1, number n2, const coeffs r)
    165 { STATISTIC(n_InpMult); nlInpMult(n1, n2, r); }
    166 
    167 #ifdef HAVE_NUMSTATS
    168 static FORCE_INLINE void n_InpAdd_FieldQ(number &n1, number n2, const coeffs r)
    169 { STATISTIC(n_InpAdd); assume(nCoeff_is_Q(r)); nlInpAdd(n1, n2, r);
    170   // avoid double counting
    171   if( nlIsZero(n1,r) ) STATISTIC(n_CancelOut);
    172 }
    173 #else
    174 static FORCE_INLINE void n_InpAdd_FieldQ(number &n1, number n2, const coeffs r)
    175 { nlInpAdd(n1, n2, r); }
    176 #endif
     78#define n_Copy_FieldQ(n,r)          nlCopy(n,r)
     79#define n_Delete_FieldQ(n,r)        nlDelete(n,r)
     80#define n_Mult_FieldQ(n1,n2,r)      nlMult(n1,n2,r)
     81#define n_Add_FieldQ(n1,n2,r)       nlAdd(n1,n2,r)
     82#define n_Sub_FieldQ(n1,n2,r)       nlSub(n1,n2,r)
     83#define n_IsZero_FieldQ(n,r)        nlIsZero(n,r)
     84#define n_Equal_FieldQ(n1,n2,r)     nlEqual(n1,n2,r)
     85#define n_Neg_FieldQ(n,r)           nlNeg(n,r)
     86#define n_InpMult_FieldQ(n1,n2,r)   nlInpMult(n1,n2,r)
     87#define n_InpAdd_FieldQ(n1,n2,r)    nlInpAdd(n1,n2,r)
    17788
    17889#endif
Note: See TracChangeset for help on using the changeset viewer.