Changeset 2ded87 in git


Ignore:
Timestamp:
Nov 13, 2014, 11:38:57 PM (9 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
85bd2a6af0f0dbc2125e835be461c105507f8e55
Parents:
13079719da06e518c20fdb2a9e05c26bff4e8cf4
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-11-13 23:38:57+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-11-17 20:53:53+01:00
Message:
Added statistic counting to Syzygy computation inside syzextra

added: a macro RTIMER_BENCHMARKING which if option(prot) will cause the output of timestamps around the most important calls
Location:
Singular/dyn_modules/syzextra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/syzextra/syzextra.cc

    r130797 r2ded87  
    1414/*****************************************************************************/
    1515
     16#include <string.h>
     17
    1618// include header file
    1719#include <kernel/mod2.h>
     
    5557#include <stdio.h>
    5658#include <stdlib.h>
    57 #include <string.h>
    58 
    59 #define NOPRODUCT 1
     59
     60#ifndef RTIMER_BENCHMARKING
     61# define RTIMER_BENCHMARKING 0
     62#endif
    6063
    6164// USING_NAMESPACE_SINGULARXX;
     
    612615      assume( 0 <= k && k <= 3 );
    613616
    614       if( __PROT__ )
    615         pp[k]++;
     617      pp[k]++; // collect stats
    616618
    617619      if( k )
     
    642644
    643645  if( __PROT__ )
     646  {
    644647    Print("(PP/ST: {c: %lu, C: %lu, P: %lu} + %lu)", pp[1], pp[2], pp[3], pp[0]);
    645 
    646  
    647 }
     648    m_stat[0] += pp [0]; m_stat[1] += pp [1]; m_stat[2] += pp [2]; m_stat[3] += pp [3];
     649  }
     650}
     651
    648652/*
    649653  m_idTailTerms.resize( IDELEMS(idTails) );
     
    671675*/
    672676
     677void SchreyerSyzygyComputation::PrintStats() const
     678{
     679  Print("SchreyerSyzygyComputation Stats: (PP/ST: {c: %lu, C: %lu, P: %lu} + %lu, LOT: %lu, LCM: %lu, ST:%lu, LK: %lu {*: %lu})\n",
     680        m_stat[1], m_stat[2], m_stat[3], m_stat[0],
     681        m_stat[4], m_stat[5],
     682        m_stat[8],
     683        m_stat[6] + m_stat[7], m_stat[7]
     684       );
     685}
    673686
    674687
     
    10781091
    10791092  assume( IDELEMS(L) == IDELEMS(T) );
    1080 #ifndef SING_NDEBUG
    1081   int t, r;
     1093
     1094#ifdef SING_NDEBUG
     1095  int t, r; // for rtimer benchmarking in prot realease mode
    10821096#endif
    10831097
     
    10851099    Print("\n{ \"syzygylayer\": \"%d\", \"hybridnf\": \"%d\", \"diagrams\": \n[", __SYZNUMBER__, __HYBRIDNF__ );
    10861100 
    1087   if( __PROT__ )
    1088     Print("SYZ{%d}:", __SYZNUMBER__ );
     1101  if( __PROT__ ) Print("\n[%d]", __SYZNUMBER__ );
    10891102
    10901103  if( m_syzLeads == NULL )
    10911104  {
    1092 #ifndef SING_NDEBUG
    1093     if( __PROT__ )
    1094     {
     1105    if( __PROT__ & RTIMER_BENCHMARKING )
     1106    {
     1107#ifdef SING_NDEBUG
    10951108      t = getTimer(); r = getRTimer();
    10961109      Print("\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", r, t, r);
    1097     }
    1098 #endif
     1110#endif
     1111    }
    10991112    ComputeLeadingSyzygyTerms( __LEAD2SYZ__ && !__IGNORETAILS__ ); // 2 terms OR 1 term!
    1100 #ifndef SING_NDEBUG
    1101     if( __PROT__ )
    1102     {
     1113    if( __PROT__ & RTIMER_BENCHMARKING )
     1114    {
     1115#ifdef SING_NDEBUG
    11031116      t = getTimer() - t; r = getRTimer() - r;
    11041117      Print("\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: dt: %d, dr: %d\n", getRTimer(), t, r);
    1105     }
    1106 #endif
     1118#endif
     1119    }
    11071120
    11081121  }
     
    11251138  const bool method = (__HYBRIDNF__  == 1); //  || (__HYBRIDNF__ == 2 && __SYZNUMBER__ < 3);
    11261139
    1127   if( __PROT__ )
    1128      {
    1129         if (method)
    1130           Print("(NF:PR, %s)", (NOPRODUCT == 1)? "*_*": "-*-" );
    1131         else
    1132           Print("(NF:TT, %s)", (NOPRODUCT == 1)? "*_*": "-*-" );
    1133      }
     1140  if( __PROT__ ) Print("[%s NF|%s]",(method) ? "PR" : "TT", (NOPRODUCT == 1)? "_,_": "^*^" );
    11341141   
    1135    
    11361142
    11371143  if(  !__IGNORETAILS__)
     
    11391145    if( T != NULL )
    11401146    {
    1141 #ifndef SING_NDEBUG
    1142       if( __PROT__ )
     1147      if( __PROT__ & RTIMER_BENCHMARKING )
    11431148      {
     1149#ifdef SING_NDEBUG
    11441150        t = getTimer(); r = getRTimer();
    11451151        Print("\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): t: %d, r: %d\n", r, t, r);
     1152#endif
    11461153      }
    1147 #endif
    11481154
    11491155      SetUpTailTerms();
    11501156       
    1151 #ifndef SING_NDEBUG
    1152       if( __PROT__ )
     1157#ifdef SING_NDEBUG
     1158      if( __PROT__ & RTIMER_BENCHMARKING )
    11531159      {
    11541160        t = getTimer() - t; r = getRTimer() - r;
     
    11591165  }
    11601166
    1161 #ifndef SING_NDEBUG
    1162   if( __PROT__ )
     1167#ifdef SING_NDEBUG
     1168  if( __PROT__ & RTIMER_BENCHMARKING )
    11631169  {
    11641170    t = getTimer(); r = getRTimer();
     
    12751281        assume( vp == NULL );
    12761282
    1277       if( __PROT__ && (vp != NULL) )
    1278         Print("!%d!", k); // check k'th syzygy failed
     1283      if( __PROT__ && (vp != NULL) ) Warn("ERROR: SyzCheck failed, wrong tail: [%d]\n\n", k); // check k'th syzygy failed
    12791284     
    12801285      p_Delete(&vp, R);
     
    12901295  }
    12911296
    1292 #ifndef SING_NDEBUG
    1293     if( __PROT__ )
    1294     {
    1295       t = getTimer() - t; r = getRTimer() - r;
    1296       Print("\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: dt: %d, dr: %d\n", getRTimer(), t, r);
    1297     }
    1298 #endif
     1297  if( __PROT__ & RTIMER_BENCHMARKING )
     1298  {
     1299#ifdef SING_NDEBUG
     1300    t = getTimer() - t; r = getRTimer() - r;
     1301    Print("\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: dt: %d, dr: %d\n", getRTimer(), t, r);
     1302#endif
     1303  }
    12991304
    13001305  TT->rank = id_RankFreeModule(TT, R);
     
    13031308    PrintS("\n]},");
    13041309 
    1305   if( __PROT__ )
    1306     PrintLn();
     1310  if( __PROT__ ) PrintLn();
    13071311}
    13081312
     
    13511355  }
    13521356
    1353   if( __PROT__ )
    1354     Print("[L%dS:%d]", bComputeSecondTerms ? 2 : 1, IDELEMS(m_syzLeads));
     1357  if( __PROT__ ) Print("(L%dS:%d)", bComputeSecondTerms ? 2 : 1, IDELEMS(m_syzLeads));
    13551358     
    13561359}
     
    14871490    } // otherwise discard that leading term altogether!
    14881491    else
    1489       if( __PROT__ )
    1490         PrintS("$"); // LOT
     1492      if( __PROT__ ) ++ m_stat[4]; // PrintS("$"); // LOT
    14911493   
    14921494    kbTest(bucket);
     
    16081610         }
    16091611         
    1610          if( __PROT__ )
    1611            PrintS("l*"); // lookup & rescale
    1612            
     1612         if( __PROT__ ) ++ m_stat[7]; // PrintS("l*"); // lookup & rescale
    16131613         
    16141614         p = p_Mult_nn(p, n, r); // !
    16151615         n_Delete(&n, r);       
    16161616       } else
    1617          if( __PROT__ )
    1618            PrintS("l"); // lookup no rescale
    1619        
     1617         if( __PROT__ ) ++ m_stat[6]; // PrintS("l"); // lookup no rescale       
    16201618
    16211619       if( __TREEOUTPUT__ )
     
    16441642     }
    16451643
    1646      if( __PROT__ )
    1647        PrintS("S"); // store
     1644     if( __PROT__ ) ++ m_stat[8]; // PrintS("S"); // store
    16481645
    16491646     T.insert( TP2PCache::value_type(p_Copy(multiplier, r), p) ); //     T[ multiplier ] = p;
     
    16771674  }
    16781675
    1679   if( __PROT__ )
    1680     PrintS("S"); // %d", tail + 1);
     1676  if( __PROT__ ) ++ m_stat[8]; // PrintS("S"); // store // %d", tail + 1);
    16811677 
    16821678  T.insert( TP2PCache::value_type(p_Copy(multiplier, r), p) );
     
    17561752  if(!(  (!__TAILREDSYZ__)   ||   m_lcm.Check(multiplier)     ))
    17571753  {
    1758     if( __TAILREDSYZ__ && __PROT__ )
    1759       PrintS("%"); // check LCM !
     1754    if( __TAILREDSYZ__ && __PROT__ ) ++ m_stat[5]; // PrintS("%"); // check LCM !
    17601755   
    17611756    return NULL;
     
    18721867    if( s == NULL ) // No Reducer?
    18731868    {     
    1874       if( __PROT__ )
    1875         PrintS("$" ); // LOT?!
     1869      if( __PROT__ ) ++ m_stat[4]; // PrintS("$"); // LOT
    18761870     
    18771871      return s;
     
    18921886    if( s == NULL ) // No Reducer?
    18931887    {
    1894       if( __PROT__ )
    1895         PrintS("$" ); // LOT?!
     1888      if( __PROT__ ) ++ m_stat[4]; // PrintS("$"); // LOT
    18961889
    18971890      return s;
     
    19171910  if( s == NULL ) // No Reducer?
    19181911  {
    1919     if( __TAILREDSYZ__&& __PROT__ )
    1920       PrintS("%" ); // LCM check
     1912    if( __TAILREDSYZ__ && __PROT__ ) ++ m_stat[5]; // PrintS("%"); // check LCM !
    19211913   
    19221914    return s;
  • Singular/dyn_modules/syzextra/syzextra.h

    r130797 r2ded87  
    1919#include <vector>
    2020#include <map>
     21#include <string.h>
    2122
    2223// include basic definitions
     
    264265        m_sum_bucket(NULL), m_spoly_bucket(NULL)
    265266    {
     267      if( __PROT__ ) memset( &m_stat, 0, sizeof(m_stat) );
    266268    }
    267269
     
    275277        m_sum_bucket(NULL), m_spoly_bucket(NULL)
    276278    {
     279      if( __PROT__ ) memset( &m_stat, 0, sizeof(m_stat) );
     280     
    277281      if( __TAILREDSYZ__ && !__IGNORETAILS__)
    278282      {
     
    291295    void SetUpTailTerms();
    292296
     297    /// print statistics about the used heuristics
     298    void PrintStats() const;
     299
    293300    /// Read off the results while detaching them from this object
    294301    /// NOTE: no copy!
     
    298305
    299306      m_syzLeads = m_syzTails = NULL; // m_LS ?
     307     
     308      if ( __PROT__ )
     309        PrintStats();
    300310    }
     311
    301312
    302313    /// The main driver function: computes
     
    401412};
    402413
     414   
     415    /// Statistics:
     416    ///  0..3: as in SetUpTailTerms()::PreProcessTerm() // TODO!!??
     417    ///  4: number of terms discarded due to LOT heuristics
     418    ///  5: number of terms discarded due to LCM heuristics
     419    ///  6, 7: lookups without & with rescale, 8: stores
     420    mutable unsigned long m_stat[9];
     421};
    403422
    404423// The following wrappers are just for testing separate functions on highest level (within schreyer.lib)
Note: See TracChangeset for help on using the changeset viewer.