Revision 1228 branches/threaded2merge/src/linad99/thread_stuff.cpp

thread_stuff.cpp (revision 1228)
7 7
#  endif
8 8
#endif
9 9

  
10
/* prototype for thread routine */
11
void admb_thread(void * ptr);
12

  
13 10
pthread_mutex_t mutex_print;
14 11

  
15
//const int NSLAVES=1;
16

  
17 12
typedef char * pchar;
18 13
typedef pchar *  ppchar;
19 14
typedef ofstream * pofstream;
20 15
__thread int adpthread_manager::slave_number;
21 16

  
22
int adpthread_manager::old_buffer_flag=0;
23

  
24

  
25 17
adpthread_manager::adpthread_manager(int ns,int bs) : buffer_size(1,ns),
26 18
  mflag(1,ns), sflag(1,ns), num_in_group(1,1),ngroups(1),
27 19
  initial_buffer_size(bs)
......
843 835
    pthread_create(thread1+i,NULL,pf,ptr+i);
844 836
  }
845 837
}
846

  
847
void adpthread_manager::create_all(pthreadfun pf ,thread_data * ptr)
848
{
849
  for (int i=1;i<=nslaves;i++)
850
  {
851
    pthread_create(thread1+i,NULL,pf,ptr+i);
852
  }
853
}
854

  
855 838
void adpthread_manager::create_all(void * ptr)
856 839
{
857 840
  pthread_attr_t policy_attr;
......
890 873
    }
891 874
  }
892 875
}
893

  
894 876
void adpthread_manager::pthread_join_all(void)
895 877
{
896 878
  for (int i=1;i<=nslaves;i++)
......
898 880
    pthread_join(thread1[i], NULL);
899 881
  }
900 882
}
901

  
902 883
void adpthread_manager::writebuffer(const void *x,int nbytes,int sno)
903 884
{
904
 /*
905
  if (old_buffer_flag==1)
885
  int tn2=ad_comm::pthread_manager->get_slave_number();
886
  if (tn2==sno)
906 887
  {
907
    check_buffer_size(nbytes,sno);
908
    ::memcpy(current_bptr[sno],x,nbytes);
909
    current_bptr[sno]+=nbytes;
888
    cerr << "This can't happen" << endl;
889
    ad_exit(1);
910 890
  }
911
  else
912
 */
891
  int s1 = sno;
892
  int s2 = tn2;
893
  if (tn2<sno)
913 894
  {
914
    int s1,s2;
915
    int tn2=ad_comm::pthread_manager->get_slave_number();
916
    if (tn2==sno)
917
    {
918
      cerr << "This can't happen" << endl;
919
      ad_exit(1);
920
    }
921
    if (tn2<sno)
922
    {
923
      s1=tn2;
924
      s2=sno;
925
    }
926
    else
927
    {
928
      s1=sno;
929
      s2=tn2;
930
    }
931
    check_buffer_size(nbytes,s1,s2);
932
    ::memcpy(scurrent_bptr[s1][s2],x,nbytes);
933
    scurrent_bptr[s1][s2]+=nbytes;
895
    s1=tn2;
896
    s2=sno;
934 897
  }
898
  check_buffer_size(nbytes,s1,s2);
899
  ::memcpy(scurrent_bptr[s1][s2],x,nbytes);
900
  scurrent_bptr[s1][s2]+=nbytes;
935 901
}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff