├── HPX_Projects_solution_suppressions.cfg
├── Apps
└── HpxTest_1
│ ├── functions.hpp
│ ├── HPX.Release.props
│ ├── stdafx.cpp
│ ├── targetver.h
│ ├── functions.cpp
│ ├── components.hpp
│ ├── stdafx.h
│ ├── HPX.props
│ ├── register.h
│ ├── stubs.h
│ ├── clients.h
│ ├── HpxTest_1.vcxproj.filters
│ ├── HpxTest_1.cpp
│ └── HpxTest_1.vcxproj
├── Libs
└── SmallServer
│ ├── SmallServer.cpp
│ ├── lib.cpp
│ ├── SmallServer.h
│ ├── SmallServer.vcxproj.filters
│ └── SmallServer.vcxproj
├── LICENSE
├── HPX_Projects.sln
├── .gitignore
└── README.md
/HPX_Projects_solution_suppressions.cfg:
--------------------------------------------------------------------------------
1 | [cppcheck]
2 | missingIncludeSystem:*:0
3 | missingIncludeSystem
4 | *:*
5 | [cppcheck_files]
6 | [cppcheck_includes]
7 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/functions.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace app {
4 | namespace functions {
5 | void print_number(double v);
6 | int get_number();
7 | int increase_ten(int v);
8 | int increase_one(int v);
9 | double divide_number(double v);
10 | }
11 | }
--------------------------------------------------------------------------------
/Apps/HpxTest_1/HPX.Release.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // HpxTest_1.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/Libs/SmallServer/SmallServer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "SmallServer.h"
3 |
4 | namespace mylib {
5 | namespace components {
6 | void server::print_greeting(const std::string& name) {
7 | auto id = this->get_id();
8 | hpx::cout<< "[ID " << id << "] " << "Hello " << name << hpx::endl;
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/Apps/HpxTest_1/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/functions.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | namespace app {
4 | namespace functions {
5 | void print_number(double v)
6 | {
7 | hpx::cout << "value is: " << v << hpx::endl;
8 | }
9 | int get_number() {
10 | return 42;
11 | }
12 |
13 | int increase_ten(int v) {
14 | return v + 10;
15 | }
16 |
17 | int increase_one(int v) {
18 | return v + 1;
19 | }
20 |
21 | double divide_number(double v) {
22 | if (v == 0) {
23 | HPX_THROW_EXCEPTION(hpx::bad_parameter,
24 | "divide_number", "Given number is zero");
25 | }
26 | return (v / 2);
27 | }
28 |
29 | }
30 | }
--------------------------------------------------------------------------------
/Libs/SmallServer/lib.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "smallserver.h"
5 |
6 | //original code: http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/init/configuration/loading_components.html
7 | //adapted to work under Visual Studio
8 |
9 | using server_type = hpx::components::component;
10 |
11 | // Define boilerplate required once per component module.
12 | HPX_REGISTER_COMPONENT_MODULE();
13 |
14 | // Define factory object associated with our component of type 'app_server'.
15 | HPX_REGISTER_COMPONENT(server_type, app_server);
16 |
17 | // Define boilerplate code required for each of the component actions. Use the
18 | // same argument as used for HPX_REGISTER_ACTION_DECLARATION above.
19 | HPX_REGISTER_ACTION(server_type::wrapped_type::print_greeting_action, server_print_greeting_action);
--------------------------------------------------------------------------------
/Apps/HpxTest_1/components.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace app {
4 | namespace components {
5 | class MyMachine : public
6 | hpx::components::locking_hook<
7 | hpx::components::component_base> {
8 |
9 | public:
10 | using argument_type = boost::int64_t;
11 |
12 | MyMachine() {
13 | hpx::cout << "[COMPONENT] ctor called" << hpx::endl;
14 | }
15 | ~MyMachine() {
16 | hpx::cout << "[COMPONENT] dtor called" << hpx::endl;
17 | }
18 | argument_type get_number() const {
19 | return num_;
20 | }
21 | void set_number(argument_type v) {
22 | num_ = v;
23 | }
24 | HPX_DEFINE_COMPONENT_ACTION(MyMachine, get_number);
25 | HPX_DEFINE_COMPONENT_ACTION(MyMachine, set_number);
26 | private:
27 | argument_type num_ = 42;
28 | };
29 | }
30 | }
31 |
32 | HPX_REGISTER_ACTION_DECLARATION(app::components::MyMachine::get_number_action, machine_get_number_action);
33 | HPX_REGISTER_ACTION_DECLARATION(app::components::MyMachine::set_number_action, machine_set_number_action);
--------------------------------------------------------------------------------
/Apps/HpxTest_1/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 | #define _CRT_SECURE_NO_WARNINGS
8 | #define _SCL_SECURE_NO_WARNINGS
9 | #define _CRT_NON_CONFORMING_SWPRINTFS
10 | #define HPX_COMPONENT_EXPORTS
11 | #include "targetver.h"
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 |
19 |
20 | // TODO: reference additional headers your program requires here
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #include
28 | #include
29 |
30 | #include "functions.hpp"
31 | #include "components.hpp"
32 | #include "stubs.h"
33 | #include "clients.h"
34 |
35 | // SmallServer references
36 | #include "../../Libs/SmallServer/SmallServer.h"
--------------------------------------------------------------------------------
/Apps/HpxTest_1/HPX.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <_PropertySheetDisplayName>HPX
7 |
8 |
9 |
10 | $(HWLOC_ROOT)\include;$(GSL_ROOT)\include;$(HPX_ROOT)\include;$(HPX_ROOT)\include\hpx\external;$(BOOST_ROOT)\include\boost-1_60;
11 | -Zc:inline -Zc:throwingNew -bigobj %(AdditionalOptions)
12 | BOOST_ALL_DYN_LINK;_MBCS;%(PreprocessorDefinitions)
13 | CompileAsCpp
14 |
15 |
16 | $(HPX_ROOT)\lib;$(BOOST_ROOT)\lib;$(HWLOC_ROOT)\lib;%(AdditionalLibraryDirectories)
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Libs/SmallServer/SmallServer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 |
9 | namespace mylib
10 | {
11 | namespace components {
12 | // Define a simple component exposing one action 'print_greeting'
13 | class HPX_COMPONENT_EXPORT server
14 | : public hpx::components::component_base
15 | {
16 | public:
17 | server() {
18 | hpx::cout << "[SERVER] ctor called" << hpx::endl;
19 | }
20 | ~server() {
21 | hpx::cout << "[SERVER] dtor called" << hpx::endl;
22 | }
23 | void print_greeting(const std::string& name);
24 |
25 | // Component actions need to be declared, this also defines the
26 | // type 'print_greeting_action' representing the action.
27 | HPX_DEFINE_COMPONENT_ACTION(server, print_greeting, print_greeting_action);
28 | };
29 | }
30 | }
31 |
32 | // Declare boilerplate code required for each of the component actions.
33 | HPX_REGISTER_ACTION_DECLARATION(
34 | mylib::components::server::print_greeting_action,
35 | server_print_greeting_action);
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Harris Brakmic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/register.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | // Add factory registration functionality.
3 | HPX_REGISTER_COMPONENT_MODULE();
4 |
5 | //******************************ACTIONS***********************************
6 | HPX_PLAIN_ACTION(app::functions::print_number, global_print_number);
7 | HPX_PLAIN_ACTION(app::functions::get_number, global_get_number);
8 | HPX_PLAIN_ACTION(app::functions::increase_ten, global_increase_ten);
9 | HPX_PLAIN_ACTION(app::functions::increase_one, global_increase_one);
10 | HPX_PLAIN_ACTION(app::functions::divide_number, global_divide_number);
11 | //************************************************************************
12 |
13 |
14 | //******************************COMPONENTS********************************
15 | using mycomp_type = hpx::components::simple_component;
16 | using argument_type = mycomp_type::argument_type;
17 | HPX_REGISTER_COMPONENT(mycomp_type, MyMachine);
18 | HPX_REGISTER_ACTION(mycomp_type::wrapped_type::get_number_action, machine_get_number_action);
19 | HPX_REGISTER_ACTION(mycomp_type::wrapped_type::set_number_action, machine_set_number_action);
20 | //************************************************************************
--------------------------------------------------------------------------------
/Libs/SmallServer/SmallServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/stubs.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | namespace app {
3 | namespace stubs {
4 | struct mycomp :
5 | hpx::components::stub_base {
6 |
7 | using argument_type = components::MyMachine::argument_type;
8 |
9 | static void set_number_async(hpx::naming::id_type const& gid, argument_type v) {
10 | hpx::cout << "[STUB] set_number_async, value: " << v << hpx::endl;
11 | using action_type = components::MyMachine::set_number_action;
12 | hpx::async(gid, v);
13 | }
14 |
15 | static void set_number_sync(hpx::naming::id_type const& gid, argument_type v) {
16 | hpx::cout << "[STUB] set_number_sync, value: " << v << hpx::endl;
17 | using action_type = components::MyMachine::set_number_action;
18 | hpx::async(gid, v).get();
19 | }
20 |
21 | static hpx::lcos::future get_number_async(hpx::naming::id_type const& gid) {
22 | hpx::cout << "[STUB] get_number_async" << hpx::endl;
23 | using action_type = components::MyMachine::get_number_action;
24 | return hpx::async(gid);
25 | }
26 |
27 | static argument_type get_number_sync(hpx::naming::id_type const& gid) {
28 | hpx::cout << "[STUB] get_number_sync" << hpx::endl;
29 | return get_number_async(gid).get();
30 | }
31 | };
32 | }
33 | }
--------------------------------------------------------------------------------
/Apps/HpxTest_1/clients.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //Defining Client Side Representation Classes
3 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/components/components_client.html
4 |
5 | namespace app {
6 | namespace clients {
7 | class myclient :
8 | public hpx::components::client_base
9 | {
10 |
11 | using base_type = hpx::components::client_base;
12 | using argument_type = base_type::argument_type;
13 |
14 | public:
15 | myclient() {
16 | hpx::cout << "[CLIENT] default ctor called" << hpx::endl;
17 | }
18 | myclient(hpx::future&& gid)
19 | : base_type(std::move(gid)) {
20 | hpx::cout << "[CLIENT] ctor called" << hpx::endl;
21 | }
22 | ~myclient() {
23 | hpx::cout << "[CLIENT] dtor called" << hpx::endl;
24 | }
25 | void set_number_async(argument_type v) {
26 | HPX_ASSERT(this->get_id());
27 | this->base_type::set_number_async(this->get_id(), v);
28 | }
29 | void set_number_sync(argument_type v) {
30 | HPX_ASSERT(this->get_id());
31 | this->base_type::set_number_sync(this->get_id(), v);
32 | }
33 | hpx::future get_number_async() {
34 | HPX_ASSERT(this->get_id());
35 | return this->base_type::get_number_async(this->get_id());
36 | }
37 | argument_type get_number() {
38 | HPX_ASSERT(this->get_id());
39 | return this->base_type::get_number_sync(this->get_id());
40 | }
41 | };
42 | }
43 | }
--------------------------------------------------------------------------------
/Apps/HpxTest_1/HpxTest_1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 | Header Files
32 |
33 |
34 | Header Files
35 |
36 |
37 | Header Files
38 |
39 |
40 | Header Files
41 |
42 |
43 |
44 |
45 | Source Files
46 |
47 |
48 | Source Files
49 |
50 |
51 | Source Files
52 |
53 |
54 |
--------------------------------------------------------------------------------
/HPX_Projects.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25008.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{CB2CA5E2-C98F-4DBB-9F2B-528839917EDB}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{C26EE6B0-0E43-44A8-8C43-A054350E174D}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HpxTest_1", "Apps\HpxTest_1\HpxTest_1.vcxproj", "{03E4AF23-4B81-410B-9D5E-7FA175141C31}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{32632EC9-8A10-46C8-A152-CA4B5A9516AB}"
13 | ProjectSection(SolutionItems) = preProject
14 | .gitignore = .gitignore
15 | LICENSE = LICENSE
16 | README.md = README.md
17 | EndProjectSection
18 | EndProject
19 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SmallServer", "Libs\SmallServer\SmallServer.vcxproj", "{EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}"
20 | EndProject
21 | Global
22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 | Debug|x64 = Debug|x64
24 | Debug|x86 = Debug|x86
25 | Release|x64 = Release|x64
26 | Release|x86 = Release|x86
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Debug|x64.ActiveCfg = Debug|x64
30 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Debug|x64.Build.0 = Debug|x64
31 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Debug|x86.ActiveCfg = Debug|Win32
32 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Debug|x86.Build.0 = Debug|Win32
33 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Release|x64.ActiveCfg = Release|x64
34 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Release|x64.Build.0 = Release|x64
35 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Release|x86.ActiveCfg = Release|Win32
36 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}.Release|x86.Build.0 = Release|Win32
37 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Debug|x64.ActiveCfg = Debug|x64
38 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Debug|x64.Build.0 = Debug|x64
39 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Debug|x86.ActiveCfg = Debug|Win32
40 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Debug|x86.Build.0 = Debug|Win32
41 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Release|x64.ActiveCfg = Release|x64
42 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Release|x64.Build.0 = Release|x64
43 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Release|x86.ActiveCfg = Release|Win32
44 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}.Release|x86.Build.0 = Release|Win32
45 | EndGlobalSection
46 | GlobalSection(SolutionProperties) = preSolution
47 | HideSolutionNode = FALSE
48 | EndGlobalSection
49 | GlobalSection(NestedProjects) = preSolution
50 | {03E4AF23-4B81-410B-9D5E-7FA175141C31} = {CB2CA5E2-C98F-4DBB-9F2B-528839917EDB}
51 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2} = {C26EE6B0-0E43-44A8-8C43-A054350E174D}
52 | EndGlobalSection
53 | EndGlobal
54 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/HpxTest_1.cpp:
--------------------------------------------------------------------------------
1 | // HpxTest_1.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include "stdafx.h"
5 | #include "register.h"
6 |
7 | void function_invocation_demo(hpx::naming::id_type id)
8 | {
9 | //Applying an Action Asynchronously with Synchronization
10 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/applying_actions/action_invocation/async.html
11 |
12 | global_print_number printNo;
13 | global_get_number getNo;
14 |
15 | hpx::apply(printNo, id, 2.0);
16 | hpx::future f2 = hpx::async(getNo, id);
17 |
18 | auto value1 = f2.get();
19 | hpx::cout << "Async function returned: " << value1 << hpx::endl;
20 | //Applying an Action Synchronously
21 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/applying_actions/action_invocation/sync.html
22 | printNo(id, 5.0);
23 | }
24 |
25 | void continuation_demo(hpx::naming::id_type id)
26 | {
27 | //Applying an Action with a Continuation and with Synchronization
28 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/applying_actions/action_invocation/apply_continue.html
29 | global_increase_ten incTen;
30 | global_increase_one incOne;
31 | hpx::future ret2 = hpx::async_continue(incTen, hpx::make_continuation(incOne), id, 31);
32 | auto contValue = ret2.get();
33 | hpx::cout << "Value from continuation: " << contValue << hpx::endl;
34 |
35 | }
36 |
37 | void error_handling_demo(hpx::naming::id_type id)
38 | {
39 | //Action Error Handling
40 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/applying_actions/action_error_handling.html
41 | global_divide_number divNo;
42 | try
43 | {
44 | divNo(id, 0);
45 | //divNo(id, -1.0);
46 | }
47 | catch (hpx::exception const& e)
48 | {
49 | hpx::cout << "Exception thrown: " << e.what() << hpx::endl;
50 | }
51 | }
52 |
53 | void component_demo()
54 | {
55 | //Defining Components
56 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/components/components_server.html
57 | //get component's and default argument's types
58 | using my_machine_type = app::components::MyMachine;
59 | using argument_type = my_machine_type::argument_type;
60 | //find all localities
61 | std::vector localities = hpx::find_all_localities();
62 | //instantiate a client accessing our component
63 | app::clients::myclient client1(hpx::components::new_(localities.back()));
64 | //remember component's id
65 | auto cid = client1.get_id();
66 | //access the component's get_number-method synchronously (look into stub-declaration for more info)
67 | argument_type aNumber = client1.get_number_sync(cid);
68 | hpx::cout << "Original value from component: " << aNumber << hpx::endl;
69 | //access component's set_number synchronously
70 | client1.set_number_sync(125);
71 | //access component's get_number synchronously
72 | aNumber = client1.get_number_sync(cid);
73 | hpx::cout << "Component changed value to: " << aNumber << hpx::endl;
74 | }
75 |
76 | void dll_component_demo(std::size_t num_components, const std::string& name)
77 | {
78 | //Loading components
79 | //http://stellar.cct.lsu.edu/files/hpx-0.9.11/html/hpx/manual/init/configuration/loading_components.html
80 | std::vector localities = hpx::find_all_localities();
81 | hpx::components::component_type svc_type =
82 | mylib::components::server::get_component_type();
83 | std::vector components =
84 | hpx::new_(
85 | hpx::default_layout(localities), num_components).get();
86 |
87 | mylib::components::server::print_greeting_action say_hello;
88 | for (auto c : components) {
89 | say_hello(c, name);
90 | }
91 | }
92 |
93 | int hpx_main(int argc, char* argv[])
94 | {
95 | //get local id
96 | auto id = hpx::find_here();
97 | auto num_components = 10;
98 | const std::string name = "Harris";
99 |
100 | function_invocation_demo(id);
101 |
102 | continuation_demo(id);
103 |
104 | error_handling_demo(id);
105 |
106 | component_demo();
107 |
108 | dll_component_demo(num_components, name);
109 |
110 | //shutdown HPX
111 | return hpx::finalize();
112 | }
113 |
114 | int main(int argc, char* argv[])
115 | {
116 | //setup any app-specific options
117 | boost::program_options::options_description desc_commandline(
118 | "usage: " HPX_APPLICATION_STRING " [options]");
119 | //init HPX and start the app
120 | return hpx::init(desc_commandline, argc, argv);
121 | }
122 |
123 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 |
24 | # Visual Studio 2015 cache/options directory
25 | .vs/
26 | # Uncomment if you have tasks that create the project's static files in wwwroot
27 | #wwwroot/
28 |
29 | # MSTest test Results
30 | [Tt]est[Rr]esult*/
31 | [Bb]uild[Ll]og.*
32 |
33 | # NUNIT
34 | *.VisualState.xml
35 | TestResult.xml
36 |
37 | # Build Results of an ATL Project
38 | [Dd]ebugPS/
39 | [Rr]eleasePS/
40 | dlldata.c
41 |
42 | # DNX
43 | project.lock.json
44 | artifacts/
45 |
46 | *_i.c
47 | *_p.c
48 | *_i.h
49 | *.ilk
50 | *.meta
51 | *.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.tmp_proj
63 | *.log
64 | *.vspscc
65 | *.vssscc
66 | .builds
67 | *.pidb
68 | *.svclog
69 | *.scc
70 |
71 | # Chutzpah Test files
72 | _Chutzpah*
73 |
74 | # Visual C++ cache files
75 | ipch/
76 | *.aps
77 | *.ncb
78 | *.opendb
79 | *.opensdf
80 | *.sdf
81 | *.cachefile
82 |
83 | # Visual Studio profiler
84 | *.psess
85 | *.vsp
86 | *.vspx
87 | *.sap
88 |
89 | # TFS 2012 Local Workspace
90 | $tf/
91 |
92 | # Guidance Automation Toolkit
93 | *.gpState
94 |
95 | # ReSharper is a .NET coding add-in
96 | _ReSharper*/
97 | *.[Rr]e[Ss]harper
98 | *.DotSettings.user
99 |
100 | # JustCode is a .NET coding add-in
101 | .JustCode
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | _NCrunch_*
111 | .*crunch*.local.xml
112 | nCrunchTemp_*
113 |
114 | # MightyMoose
115 | *.mm.*
116 | AutoTest.Net/
117 |
118 | # Web workbench (sass)
119 | .sass-cache/
120 |
121 | # Installshield output folder
122 | [Ee]xpress/
123 |
124 | # DocProject is a documentation generator add-in
125 | DocProject/buildhelp/
126 | DocProject/Help/*.HxT
127 | DocProject/Help/*.HxC
128 | DocProject/Help/*.hhc
129 | DocProject/Help/*.hhk
130 | DocProject/Help/*.hhp
131 | DocProject/Help/Html2
132 | DocProject/Help/html
133 |
134 | # Click-Once directory
135 | publish/
136 |
137 | # Publish Web Output
138 | *.[Pp]ublish.xml
139 | *.azurePubxml
140 | # TODO: Comment the next line if you want to checkin your web deploy settings
141 | # but database connection strings (with potential passwords) will be unencrypted
142 | *.pubxml
143 | *.publishproj
144 |
145 | # NuGet Packages
146 | *.nupkg
147 | # The packages folder can be ignored because of Package Restore
148 | **/packages/*
149 | # except build/, which is used as an MSBuild target.
150 | !**/packages/build/
151 | # Uncomment if necessary however generally it will be regenerated when needed
152 | #!**/packages/repositories.config
153 | # NuGet v3's project.json files produces more ignoreable files
154 | *.nuget.props
155 | *.nuget.targets
156 |
157 | # Microsoft Azure Build Output
158 | csx/
159 | *.build.csdef
160 |
161 | # Microsoft Azure Emulator
162 | ecf/
163 | rcf/
164 |
165 | # Microsoft Azure ApplicationInsights config file
166 | ApplicationInsights.config
167 |
168 | # Windows Store app package directory
169 | AppPackages/
170 | BundleArtifacts/
171 |
172 | # Visual Studio cache files
173 | # files ending in .cache can be ignored
174 | *.[Cc]ache
175 | # but keep track of directories ending in .cache
176 | !*.[Cc]ache/
177 |
178 | # Others
179 | ClientBin/
180 | ~$*
181 | *~
182 | *.dbmdl
183 | *.dbproj.schemaview
184 | *.pfx
185 | *.publishsettings
186 | node_modules/
187 | orleans.codegen.cs
188 |
189 | # RIA/Silverlight projects
190 | Generated_Code/
191 |
192 | # Backup & report files from converting an old project file
193 | # to a newer Visual Studio version. Backup files are not needed,
194 | # because we have git ;-)
195 | _UpgradeReport_Files/
196 | Backup*/
197 | UpgradeLog*.XML
198 | UpgradeLog*.htm
199 |
200 | # SQL Server files
201 | *.mdf
202 | *.ldf
203 |
204 | # Business Intelligence projects
205 | *.rdl.data
206 | *.bim.layout
207 | *.bim_*.settings
208 |
209 | # Microsoft Fakes
210 | FakesAssemblies/
211 |
212 | # GhostDoc plugin setting file
213 | *.GhostDoc.xml
214 |
215 | # Node.js Tools for Visual Studio
216 | .ntvs_analysis.dat
217 |
218 | # Visual Studio 6 build log
219 | *.plg
220 |
221 | # Visual Studio 6 workspace options file
222 | *.opt
223 |
224 | # Visual Studio LightSwitch build output
225 | **/*.HTMLClient/GeneratedArtifacts
226 | **/*.DesktopClient/GeneratedArtifacts
227 | **/*.DesktopClient/ModelManifest.xml
228 | **/*.Server/GeneratedArtifacts
229 | **/*.Server/ModelManifest.xml
230 | _Pvt_Extensions
231 |
232 | # Paket dependency manager
233 | .paket/paket.exe
234 |
235 | # FAKE - F# Make
236 | .fake/
237 |
238 | # db files
239 | *.db
240 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### HPX Projects
2 |
3 | This is a collection of small demos showing different functionalities from HPX.
4 |
5 | All parts are based on Visual C++ under VS 2015.
6 |
7 | HPX version: **0.9.11**
8 |
9 | BOOST version: **1.60**
10 |
11 | HWLOC version: **1.11.0**
12 |
13 | The configuration procedure of HPX with Visual Studio is rather complex and can quickly lead to very confusing errors.
14 |
15 | Therefore I'd recommend to use my small tutorial on building HPX under Windows.
16 |
17 | For a more detailed explanation and examples you can read my article on HPX.
18 |
19 | #### Configuration
20 |
21 | To make the configuration of Project-Options easier I've extracted some `default` properties into a separate `prop` file.
22 |
23 |
24 |
25 | I'm using the following system-variables to access Boost, HwLoc and HPX libraries:
26 |
27 | ```
28 |
29 | BOOST_ROOT = C:\lib\boost
30 | HWLOC_ROOT = C:\bin\hwloc
31 | HPX_ROOT = C:\bin\hpx
32 | ```
33 |
34 | In my `PATH` there are some additional entries pointing at subdirectories inside the above roots:
35 |
36 | ```
37 |
38 | %BOOST_ROOT%\lib
39 | %HPX_ROOT%\bin
40 | ```
41 |
42 | This is, of course, not mandatory and you can create your own paths. What's important is that you have
43 | the libs installed and accessible under some system-wide variables.
44 |
45 | #### Visual Studio Project Properties
46 |
47 | After having compiled and installed the libraries (boost, hpx & hwloc) you have to insert certain *library* and *include* paths. These settings will look like in the screenshot below. There's a separate properties-file with several `defaults` available so you can more easily adapt the project to your environment. The most important part will be the different library `ROOTs`.
48 |
49 |
50 |
51 | #### Compilation
52 |
53 | The compilation is straightforward. Just use the standard **Debug/Release** facilities.
54 |
55 | #### Execution
56 |
57 | Currently, the whole execution logic is packed into **a single ugly** `source file`. At least the participating objects and functions are defined over several `cpp` and `hpp` files. But soon I'll provide a better structure. The main focus will be on `actions` and `components`. This project already contains a few actions and a component implementing some (a)synchronous methods. There's also a separate DLL-Project available that defines another HPX-Component (`SmallServer.dll`) to be used in this demo. The output is *console-based* and currently looks like this:
58 |
59 |
60 |
61 | The program's `main` is located in `HpxTest_1.cpp` which contains a special `hpx_main` function
62 | where HPX kicks in. To make the app aware of this additional `main` function we have to
63 | execute another HPX-function called `hpx::init`. Of course, this is not the only way to start an
64 | HPX app. There are several possibilities for different use-cases.
65 |
66 |
67 |
68 | In our case the `hpx::main` contains a bunch of calls to other functions which utilize
69 | different functionalities from HPX.
70 |
71 |
72 |
73 | - Applying **(a)synchronous** `actions`.
74 |
75 | In HPX actions are like wrappers that map to `real functions`.
76 | And it doesn't matter if they're available locally or on some other machine. In fact, HPX maintans its own
77 | `registry` for managing actions and components so you don't have to fiddle around with memory addressing. Instead,
78 | HPX assigns a globally unique id to a `thing`. Only this Id is needed to localize a `thing`. Also, HPX can move
79 | `things` around the global memory. For example, when there's no sufficient memory on a certain machine HPX can take
80 | some components and move them to other machine within the cluster. HPX does this by using `parcels` which are basically
81 | `serialized` functions and/or components. HPX also extends the standard C++ syntax for asynchronous function calling.
82 |
83 | - **Continuations** demo.
84 |
85 | A continuation allows us to chain several functions together and forward their results down the chain.
86 |
87 | - **Error handling** in HPX
88 |
89 | Asynchronous functions throw *asynchronous* errors. And in highly parallel systems errors are really hard to handle. But HPX keeps the complexity away by providing
90 | nice facilities for location-agnostic error handling.
91 |
92 | - **Components**
93 |
94 | HPX supports remotely manageable components. In this demo part we initialize a component and call it's (a)synchronous methods to manipulate a number.
95 |
96 | - **Components from DLLs**
97 |
98 | HPX also supports loading components from DLLs. In this example we have a `SmallServer.dll` that lives in a project of the same name.
99 |
100 |
101 |
102 | Our client app `HpxTest_1.exe` should be able to load and execute exported methods from **SmallServer.dll**. This is done the `standard way` via `#include "smallserver.h"` where the needed `function declarations` & `component exports` are located. It's important to know that in this file **no function definitions** should be located.
103 | Any function definition in this header file will ultimately lead to weird `dllimport errors`. Put your function definitions into `SmallServer.cpp`. The import library file SmallServer.lib is located in the Output directory: `x64/Debug` respective `x64/Release`. HpxTest_1.exe needs this file for mapping to SmallServer-exports.
104 |
105 | *If you'd prefer some other location take care of properly setting the import-library paths in Project Settings.*
106 |
107 |
108 |
109 | #### License
110 |
111 | MIT
--------------------------------------------------------------------------------
/Libs/SmallServer/SmallServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {EFA436B8-4A4D-48D9-9978-9CC73BEB04F2}
23 | SmallServer
24 | 10.0.10240.0
25 |
26 |
27 |
28 | Application
29 | true
30 | v140
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v140
37 | true
38 | MultiByte
39 |
40 |
41 | DynamicLibrary
42 | true
43 | v140
44 | MultiByte
45 |
46 |
47 | DynamicLibrary
48 | false
49 | v140
50 | false
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | .dll
75 |
76 |
77 | .dll
78 | false
79 |
80 |
81 |
82 | Level3
83 | Disabled
84 | true
85 |
86 |
87 |
88 |
89 | Level3
90 | Disabled
91 |
92 |
93 | ProgramDatabase
94 | true
95 | Disabled
96 | _MBCS;HPX_COMPONENT_NAME=hpx_smallserver;HPX_COMPONENT_STRING="hpx_smallserver";HPX_COMPONENT_EXPORTS;_WINDOWS;WINDOWS;_WIN32;WIN32;_DEBUG;DEBUG;CMAKE_INTDIR="Debug";smallserver_component_EXPORTS;%(PreprocessorDefinitions)
97 | true
98 | 4307;4180
99 | true
100 |
101 |
102 | hpxd.lib;hpx_initd.lib;hpx_iostreamsd.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;dbghelp.lib;psapi.lib;shlwapi.lib;libhwloc.lib;%(AdditionalDependencies)
103 | false
104 |
105 |
106 | /machine:x64 /debug %(AdditionalOptions)
107 | $(HPX_ROOT)\lib;$(BOOST_ROOT)\lib;$(HWLOC_ROOT)\lib;%(AdditionalLibraryDirectories)
108 |
109 |
110 |
111 |
112 | false
113 |
114 |
115 | false
116 |
117 |
118 |
119 |
120 | Level3
121 | MaxSpeed
122 | true
123 | true
124 | true
125 |
126 |
127 | true
128 | true
129 |
130 |
131 |
132 |
133 | Level3
134 | Full
135 |
136 |
137 | false
138 | true
139 | true
140 | AnySuitable
141 | true
142 | 4307;4180
143 | BOOST_ALL_DYN_LINK;_MBCS;HPX_COMPONENT_NAME=hpx_smallserver;HPX_COMPONENT_STRING="hpx_smallserver";HPX_COMPONENT_EXPORTS;_WINDOWS;WINDOWS;_WIN32;WIN32;_NDEBUG;NDEBUG;CMAKE_INTDIR="Release";smallserver_component_EXPORTS;%(PreprocessorDefinitions)
144 |
145 |
146 |
147 |
148 | true
149 | hpx.lib;hpx_init.lib;hpx_iostreams.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
150 | false
151 | %(IgnoreSpecificDefaultLibraries)
152 | No
153 | /machine:x64 %(AdditionalOptions)
154 |
155 |
156 | false
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
--------------------------------------------------------------------------------
/Apps/HpxTest_1/HpxTest_1.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {03E4AF23-4B81-410B-9D5E-7FA175141C31}
23 | Win32Proj
24 | HpxTest_1
25 | 10.0.10240.0
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v140
51 | false
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 | $(VC_IncludePath);$(WindowsSDK_IncludePath);
79 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64
80 |
81 |
82 | false
83 |
84 |
85 | false
86 | $(VC_IncludePath);$(WindowsSDK_IncludePath);
87 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64
88 |
89 |
90 |
91 | Use
92 | Level3
93 | Disabled
94 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
95 | true
96 |
97 |
98 | Console
99 | true
100 |
101 |
102 |
103 |
104 | Use
105 | Level3
106 | Disabled
107 | BOOST_ALL_DYN_LINK;WIN32;_WINDOWS;_DEBUG;HPX_APPLICATION_NAME=hpx_test_1_exe;HPX_APPLICATION_STRING="hpx_test_1";HPX_PREFIX="$(HPX_ROOT)";HPX_APPLICATION_EXPORTS;_WINDOWS;_WIN32;_DEBUG;DEBUG;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)
108 |
109 |
110 | $(HWLOC_ROOT)\include;$(GSL_ROOT)\include;$(HPX_ROOT)\include;$(HPX_ROOT)\include\hpx\external;$(BOOST_ROOT)\include\boost-1_60;
111 | EditAndContinue
112 | true
113 | Disabled
114 | true
115 | CompileAsCpp
116 | 4307;4180
117 | true
118 | -Zc:inline -Zc:throwingNew -bigobj %(AdditionalOptions)
119 |
120 |
121 | Console
122 | true
123 | $(OutDir);$(HPX_ROOT)\lib;$(BOOST_ROOT)\lib;$(HWLOC_ROOT)\lib;%(AdditionalLibraryDirectories)
124 | SmallServer.lib;hpxd.lib;hpx_initd.lib;hpx_iostreamsd.lib;hpx_cancelable_actiond.lib;libhwloc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
125 | %(IgnoreSpecificDefaultLibraries)
126 | /machine:x64 /debug %(AdditionalOptions)
127 |
128 |
129 | false
130 |
131 |
132 |
133 |
134 | Level3
135 | Use
136 | MaxSpeed
137 | true
138 | true
139 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
140 | true
141 |
142 |
143 | Console
144 | true
145 | true
146 | true
147 |
148 |
149 |
150 |
151 | Level3
152 | Use
153 | Full
154 |
155 |
156 | false
157 | BOOST_ALL_DYN_LINK;WIN32;_WINDOWS;NDEBUG;HPX_APPLICATION_NAME=hpx_test_1_exe;HPX_APPLICATION_STRING="hpx_test_1";HPX_PREFIX="$(HPX_ROOT)";HPX_APPLICATION_EXPORTS;_WINDOWS;_WIN32;HPX_DISABLE_ASSERTS;BOOST_DISABLE_ASSERTS;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)
158 |
159 |
160 | -Zc:inline -Zc:throwingNew -bigobj %(AdditionalOptions)
161 | true
162 | AnySuitable
163 | true
164 | CompileAsCpp
165 | 4307;4180
166 | false
167 |
168 |
169 | $(HWLOC_ROOT)\include;$(GSL_ROOT)\include;$(HPX_ROOT)\include;$(HPX_ROOT)\include\hpx\external;$(BOOST_ROOT)\include\boost-1_60;
170 | true
171 |
172 |
173 | Console
174 |
175 |
176 |
177 |
178 | true
179 | $(OutDir);$(HPX_ROOT)\lib;$(BOOST_ROOT)\lib;$(HWLOC_ROOT)\lib;%(AdditionalLibraryDirectories)
180 | SmallServer.lib;hpx.lib;hpx_init.lib;hpx_iostreams.lib;hpx_cancelable_action.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
181 | %(IgnoreSpecificDefaultLibraries)
182 | /machine:x64 %(AdditionalOptions)
183 |
184 |
185 |
186 | false
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 | Create
206 | Create
207 | Create
208 | Create
209 |
210 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------