implicit_vs_explicit - noma/ham GitHub Wiki

Implicit vs. Explicit Initialisation

Usually, HAM-Offload is implicitly initialised and de-initialised. For the application developer, the programme starts with its main() as expected. What really happens is: HAM-Offload renames the main() provided by the application during compilation and calls its own main() instead that does what needs to be done, and then executes the original main() function. For most application, this is not a problem, but for some it might be. For instance, when you write your own library that performs offloading internally. For such chases, there is the define HAM_EXPLICIT. It switches the initialisation into an explicit mode, where ham_init() and ham_finalise() must be called manually in each process.

bool ham_init(int argc, char* argv[])
Initialises HAM-Offload. Must be called in every process of the application before using HAM-Offload. Returns true if the process is the logical host. For all other processes, it blocks, until the host calls ham_finalise() and then returns false.

int ham_finalise()
Returns 0 or some error code.

See ham_offload_explicit.cpp for an example (vs. ham_offload.cpp ).