Revision 752 branches/threaded2/tests/threaded_hessian_routine/tests_threaded_hessian_routine.cpp

tests_threaded_hessian_routine.cpp (revision 752)
1 1
#include <iostream>
2
#include <vector>
2 3
#include <thread>
4
using std::vector;
5
using std::thread;
6

  
3 7
#include <gtest/gtest.h>
4 8

  
5 9
#define main simple
......
17 21
  }
18 22
  virtual void TearDown() {
19 23
  }
24
public:
25
  static __thread int line;
26
  static __thread dvariable* variable;
20 27
};
28
__thread int tests_threaded::line = -1;
29
__thread dvariable* tests_threaded::variable = nullptr;
21 30

  
22 31
int simple(int argc, char* argv[]);
32
void hello_world()
33
{
34
}
35
TEST(tests_threaded, hello_world)
36
{
37
  std::thread t(hello_world);
38
  t.join();
39
}
40
TEST(tests_threaded, simple_hess_routine_threaded)
41
{
42
  ad_set_new_handler();
43
  ad_exit=&ad_boundf;
23 44

  
24
/*
25
TEST(tests_threaded, simple)
45
  gradient_structure::set_NO_DERIVATIVES();
46
  gradient_structure::set_YES_SAVE_VARIABLES_VALUES();
47

  
48
  int argc = 1;
49
  char* argv[] = { (char*)"simple/simple" };
50
  if (!arrmblsize) arrmblsize=15000000;
51

  
52
  const int n = 20;
53
  std::thread t[n];
54
  for (int i = 0; i < n; i++)
55
  {
56
    t[i] = std::thread([](){
57
      ASSERT_EQ(-1, tests_threaded::line);
58
      ASSERT_EQ(nullptr, tests_threaded::variable);
59
      tests_threaded::line = 2;
60
    });
61
  }
62
  for (int i = 0; i < n; i++)
63
  {
64
    t[i].join();
65
  }
66
}
67
TEST(tests_threaded, dlink_constructor_destructor)
26 68
{
27
  char* argv[] = { "simple/simple" };
28
  simple(1, argv);
69
  ad_set_new_handler();
70
  ad_exit=&ad_boundf;
71

  
72
  gradient_structure::set_NO_DERIVATIVES();
73
  gradient_structure::set_YES_SAVE_VARIABLES_VALUES();
74

  
75
  dlink link;
76
  ASSERT_EQ(link.previous(), nullptr);
29 77
}
78
TEST(tests_threaded, dlist_create)
79
{
80
  ad_set_new_handler();
81
  ad_exit=&ad_boundf;
30 82

  
31
TEST(tests_threaded, simple_computations)
83
  gradient_structure::set_NO_DERIVATIVES();
84
  gradient_structure::set_YES_SAVE_VARIABLES_VALUES();
85

  
86
  dlist lst;
87

  
88
  dlink* lstlink = lst.create();
89
  if (lstlink == nullptr)
90
  {
91
    FAIL(); 
92
  }
93
  ASSERT_EQ(lst.check_list(), 0);
94
}
95
TEST(tests_threaded, dlist_append)
32 96
{
97
  ad_set_new_handler();
98
  ad_exit=&ad_boundf;
99

  
100
  gradient_structure::set_NO_DERIVATIVES();
101
  gradient_structure::set_YES_SAVE_VARIABLES_VALUES();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff