Changeset 13539


Ignore:
Timestamp:
10/04/12 16:49:33 (12 years ago)
Author:
Eric.Larour
Message:

CHG:
simplified profiler further.
moved Dakotax to solution/dakota_core and cleanep up the modules/Dakotax code a lot.
also took care of reactivating sharedstring and DescriptorIndex.

Location:
issm/trunk-jpl/src/c
Files:
2 added
6 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r13537 r13539  
    221221                                        ./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\
    222222                                        ./shared/String/sharedstring.h\
     223                                        ./shared/String/DescriptorIndex.cpp\
    223224                                        ./shared/Wrapper/wrappershared.h\
    224225                                        ./shared/Wrapper/ModuleBoot.cpp\
     
    373374                                          ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\
    374375                                          ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\
    375                                           ./modules/Dakotax/Dakotax.h\
    376                                           ./modules/Dakotax/Dakotax.cpp\
    377                                           ./modules/Dakotax/DakotaMPI_Bcast.cpp\
    378                                           ./modules/Dakotax/DakotaFree.cpp\
    379                                           ./modules/Dakotax/SpawnCore.cpp\
    380                                           ./modules/Dakotax/DescriptorIndex.cpp\
    381376                                          ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\
    382                                           ./modules/Dakotax/SpawnCoreParallel.cpp
     377                                          ./solutions/dakota_core.cpp\
     378                                          ./solutions/DakotaSpawnCore.cpp
    383379#}}}
    384380#Transient sources  {{{
  • issm/trunk-jpl/src/c/classes/dakota/DakotaPlugin.cpp

    r12837 r13539  
    8888
    8989        /*run core solution: */
    90         SpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);
     90        DakotaSpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);
    9191
    9292        /*populate responses: */
  • issm/trunk-jpl/src/c/classes/objects/Profiler.cpp

    r13534 r13539  
    1616/*FUNCTION Profiler::Profiler() default constructor {{{*/
    1717Profiler::Profiler(){
    18                  this->timetags=new Parameters();
     18                 this->time=new Parameters();
    1919}
    2020/*}}}*/
    2121/*FUNCTION Profiler::~Profiler(){{{*/
    2222Profiler::~Profiler(){
    23         delete timetags;
     23        delete time;
    2424}
    2525/*}}}*/
     
    3131        _printLine_("Profiler:");
    3232        _printLine_("   time tags: ");
    33         this->timetags->Echo();
     33        this->time->Echo();
    3434
    3535}
     
    4040        _printLine_("Profiler:");
    4141        _printLine_("   time tags: ");
    42         this->timetags->DeepEcho();
     42        this->time->DeepEcho();
    4343
    4444}
     
    5959void  Profiler::Tag(int tagenum,bool dontmpisync){
    6060
    61         double time;
     61        IssmDouble t;
     62        IssmDouble f;
     63        IssmDouble m;
    6264
    6365        /*If mpisync requested, make sure all the cpus are at the same point
     
    6971        }
    7072
    71         /*Now capture time: */
     73        /*Capture time: */
    7274        #ifdef _HAVE_MPI_
    73         time=MPI_Wtime();
     75        t=MPI_Wtime();
    7476        #else
    75         time=(IssmPDouble)clock();
     77        t=(IssmPDouble)clock();
    7678        #endif
    7779
    78         /*Plug into this->timetags: */
    79         this->timetags->AddObject(new DoubleParam(tagenum,time));
     80        /*Capture flops: */
     81        #ifdef _HAVE_PETSC_
     82                PetscGetFlops(&f);
     83                PetscMemoryGetCurrentUsage(&m);
     84        #else
     85                /*do nothing for now:*/
     86        #endif
     87
     88        /*Plug into this->time: */
     89        this->time->AddObject(new DoubleParam(tagenum,t));
     90        this->flops->AddObject(new DoubleParam(tagenum,f));
     91        this->memory->AddObject(new DoubleParam(tagenum,m));
    8092
    8193}
    8294/*}}}*/
    83 /*FUNCTION Profiler::Delta {{{*/
    84 double  Profiler::Delta(int inittag, int finaltag){
     95/*FUNCTION Profiler::DeltaTime {{{*/
     96IssmDouble  Profiler::DeltaTime(int inittag, int finaltag){
    8597
    86         double init, final;
    87         this->timetags->FindParam(&init,inittag);
    88         this->timetags->FindParam(&final,finaltag);
     98        IssmDouble init, final;
     99        this->time->FindParam(&init,inittag);
     100        this->time->FindParam(&final,finaltag);
    89101
    90102        #ifdef _HAVE_MPI_
     
    95107}
    96108/*}}}*/
    97 /*FUNCTION Profiler::DeltaModHour {{{*/
    98 int Profiler::DeltaModHour(int inittag, int finishtag){
     109/*FUNCTION Profiler::DeltaFlops {{{*/
     110IssmDouble  Profiler::DeltaFlops(int inittag, int finaltag){
    99111
    100         double init, finish;
    101         this->timetags->FindParam(&init,inittag);
    102         this->timetags->FindParam(&finish,finishtag);
     112        IssmDouble init, final;
     113        this->flops->FindParam(&init,inittag);
     114        this->flops->FindParam(&final,finaltag);
     115
     116        return final-init;
     117}
     118/*}}}*/
     119/*FUNCTION Profiler::DeltaTimeModHour {{{*/
     120int Profiler::DeltaTimeModHour(int inittag, int finishtag){
     121
     122        IssmDouble init, finish;
     123        this->time->FindParam(&init,inittag);
     124        this->time->FindParam(&finish,finishtag);
    103125
    104126        #ifdef _HAVE_MPI_
    105         return int((finish-init)/3600);
     127        return int((reCast<int,IssmDouble>(finish-init))/3600);
    106128        #else
    107         return int((finish-init)/CLOCKS_PER_SEC/3600);
     129        return int((reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC/3600);
    108130        #endif
    109131
    110132}
    111133/*}}}*/
    112 /*FUNCTION Profiler::DeltaModMin {{{*/
    113 int Profiler::DeltaModMin(int inittag, int finishtag){
     134/*FUNCTION Profiler::DeltaTimeModMin {{{*/
     135int Profiler::DeltaTimeModMin(int inittag, int finishtag){
    114136
    115         double init, finish;
    116         this->timetags->FindParam(&init,inittag);
    117         this->timetags->FindParam(&finish,finishtag);
     137        IssmDouble init, finish;
     138        this->time->FindParam(&init,inittag);
     139        this->time->FindParam(&finish,finishtag);
    118140
    119141        #ifdef _HAVE_MPI_
    120         return int(int(finish-init)%3600/60);
     142        return int(int(reCast<int,IssmDouble>(finish-init))%3600/60);
    121143        #else
    122         return int(int(finish-init)/CLOCKS_PER_SEC%3600/60);
     144        return int(int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%3600/60);
    123145        #endif
    124146}
    125147/*}}}*/
    126 /*FUNCTION Profiler::DeltaModSec {{{*/
    127 int Profiler::DeltaModSec(int inittag, int finishtag){
     148/*FUNCTION Profiler::DeltaTimeModSec {{{*/
     149int Profiler::DeltaTimeModSec(int inittag, int finishtag){
    128150
    129         double init, finish;
    130         this->timetags->FindParam(&init,inittag);
    131         this->timetags->FindParam(&finish,finishtag);
     151        IssmDouble init, finish;
     152        this->time->FindParam(&init,inittag);
     153        this->time->FindParam(&finish,finishtag);
    132154
    133155        #ifdef _HAVE_MPI_
    134         return int(finish-init)%60;
     156        return int(reCast<int,IssmDouble>(finish-init))%60;
    135157        #else
    136         return int(finish-init)/CLOCKS_PER_SEC%60;
     158        return int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%60;
    137159        #endif
    138160}
    139161/*}}}*/
     162/*FUNCTION Profiler::Memory {{{*/
     163IssmDouble  Profiler::Memory(int tag){
     164
     165        IssmDouble m;
     166        this->memory->FindParam(&m,tag);
     167
     168        return m;
     169}
     170/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Profiler.h

    r13534 r13539  
    2828
    2929        public:
    30                 Parameters*  timetags;
     30                Parameters*  time;
     31                Parameters*  flops;
     32                Parameters*  memory;
    3133
    3234                /*Profiler constructors, destructors {{{*/
     
    4345                /*Profiler routines {{{*/
    4446                void    Tag(int tagenum,bool dontmpisync=false);
    45                 double  Delta(int inittag, int finaltag);
    46                 int     DeltaModHour(int inittag, int finaltag);
    47                 int     DeltaModMin(int inittag, int finaltag);
    48                 int     DeltaModSec(int inittag, int finaltag);
     47                IssmDouble  Memory(int tag);
     48                IssmDouble  DeltaTime(int inittag, int finaltag);
     49                IssmDouble  DeltaFlops(int inittag, int finaltag);
     50                int     DeltaTimeModHour(int inittag, int finaltag);
     51                int     DeltaTimeModMin(int inittag, int finaltag);
     52                int     DeltaTimeModSec(int inittag, int finaltag);
    4953                /*}}}*/
    5054};
  • issm/trunk-jpl/src/c/modules/Dakotax/Dakotax.h

    r12832 r13539  
    1010
    1111/* local prototypes: */
    12 int  SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
    13 int  DescriptorIndex(char* root, int* pindex,char* descriptor);
    14 
    1512void Dakotax(FemModel* femmodel);
    16 void SpawnCoreParallel(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodel,int counter);
    17 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel);
    18 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses);
    19 void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses);
     13int  DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
    2014
    2115#endif  /* _DAKOTAX_H */
  • issm/trunk-jpl/src/c/shared/String/sharedstring.h

    r5469 r13539  
    88int  DescriptorIndex(char* root, int* pindex,char* descriptor);
    99
     10#ifndef WIN32
     11int stricmp(const char* a,const char* b);
     12#endif
     13
    1014#endif //ifndef _SHAREDSTRING_H_
    1115
  • issm/trunk-jpl/src/c/shared/shared.h

    r13538 r13539  
    1616#include "Numerics/numerics.h"
    1717#include "Sorting/sorting.h"
     18#include "String/sharedstring.h"
    1819#include "Threads/issm_threads.h"
    1920#include "TriMesh/trimesh.h"
  • issm/trunk-jpl/src/c/solutions/issm.cpp

    r13534 r13539  
    77       
    88void ProfilerEcho(Profiler* profiler);
     9void ProfilerEnd(Profiler* profiler, Results* results, Parameters* parameters);
    910
    1011int main(int argc,char **argv){
     
    3839        /*profiling*/   
    3940        Profiler* profiler=NULL;
    40         bool profiling = false;
    41         IssmPDouble Time_start, Flops_start;
    42         IssmPDouble Solution_time, Memory_use, Current_flops;
    4341
    4442        /*Initialize exception trapping: */
     
    4846        EnvironmentInit(argc,argv);
    4947       
    50         /*Some profiling: */
    51         profiler=new Profiler(); profiler->Tag(Start);
     48        /*Start profiler: */
     49        profiler=new Profiler();
     50        profiler->Tag(Start);
    5251       
    5352        /*First process inputs*/
     
    8382        femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
    8483        femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
    85         femmodel->parameters->FindParam(&profiling,DebugProfilingEnum);
    8684        femmodel->parameters->FindParam(&autodiff,AutodiffIsautodiffEnum);
    8785
     
    106104
    107105        _pprintLine_("call computational core:");
     106
     107               
    108108        profiler->Tag(StartCore);
    109        
    110         if(profiling)ProfilingStart(&Time_start,&Flops_start);
    111 
    112109        if(dakota_analysis){
    113110                #ifdef _HAVE_DAKOTA_
    114                 Dakotax(femmodel);
     111                dakota_core(femmodel);
    115112                #else
    116113                _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
     
    119116        else if(control_analysis){
    120117                #ifdef _HAVE_CONTROL_
    121                 if(tao_analysis)
    122                  controltao_core(femmodel);
    123                 else
    124                  control_core(femmodel);
     118                if(tao_analysis) controltao_core(femmodel);
     119                else control_core(femmodel);
    125120                #else
    126                 _error_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
     121                _error_("ISSM was not compiled with control support, cannot carry out control analysis!");
    127122                #endif
    128123        }
    129124        else{
    130125                solutioncore(femmodel);
    131         }
    132 
    133         if(profiling){
    134                 ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start);
    135                 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0));
    136                 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0));
    137                 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0));
    138126        }
    139127
     
    144132        }
    145133        #endif
    146 
    147134        profiler->Tag(FinishCore);
    148135
    149        
     136        ProfilerEnd(profiler,femmodel->results,femmodel->parameters);
     137
    150138        _pprintLine_("write results to disk:");
    151139        OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
     
    183171        delete femmodel;
    184172
    185         /*Get finish time and close*/
    186         profiler->Tag(Finish); ProfilerEcho(profiler);
     173        /*Profiling at the end: */
     174        profiler->Tag(Finish);
     175        ProfilerEcho(profiler);
    187176
    188177        /*Finalize environment:*/
     
    196185}
    197186       
    198 
    199 
    200 void ProfilerEcho(Profiler* profiler){
    201 
    202         _pprintLine_("");
    203         _pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->Delta(StartInit,FinishInit));
    204         _pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->Delta(StartCore,FinishCore));
     187void ProfilerEcho(Profiler* profiler){ /*{{{*/
     188
     189        _pprintLine_("");
     190        _pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->DeltaTime(StartInit,FinishInit));
     191        _pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->DeltaTime(StartCore,FinishCore));
    205192        _pprintLine_("");
    206193        _pprintLine_("   Total elapsed time:"
    207                 <<profiler->DeltaModHour(Start,Finish)<<" hrs "
    208                 <<profiler->DeltaModMin(Start,Finish)<<" min "
    209                 <<profiler->DeltaModSec(Start,Finish)<<" sec"
     194                <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs "
     195                <<profiler->DeltaTimeModMin(Start,Finish)<<" min "
     196                <<profiler->DeltaTimeModSec(Start,Finish)<<" sec"
    210197                );
    211198        _pprintLine_("");
    212199
    213 }
    214 
     200} /*}}}*/
     201void ProfilerEnd(Profiler* profiler, Results* results, Parameters* parameters){ /*{{{*/
     202
     203        bool profiling = false;
     204       
     205        IssmDouble solution_time;
     206        IssmDouble solution_flops;
     207        IssmDouble solution_memory;
     208
     209        parameters->FindParam(&profiling,DebugProfilingEnum);
     210
     211        if(profiling){
     212
     213                solution_time=profiler->DeltaTime(StartCore,FinishCore);
     214                solution_flops=profiler->DeltaFlops(StartCore,FinishCore);
     215                solution_memory=profiler->Memory(FinishCore);
     216
     217                _pprintLine_("Solution elapsed time  : " << solution_time << "  Seconds");
     218                _pprintLine_("Solution elapsed flops : " << solution_flops << "  Flops");
     219                _pprintLine_("Solution memory used   : " << solution_memory << "  Bytes");
     220
     221                /*Add to results: */
     222                results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0));
     223                results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0));
     224                results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0));
     225        }
     226
     227} /*}}}*/
  • issm/trunk-jpl/src/c/solutions/solutions.h

    r13534 r13539  
    3030void steadystate_core(FemModel* femmodel);
    3131void transient_core(FemModel* femmodel);
     32void dakota_core(FemModel* femmodel);
    3233IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
    3334
     
    4748void EnvironmentInit(int argc,char** argv);
    4849void EnvironmentFinalize(void);
     50int  DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
    4951
    5052//solution configuration
     
    5355void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype);
    5456
     57
    5558#endif
Note: See TracChangeset for help on using the changeset viewer.