Changeset 25510


Ignore:
Timestamp:
09/01/20 16:03:14 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing AD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r25509 r25510  
    1919        AD_COUNTDOUBLES,
    2020        AD_REGISTERINPUT,
     21        AD_REGISTEROUTPUT,
    2122        AD_SETADJOINT,
    2223#endif
     
    143144                int   double_count;
    144145                int*  identifiers;
    145                 auto* tape_codi;
    146 
    147         public:
    148                 RegisterInputFunctor(auto* tape_in,int* identifiers_in) : MarshallHandle(AD_REGISTERINPUT),double_count(0),identifiers(identifiers_in),tape_codi(tape_in)){}
     146                IssmDouble::TapeType* tape_codi;
     147
     148        public:
     149                RegisterInputFunctor(int* identifiers_in) : MarshallHandle(AD_REGISTERINPUT){
     150                        this->double_count = 0;
     151                        this->identifiers  = identifiers_in;
     152                        this->tape_codi    = &(IssmDouble::getGlobalTape());
     153                }
    149154                int DoubleCount(void){return this->double_count;};
    150155                void Echo(void){
     
    173178                }
    174179}; /*}}}*/
     180class RegisterOutputFunctor:  public MarshallHandle{ /*{{{*/
     181
     182        private:
     183                int   double_count;
     184                IssmDouble::TapeType* tape_codi;
     185
     186        public:
     187                RegisterOutputFunctor(void) : MarshallHandle(AD_REGISTERINPUT){
     188                        this->double_count = 0;
     189                        this->tape_codi    = &(IssmDouble::getGlobalTape());
     190                }
     191                int DoubleCount(void){return this->double_count;};
     192                void Echo(void){
     193                        printf("RegisterOutputFunctor Echo:\n");
     194                        printf("   double_count: %i\n",double_count);
     195                }
     196                template<typename T> void call(T & value){
     197                        /*General case: do nothing*/
     198                }
     199                template<typename T> void call(T* & value,int size){
     200                        /*General case: do nothing*/
     201                }
     202                void call(IssmDouble value){
     203                        this->tape_codi->registerOutput(value);
     204                        this->double_count++;
     205                }
     206                void call(IssmDouble* value,int size){
     207                        if(value){
     208                                for(int i=0;i<size;i++){
     209                                        this->tape_codi->registerOutput(value[i]);
     210                                        this->double_count++;
     211                                }
     212                        }
     213                }
     214}; /*}}}*/
    175215#endif
    176216
     
    183223                case AD_COUNTDOUBLES:  {CountDoublesFunctor*    temp = xDynamicCast<CountDoublesFunctor*>(this);    temp->call(value); break;}
    184224                case AD_REGISTERINPUT: {RegisterInputFunctor*   temp = xDynamicCast<RegisterInputFunctor*>(this);   temp->call(value); break;}
     225                case AD_REGISTEROUTPUT:{RegisterOutputFunctor*  temp = xDynamicCast<RegisterOutputFunctor*>(this);  temp->call(value); break;}
    185226                //case AD_SETADJOINT:    {SetAdjointFunction*     temp = xDynamicCast<SetAdjointFunction*>(this);     temp->call(value); break;}
    186227#endif
     
    196237                case AD_COUNTDOUBLES:  {CountDoublesFunctor*    temp = xDynamicCast<CountDoublesFunctor*>(this);    temp->call(value,size); break;}
    197238                case AD_REGISTERINPUT: {RegisterInputFunctor*   temp = xDynamicCast<RegisterInputFunctor*>(this);   temp->call(value,size); break;}
     239                case AD_REGISTEROUTPUT:{RegisterOutputFunctor*  temp = xDynamicCast<RegisterOutputFunctor*>(this);  temp->call(value,size); break;}
    198240                //case AD_SETADJOINT:    {SetAdjointFunction*     temp = xDynamicCast<SetAdjointFunction*>(this);     temp->call(value,size); break;}
    199241#endif
Note: See TracChangeset for help on using the changeset viewer.