Revision 1049

branches/threaded2/tests/multisimple/msimple.rep (revision 1049)
1
A = 2; B = 4
2
a = 0.496229; b = -1.60112
branches/threaded2/tests/multisimple/adpthread_manager.h (revision 1049)
1
// $Id: adpthread_manager.h 3054M 2013-01-11 20:20:26Z (local) $
2
#ifndef __admb__adpthread_manager__
3
#define __admb__adpthread_manager__ 1.0
4

  
5
//#include <admodel.h>
6
#include <fvar.hpp>
7
#include <pthread.h>
8

  
9

  
10
/*
11
extern pthread_mutex_t * smutex;
12
extern pthread_cond_t * scondition;
13
extern pthread_cond_t *mcondition;
14
extern int * mflag;
15
extern int * sflag;
16
*/
17
  
18
class thread_data
19
{
20
public:
21
  static int __thread id;
22
  int thread_no;
23
  int bufsize;
24
  pthread_mutex_t *inlock;
25
  pthread_mutex_t *outlock;
26
  void * transfer_buffer;
27
  char message[100];
28
};
29

  
30
typedef char * pchar;
31

  
32
class adpthread_manager
33
{
34
public:
35
  char ** transfer_buffer;
36
  char ** buffend;
37
  char ** tb_save;
38
  int nslaves;
39
  int bs;
40

  
41
  /** Indicates state of "master" tranfer buffer; thread-specific.
42
  0 => able to receive data; 1 => buffer contains data.
43
  Set to 1 by "send to slave" functions; 
44
  set to 0 by "get from master" functions.
45
  Integer vector with the same number of entries as the thread vector;
46
  one flag for each thread.
47
  */
48
  int * mflag;
49

  
50
  /** Indicates state of "slave" tranfer buffer; thread-specific. 
51
  0 => able to receive data; 1 => buffer contains data.
52
  Set to 1 by "send to master" and "slave pack derivative" functions; 
53
  set to 0 by get from slave functions.
54
  Integer vector with the same number of entries as the thread vector;
55
  one flag for each thread.
56
  */
57
  int * sflag;
58
  //pthread_rwlock_t * tb_lock;
59
  pthread_mutex_t * smutex;
60
  pthread_cond_t * scondition;
61
  pthread_cond_t *mcondition;
62
  pthread_t * thread1;  // thread variables
63
  static int pt_res;
64
  static void pt_result(const char *string, const char* file, const int line);
65

  
66
  adpthread_manager(int ns,int bs);
67
 ~adpthread_manager();
68
  void initialize(void);
69
  void reset(void);
70

  
71
  void send_int_to_slave(const int z,int sno);
72
  void send_ivector_to_slave(const ivector &x,int sno);
73
  ivector get_ivector_from_slave(int sno);
74
  ivector get_ivector_from_master(int sno);
75
  int get_int_from_master(int sno);
76
  void send_double_to_slave(const double x,int sno);
77
  void send_double_to_master(const double x,int sno);
78
  double get_double_from_slave(int sno);
79
  double get_double_from_master(int sno);
80
  void send_dvariable_to_slave(const prevariable &x,int sno);
81
  void send_dvariable_to_master(const prevariable &x,int sno);
82
  dvariable get_dvariable_from_slave(int sno);
83
  dvariable get_dvariable_from_master(int sno);
84
  void send_dvector_to_slave(const dvector &x,int sno);
85
  void send_dvector_to_master(const dvector &x,int sno);
86
  dvector get_dvector_from_slave(int sno);
87
  dvector get_dvector_from_master(int sno);
88
  dvar_vector get_dvar_vector_from_slave(int sno);
89
  dvar_vector get_dvar_vector_from_master(int sno);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff