Revision 1174

branches/threaded2merge/tests/threads/msimple/GNUmakefile (revision 1174)
1
GTEST_DIR=../../googletest-read-only
2

  
3
all: clean tests_msimple
4

  
1 5
msimple: msimple.tpl
2 6
	CXXFLAGS=-pthread LDFLAGS=-pthread ../../../admb -g msimple
3 7
	-./msimple
8

  
9
tests_msimple: msimple tests_msimple.cpp
10
	cp $(GTEST_DIR)/gtest-all.o .
11
	CXXFLAGS="-pthread -I$(GTEST_DIR)/include" LDFLAGS=-pthread ../../../admb -g tests_msimple.cpp main.cpp gtest-all.o
12
	-./tests_msimple
13

  
4 14
clean:
5 15
	@rm -vf msimple.log
6 16
	@rm -vf msimple.cpp
......
9 19
	@rm -vf log_master
10 20
	@rm -vf eigv.rpt
11 21
	@rm -vf msimple.htp
22
	@rm -vf msimple
12 23
	@rm -vf fmin.log
24
	@rm -vf tests_msimple
branches/threaded2merge/tests/threads/msimple/tests_msimple.cpp (revision 1174)
1
#include <gtest/gtest.h>
2
#include <fvar.hpp>
3

  
4
class tests_msimple: public ::testing::Test {};
5

  
6
#define main msimple_main
7
#include "msimple.cpp"
8

  
9
TEST_F(tests_msimple, msimple_main)
10
{
11
  int argc = 1;
12
  char* argv[] = {"msimple"};
13
  msimple_main(argc, argv);
14
}
branches/threaded2merge/tests/threads/msimple/msimple.tpl (revision 1174)
5 5
  #include <fvar.hpp>
6 6
  #include <adthread.h>
7 7

  
8
 
9 8
  // write the function to run on the threads
10 9
  void* simple_thread(void* ptr)
11 10
  {
......
21 20
      // get the thread number
22 21
      ad_comm::pthread_manager->set_slave_number(tptr->thread_no);
23 22

  
24
    
25 23
      // take control of the constant buffer for reading
26 24
      ad_comm::pthread_manager->cread_lock_buffer(0);
27 25
      // read the independent variables IN THE SAME ORDER AS THEY ARE SENT
......
29 27
      cerr << " * * *  got x chunk " << tptr->thread_no << " from " << x.indexmin() << " to " << x.indexmax() << endl;
30 28
      dvector Y = ad_comm::pthread_manager->get_dvector(0);
31 29
      cerr << " * * *  got Y chunk " << tptr->thread_no << " from " << Y.indexmin() << " to " << Y.indexmax() << endl;
32
     // release the constant buffer
30
      // release the constant buffer
33 31
      ad_comm::pthread_manager->cread_unlock_buffer(0);
34 32

  
35 33
      do
36 34
      {
37 35
         // take control of the variable buffer for reading
38 36
         ad_comm::pthread_manager->read_lock_buffer(0);
37

  
39 38
         // read the finished signal
40 39
         int lflag=ad_comm::pthread_manager->get_int(0);
41 40
         if (lflag == 0) break;
......
63 62
   
64 63
         // compute derivative contribution for this thread 
65 64
         slave_gradcalc();
66
      }
67
      while (1);
65
      } while (1);
66

  
68 67
      // close thread
69 68
      pthread_exit(ptr);
70 69
   }
71 70

  
72

  
73 71
DATA_SECTION
74 72
  init_int nobs
75 73
  init_int nthread
......
92 90
    x *= 100.0;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff