Revision 779

branches/pthreads-737/tests/nst/admb_thread.cpp (revision 779)
12 12
extern pthread_mutex_t mp_ptr_mutex;
13 13
extern pthread_cond_t mp_ptr_cond;
14 14
  
15
__ADMBTHREAD__ int  adpthread_manager::slave_number=0;
15 16

  
17

  
16 18
void admb_thread(void * ptr)
17 19
{
18 20
  pthread_mutex_lock(&mp_ptr_mutex);
......
21 23
  thread_data * tptr = (thread_data *) ptr;
22 24
  thread_data::id=tptr->thread_no;
23 25
  int sno=tptr->thread_no;
26
  cout << "TT sno " << sno << endl;
27
  adpthread_manager::set_slave_number(sno);
28
  cout << "XX slavenumber = " << adpthread_manager::get_slave_number()
29
   << endl;
24 30
  pthread_mutex_unlock(&test_thread_manager->smutex[sno]);
25 31
  model_parameters * mp = (model_parameters*)mp_ptr;
26 32
  const int m = mp->m;
27 33
  TTRACE(sno,m)
28 34
  {
29 35
    //arrmblsize = 35000000;
30
 
31 36
    gradient_structure::set_MAX_NVAR_OFFSET(10000);
32
    gradient_structure::set_GRADSTACK_BUFFER_SIZE(20000000);
33
    gradient_structure::set_CMPDIF_BUFFER_SIZE(20000000);
37
    gradient_structure::set_GRADSTACK_BUFFER_SIZE(200);
38
    gradient_structure::set_CMPDIF_BUFFER_SIZE(2000);
34 39
    gradient_structure::set_MAX_NVAR_OFFSET(30000);
35 40
    gradient_structure gs(1000000);
36 41
    do
37 42
    {
38
       double lflag = test_thread_manager->get_double_from_master(sno); 
39
       TTRACE(sno,lflag)
40
       if (lflag == 0.0) break;
41
       dvar_vector v= test_thread_manager->get_dvar_vector_from_master(sno);
42
       int mmin=v.indexmin();
43
       int mmax=v.indexmax();
44
       TTRACE(mmin,mmax)
45
       dvar_matrix M(1,m,1,m);
46
       int ii=0;
47
       for (int i=1;i<=m;i++)
48
       {
49
         for (int j=1;j<=m;j++)
50
         {
51
           M(i,j)=v(++ii);
52
         }
53
       }
54
       dvector u(1,m);
55
       u.fill_seqadd(sno,1.0/sno);
56
       TTRACE(sno,sum(u))
57
    
58
       dvariable z=0.0;
59
       for (int i=1;i<=20;i++)
60
       {
61
         z+=norm2(solve(M,u+double(i)));
62
       }
63
       TTRACE(sno,z)
64
  
65
       test_thread_manager->send_dvariable_to_master(z,sno);
66
       slave_gradcalc();
43
      test_thread_manager->read_lock_buffer_slave(sno); 
44
      test_thread_manager->verify_id_string_from_master_nl("abcx",sno); 
45
      double lflag = test_thread_manager->get_double_from_master_nl(sno); 
46
      //cout << "IN thread " << sno << " read " << lflag << endl;
47
      if (lflag == 0.0) break;
48
      dvar_vector v= test_thread_manager->get_dvar_vector_from_master(sno);
49
      dvector w= test_thread_manager->get_dvector_from_master(sno);
50
      //cout << w << endl;
51
      test_thread_manager->read_unlock_buffer_slave(sno); 
52
      int mmin=v.indexmin();
53
      int mmax=v.indexmax();
54
      TTRACE(mmin,mmax)
55
      dvar_matrix M(1,m,1,m);
56
      int ii=0;
57
      for (int i=1;i<=m;i++)
58
      {
59
        for (int j=1;j<=m;j++)
60
        {
61
          M(i,j)=v(++ii);
62
        }
63
      }
64
      dvector u(1,m);
65
      u.fill_seqadd(sno,1.0/sno);
66
      TTRACE(sno,sum(u))
67
   
68
      dvariable z=0.0;
69
      for (int i=1;i<=20;i++)
70
      {
71
        z+=norm2(solve(M,u+double(i)));
72
      }
73
 
74
      test_thread_manager->write_lock_buffer_slave(sno); 
75
      test_thread_manager->send_id_string_to_master_nl("X1",sno);
76
      test_thread_manager->send_dvariable_to_master(z,sno);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff