Revision 554

branches/parallel/parallel-diff.txt (revision 554)
1
Index: nh99/mod_hess.cpp
2
===================================================================
3
--- nh99/mod_hess.cpp	(.../trunk/src)	(revision 550)
4
+++ nh99/mod_hess.cpp	(.../branches/parallel/src)	(revision 550)
5
@@ -69,9 +69,31 @@
6
 {
7
 
8
   int nvar=initial_params::nvarcalc(); // get the number of active parameters
9
-  //if (adjm_ptr) set_labels_for_hess(nvar);
10
   independent_variables x(1,nvar);
11
   initial_params::xinit(x);        // get the initial values into the x vector
12
+#if defined(USE_ADMPI)
13
+    if (ad_comm::mpi_manager)
14
+    {
15
+      if (ad_comm::mpi_manager->is_master())
16
+      {
17
+         int set_hess_slaves=ad_comm::mpi_manager->get_num_slaves();
18
+         ad_comm::mpi_manager->set_num_hess_slaves(set_hess_slaves);
19
+         // send variable assignement to slaves for hessian calcs
20
+         ad_comm::mpi_manager->send_slave_hessian_assignments(nvar);
21
+        for (int i=1;i<=ad_comm::mpi_manager->get_num_slaves();i++)
22
+        {
23
+           ad_comm::mpi_manager->send_dvector_to_slave(x,i);
24
+        }
25
+        //sleep(2);
26
+      }
27
+      else
28
+      {
29
+         //get variable assignement for slaves for hessian calcs
30
+         ad_comm::mpi_manager->get_slave_hessian_assignments();
31
+         x=ad_comm::mpi_manager->get_dvector_from_master();
32
+      }
33
+    }
34
+#endif
35
   double f;
36
   double delta=1.e-5;
37
   dvector g1(1,nvar);
38
@@ -87,6 +109,17 @@
39
   adstring tmpstring="admodel.hes";
40
   if (ad_comm::wd_flag)
41
      tmpstring = ad_comm::adprogram_name + ".hes";
42
+#if defined(USE_ADMPI)
43
+  if (ad_comm::mpi_manager)
44
+  {
45
+    if (ad_comm::mpi_manager->is_slave())
46
+    {
47
+      tmpstring += "_";
48
+      tmpstring += str(ad_comm::mpi_manager->get_slave_number());
49
+    }
50
+  }
51
+#endif // #if defined(USE_ADMPI)
52
+
53
   uostream ofs((char*)tmpstring);
54
 
55
   ofs << nvar;
56
@@ -102,8 +135,24 @@
57
     }
58
     double sdelta1;
59
     double sdelta2;
60
-    for (int i=1;i<=nvar;i++)
61
+    int mmin=1;
62
+    int mmax=nvar;
63
+#if defined(USE_ADMPI)
64
+    if (ad_comm::mpi_manager)
65
     {
66
+      ivector hess_bounds=ad_comm::mpi_manager->get_hess_bounds();
67
+      if (hess_bounds(1)>0)
68
+      {
69
+        mmin=hess_bounds(1);
70
+        mmax=hess_bounds(2);
71
+        ofs << mmin << mmax;
72
+      }
73
+    }
74
+#endif
75
+
76
+
77
+    for (int i=mmin;i<=mmax;i++)
78
+    {
79
 #if defined (__SPDLL__)
80
       hess_calcreport(i,nvar);
81
 #else
82
@@ -177,8 +226,39 @@
83
   }
84
   ofs << gradient_structure::Hybrid_bounded_flag;
85
   dvector tscale(1,nvar);   // need to get scale from somewhere
86
-  /*int check=*/initial_params::stddev_scale(tscale,x);
87
-  ofs << tscale;
88
+#if defined(USE_ADMPI)
89
+  if (ad_comm::mpi_manager)
90
+  {
91
+    if (ad_comm::mpi_manager->is_master())
92
+    {
93
+      ofs << gradient_structure::Hybrid_bounded_flag;
94
+      ofs << tscale;
95
+      // wait until slaves are finished
96
+      for (int i=1;i<=ad_comm::mpi_manager->get_num_slaves();i++)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff