Skip to content

Application Object #33

@henryiii

Description

@henryiii

GooFit 2.0 could have an App object, which is created at the beginning of main and goes out of scope at the end. This object could do MPI construction/cleanup, command line parsing, and other tasks. The API changes in 2.0 are an ideal place to add this object.

This is the proposed interface:

GooFit::Application app("This is my program", argc, argv);

This is the only piece required to handle MPI setup and teardown. However, it is highly recommended to also "run" the application (below), since that handles standard options to all goofit programs, like printing info about the card/processor, and includes a help flag.

Adding options is simple:

int val=0;
app.add_option("-v,--val", val, "Please set this value", true);

This subclasses my CLI11 library and modifies it to support a ROOT like constructor. It can process ints, floats, and strings, as well as vectors of arguments, flags, and sets. It can also handle positional arguments, defaults, required options, validators, and sub-commands with callbacks.

To parse the arguments and exit if needed:

try {
    app.run();
} catch(GooFit::ParseError &e) {
    return app.exit(e);
}

All examples have been fully converted to use this new object; the pipipi0 fit was modified to take human readable input, please check with --help and look at the code. Please also look at product and convolution in the MPI branch, those have been changed to avoid memory leakage.

Current Application support:

  • Hidden -DGOOFIT_MPI CMake options finds MPI and activates setup/cleanup
  • Help, gpu device list, gpu card or OMP thread info
  • ROOT TApplication-like interface
  • Setting a device (careful: any threading code must also set device)
  • Timing info? Not currently included

Original request:
I’m wondering if you have considered adding a goofit_init/goofit_cleanup functions that would be required for initialization/cleanup? I would request this type of functionality to embed MPI_Init call/cleanup, which would be an easy way to hide the messy macro code from the user-side. No variables are cleaned up in the examples, are these meant to be cleaned up by user code? The cleanup would be useful to have the PDF’s free up their memory, I don’t see any memory cleanup occurring.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions