C++ Sample App
Lets compile the C++ sample app by going through it step by step. We assume you have installed vcpkg. Install whichever triplet you wish. Here we install the
C:\vcpkg>vcpkg install boost:x64-windows C:\vcpkg>vcpkg install bond:x64-windows C:\vcpkg>vcpkg install cppzmq:x64-windows
While all the files are provided in a single folder and you could compile it in one go, we will do so step by step so that you can see how the different pieces fit together.
Step 1: Create A C++ Project
Create a C++ project in your IDE. The samples use C++17 because it simplifies certain things. For example it enables structured bindings like
auto [x, y] = some_func(...) which greatly helps with code readability. C++17 also contains
std::optional which simplifies control flow.
If your project policy requires any versions lower than C++17, it shouldn’t be too difficult to modify it to run with C++11.
Step 2: Pull In Parietal Numerics Bindings
The following files are generated by the Bond codegen tool. These files contain not only the types and enums, but also the serialization and deserialization logic.
parietal_apply.h parietal_enum.h parietal_reflection.h parietal_types.h parietal_apply.cpp parietal_types.cpp
Step 3: Pull In Helper Files
The following is some machinery to help us get going. These are the sets of files you will have to adapt to your project policy.
helpers.h monitor_jobs.h serialization_helpers.h sockets.h zhelpers.hpp generate_data.h
Our main priority in writing these files (aside from zhelpers.hpp which is external) was to make them easy to understand… or as much as we could. For example, the Parietal context class
PC in the file
sockets.h is implemented as a Singleton. Whether or not you want Singletons in your project is your call. You can reimplement however you wish. However in the case of this sample app, it made things easy to understand.
Step 4: Pull In Individual Examples
example_glm.h example_impute.h example_ols.h example_cvlasso.h (async example)
Step 5: Pull In main.cpp
The entrypoint of the program.
Step 6: Compile & Run
You should now be able to compile the sample application. Make sure the Parietal Numerics engine is running in the background before you execute compiled sample application binary.