1 // Copyright (C) 2012 Hartmut Kaiser
2 // Copyright (C) 2017 Christopher Taylor
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
5 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 #include <hpx/hpx_main.hpp>
8 #include <hpx/include/actions.hpp>
9 #include <hpx/include/runtime.hpp>
10 #include <hpx/runtime/threads/thread_data.hpp>
11 #include <hpx/util/lightweight_test.hpp>
12 
13 #include <cstring>
14 #include <vector>
15 
16 ///////////////////////////////////////////////////////////////////////////////
test_small_stacksize()17 void test_small_stacksize()
18 {
19     HPX_TEST(hpx::threads::get_self_ptr());
20     // verify that sufficient stack has been allocated
21     HPX_TEST_EQ(hpx::threads::get_ctx_ptr()->get_stacksize(),
22         hpx::get_runtime().get_config().get_stack_size(
23             hpx::threads::thread_stacksize_small));
24 
25     // allocate HPX_SMALL_STACK_SIZE - HPX_THREADS_STACK_OVERHEAD memory on the stack
26     char array[HPX_SMALL_STACK_SIZE*HPX_THREADS_STACK_OVERHEAD];
27 
28     // do something to that array
29     std::memset(array, '\0', sizeof(array));
30 }
HPX_DECLARE_ACTION(test_small_stacksize,test_small_stacksize_action)31 HPX_DECLARE_ACTION(test_small_stacksize, test_small_stacksize_action)
32 HPX_ACTION_USES_SMALL_STACK(test_small_stacksize_action)
33 HPX_PLAIN_ACTION(test_small_stacksize, test_small_stacksize_action)
34 
35 int main()
36 {
37     std::vector<hpx::id_type> localities = hpx::find_all_localities();
38 
39     for (hpx::id_type const& id : localities)
40     {
41         {
42             test_small_stacksize_action test_action;
43             test_action(id);
44         }
45 
46     }
47 
48     return hpx::util::report_errors();
49 }
50 
51