Changeset 23221


Ignore:
Timestamp:
09/05/18 09:58:54 (7 years ago)
Author:
Mathieu Morlighem
Message:

CHG: added core solution profiling

Location:
issm/trunk-jpl/src/c
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/classes/FemModel.cpp

    r23173 r23221  
    254254        /*Before we delete the profiler, report statistics for this run: */
    255255        profiler->Stop(TOTAL);  //final tagging
     256
    256257        _printf0_("\n");
    257         _printf0_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->TotalTime(MPROCESSOR) << "\n");
    258         _printf0_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->TotalTime(CORE) << "\n");
    259         _printf0_("   "<<setw(40)<<left<<"Solver elapsed time:"<<profiler->TotalTime(SOLVER) << "\n");
     258        _printf0_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<setw(7)<<profiler->TotalTime(MPROCESSOR) << "\n");
     259        /*Total times*/
     260        _printf0_("   "<<setw(40)<<left<<"Total Core solution elapsed time:"<<setw(7)<<profiler->TotalTime(CORE) << "\n");
     261        /*Individual cores*/
     262        if(profiler->Used(STRESSBALANCECORE)) _printf0_("   "<<setw(40)<<left<<"Stress balance core elapsed time:"<<setw(7)<<profiler->TotalTime(STRESSBALANCECORE) << "\n");
     263        if(profiler->Used(MASSTRANSPORTCORE)) _printf0_("   "<<setw(40)<<left<<"Mass transport core elapsed time:"<<setw(7)<<profiler->TotalTime(MASSTRANSPORTCORE) << "\n");
     264        /*Linear solver only*/
     265        _printf0_("   "<<setw(40)<<left<<"Linear solver elapsed time:"<<setw(7)<<profiler->TotalTime(SOLVER) << " ("<<setprecision(2)<<profiler->TotalTime(SOLVER)/profiler->TotalTime(CORE)*100.<<"%)\n");
    260266        _printf0_("\n");
    261267        _printf0_("   Total elapsed time: "
  • TabularUnified issm/trunk-jpl/src/c/classes/Profiler.cpp

    r23066 r23221  
    1515/*Profiler constructors and destructors:*/
    1616Profiler::Profiler(){/*{{{*/
    17         for(int i=0;i<MAXIMUMSIZE;i++){
     17        for(int i=0;i<MAXPROFSIZE;i++){
    1818                this->time[i]          = 0.;
    1919                this->time_start[i]    = 0.;
     
    2323                this->memory_start[i]  = 0.;
    2424                this->running[i]       = false;
     25                this->used[i]          = false;
    2526        }
    2627} /*}}}*/
     
    3233        Profiler* output=new Profiler();
    3334
    34         for(int i=0;i<MAXIMUMSIZE;i++){
     35        for(int i=0;i<MAXPROFSIZE;i++){
    3536                output->time[i]  =this->time[i];
    3637                output->flops[i] =this->flops[i];
     
    4950
    5051        _printf_("Profiler:\n");
    51         for(int i=0;i<MAXIMUMSIZE;i++){
     52        for(int i=0;i<MAXPROFSIZE;i++){
    5253                _printf_("    Tag "<<i<<":\n");
    5354                _printf_("       flops:   "<<this->flops[i]<<"\n");
     
    7071        MARSHALLING_ENUM(ProfilerEnum);
    7172        pointer = &this->time[0];
    72         MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXIMUMSIZE);
     73        MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE);
    7374        pointer = &this->flops[0];
    74         MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXIMUMSIZE);
     75        MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE);
    7576        pointer = &this->memory[0];
    76         MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXIMUMSIZE);
     77        MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE);
    7778        bpointer = &this->running[0];
    78         MARSHALLING_DYNAMIC(bpointer,bool,MAXIMUMSIZE);
     79        MARSHALLING_DYNAMIC(bpointer,bool,MAXPROFSIZE);
    7980
    8081} /*}}}*/
     
    8889        /*Get tag*/
    8990        _assert_(tag>=0);
    90         _assert_(tag<MAXIMUMSIZE);
     91        _assert_(tag<MAXPROFSIZE);
    9192        if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped");
    9293
     
    9798        /*Get tag*/
    9899        _assert_(tag>=0);
    99         _assert_(tag<MAXIMUMSIZE);
     100        _assert_(tag<MAXPROFSIZE);
    100101        if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped");
    101102
     
    130131        /*Get initial flops*/
    131132        _assert_(tag>=0);
    132         _assert_(tag<MAXIMUMSIZE);
     133        _assert_(tag<MAXPROFSIZE);
    133134        if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped");
    134135
     
    140141        /*Check tag*/
    141142        _assert_(tag>=0);
    142         _assert_(tag<MAXIMUMSIZE);
     143        _assert_(tag<MAXPROFSIZE);
    143144        if(this->running[tag]) _error_("Tag "<<tag<<" is already running");
    144145
     
    167168        /*Plug into this->time: */
    168169        _assert_(tag>=0);
    169         _assert_(tag<MAXIMUMSIZE);
     170        _assert_(tag<MAXPROFSIZE);
    170171        this->time_start[tag]   = t;
    171172        this->flops_start[tag]  = f;
     
    174175        /*turn on running*/
    175176        this->running[tag] = true;
     177        this->used[tag]    = true;
    176178}/*}}}*/
    177179void  Profiler::Stop(int tag,bool dontmpisync){/*{{{*/
     
    179181        /*Check tag*/
    180182        _assert_(tag>=0);
    181         _assert_(tag<MAXIMUMSIZE);
     183        _assert_(tag<MAXPROFSIZE);
    182184        if(!this->running[tag]) _error_("Tag "<<tag<<" is not running");
    183185
     
    206208        /*Plug into this->time: */
    207209        _assert_(tag>=0);
    208         _assert_(tag<MAXIMUMSIZE);
     210        _assert_(tag<MAXPROFSIZE);
    209211        this->time[tag]   += t - this->time_start[tag];
    210212        this->flops[tag]  += f - this->flops_start[tag];
     
    214216        this->running[tag] = false;
    215217}/*}}}*/
     218bool  Profiler::Used(int tag){/*{{{*/
     219
     220        /*Check tag*/
     221        _assert_(tag>=0);
     222        _assert_(tag<MAXPROFSIZE);
     223        return this->used[tag];
     224}/*}}}*/
  • TabularUnified issm/trunk-jpl/src/c/classes/Profiler.h

    r22551 r23221  
    1111
    1212/*Macros*/
    13 #define TOTAL 0      /*Profiling Total time */
    14 #define MPROCESSOR 1 /*Profiling Model processor*/
    15 #define CORE 2       /*Profiling solution */
    16 #define SOLVER 3     /*Profiling solution */
    17 #define ADCORE 4     /*Profiling AD */
    18 #define MAXIMUMSIZE 5
     13#define TOTAL              0 /*Profiling Total time */
     14#define MPROCESSOR         1 /*Profiling Model processor*/
     15#define CORE               2 /*Profiling solution */
     16#define SOLVER             3 /*Profiling solution */
     17#define ADCORE             4 /*Profiling AD */
     18#define STRESSBALANCECORE  5 /*Profiling AD */
     19#define MASSTRANSPORTCORE  6 /*Profiling AD */
     20#define MAXPROFSIZE        7 /*Used to initialize static arrays*/
    1921
    2022class Profiler: public Object{
    2123
    2224        public:
    23                 IssmPDouble flops[MAXIMUMSIZE];
    24                 IssmPDouble flops_start[MAXIMUMSIZE];
    25                 IssmPDouble memory[MAXIMUMSIZE];
    26                 IssmPDouble memory_start[MAXIMUMSIZE];
    27                 IssmPDouble time[MAXIMUMSIZE];
    28                 IssmPDouble time_start[MAXIMUMSIZE];
    29                 bool        running[MAXIMUMSIZE];
     25                IssmPDouble flops[MAXPROFSIZE];
     26                IssmPDouble flops_start[MAXPROFSIZE];
     27                IssmPDouble memory[MAXPROFSIZE];
     28                IssmPDouble memory_start[MAXPROFSIZE];
     29                IssmPDouble time[MAXPROFSIZE];
     30                IssmPDouble time_start[MAXPROFSIZE];
     31                bool        running[MAXPROFSIZE];
     32                bool        used[MAXPROFSIZE];
    3033
    3134                /*Profiler constructors, destructors */
     
    5053                void         Start(int tagenum,bool dontmpisync=false);
    5154                void         Stop(int tagenum,bool dontmpisync=false);
     55                bool         Used(int tagenum);
    5256};
    5357
  • TabularUnified issm/trunk-jpl/src/c/cores/masstransport_core.cpp

    r23066 r23221  
    1111
    1212void masstransport_core(FemModel* femmodel){
     13
     14        /*Start profiler*/
     15        femmodel->profiler->Start(MASSTRANSPORTCORE);
    1316
    1417        /*parameters: */
     
    8184        /*Free ressources:*/
    8285        if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);}
     86
     87        /*profiler*/
     88        femmodel->profiler->Stop(MASSTRANSPORTCORE);
    8389}
  • TabularUnified issm/trunk-jpl/src/c/cores/stressbalance_core.cpp

    r23215 r23221  
    1212
    1313void stressbalance_core(FemModel* femmodel){
     14
     15        /*Start profiler*/
     16        femmodel->profiler->Start(STRESSBALANCECORE);
    1417
    1518        /*parameters: */
     
    8689        /*Free ressources:*/   
    8790        if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);}
     91
     92        /*End profiler*/
     93        femmodel->profiler->Stop(STRESSBALANCECORE);
    8894}
Note: See TracChangeset for help on using the changeset viewer.