Revision 810 branches/pthreads-737/tests/nst/thread_stuff.cpp

thread_stuff.cpp (revision 810)
1059 1059
    }
1060 1060
  }
1061 1061
}
1062
void adpthread_manager::send_dvar_matrix_to_slave(const dvar_matrix &x,int sno)
1063
void adpthread_manager::adjoint_send_dvar_matrix_to_slave(void)
1062 1064
*/
1063 1065

  
1064 1066

  
1067

  
1068
void adjoint_send_dvar_matrix_to_slave(void)
1069
{
1070
  verify_identifier_string("UN");
1071
  adpthread_manager * ptr=(adpthread_manager*)(restore_pointer_value());
1072
  ptr->adjoint_send_dvar_matrix_to_slave();
1073
}
1074

  
1075
void adpthread_manager::adjoint_send_dvar_matrix_to_slave(void)
1076
{
1077
  verify_identifier_string("HH");
1078
  int sno=restore_int_value();
1079
  verify_identifier_string("OP");
1080
  verify_id_string_from_slave_nl("SVX",sno);
1081
  int rmin;
1082
  int rmax;
1083
  readbuffer(&rmin,sizeof(int),sno);
1084
  readbuffer(&rmax,sizeof(int),sno);
1085
  dmatrix M(rmin,rmax);
1086
  for (int i=rmin;i<=rmax;i++)
1087
  {
1088
    int mmin,mmax;
1089
    readbuffer(&mmin,sizeof(int),sno);
1090
    readbuffer(&mmax,sizeof(int),sno);
1091
    M(i).allocate(mmin,mmax);
1092
    int sz=mmax-mmin+1;
1093
    readbuffer(&(M(i)(mmin)),sz*sizeof(double),sno);
1094
  }
1095
  dvar_matrix_position dmpos=restore_dvar_matrix_position();
1096
  verify_identifier_string("Y");
1097
  M.save_dmatrix_derivatives(dmpos);
1098
}
1099

  
1100
void adpthread_manager::send_dvar_matrix_to_slave(const dvar_matrix &x,int sno)
1101
{
1102
  int rmin=x.indexmin();
1103
  int rmax=x.indexmax();
1104
  send_id_string_to_slave_nl("WUZ",sno);
1105
  writebuffer(&rmin,sizeof(int),sno);
1106
  writebuffer(&rmax,sizeof(int),sno);
1107
  for (int i=rmin;i<=rmax;i++)
1108
  {
1109
    int mmin=x(i).indexmin();
1110
    int mmax=x(i).indexmax();
1111
    int sz=mmax-mmin+1;
1112
    writebuffer(&mmin,sizeof(int),sno);
1113
    writebuffer(&mmax,sizeof(int),sno);
1114
    writebuffer(&(value(x(i)(mmin))),sz*sizeof(double),sno);
1115
  }
1116
  save_identifier_string("Y");
1117
  // !!! should we optimize this ?
1118
  x.save_dvar_matrix_position();
1119
  save_identifier_string("OP");
1120
  save_int_value(sno);
1121
  save_identifier_string("HH");
1122
  save_pointer_value(this);
1123
  save_identifier_string("UN");
1124
  gradient_structure::GRAD_STACK1->
1125
    set_gradient_stack(::adjoint_send_dvar_matrix_to_slave);
1126
}
1127

  

Also available in: Unified diff