Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lonsing
Copy link
Collaborator

@lonsing lonsing commented Jul 10, 2020

Changes in this PR:

  • Move the handing of command line options from main function in pono.cpp to a new class PonoOptions. The purpose of this change is to simplify the main function and make option handling more extensible (e.g. as future work, we might want to set options via calls of an API). Also, with this change, options can be accessed from any class by referencing a global PonoOptions object. As for the Logger object, exactly one PonoOptions object exists.
  • Define a new enum PonoResult representing the return value of the main function in pono.cpp (formerly called int status_code) to avoid the use of magic constants.

@lonsing lonsing added enhancement New feature or request simple A very simple (meaning easy to review) change. labels Jul 10, 2020
@lonsing lonsing requested review from ahmed-irfan and makaimann July 10, 2020 04:34
PonoResult parse_and_set_options (int argc, char ** argv);

// Pono options
Engine engine;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use the convention to append _ at the end of every data member.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though, we are not clear if we would use this convention for private members only

@ahmed-irfan
Copy link
Collaborator

clang-format

Copy link
Collaborator

@makaimann makaimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! It will definitely be nice to handle options in a more cohesive way. I just left a few comments.


typedef enum
{
PROPERTY_TRUE = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely makes sense to avoid magic constants, but I'm wondering if we should just unify this and ProverResult instead of having two separate classes: https://github.com/upscale-project/pono/blob/e25fb8fa112eeb2b85427fda9475d9b247994654/core/proverresult.h#L25


namespace pono {

bool PonoOptions::instance_created = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is global, right? Does this mean there's only one PonoOptions object allowed? We don't have to do this now, but it might actually be nice to allow multiple option configurations in memory. In IC3IA for example, options are a struct that's passed to the prover and it accesses the different options from there. Then, you can have programs that run provers with different options.

class PonoOptions
{

// TODO: for now, all class members (i.e., Pono options) are public
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also just make this a struct. For this kind of object, I'm not opposed to keeping everything public. What are your thoughts @lonsing and @ahmed-irfan?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct sounds good.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a second thought, maybe class would be more clean and safe.

@lonsing
Copy link
Collaborator Author

lonsing commented Jul 12, 2020

Thanks for you feedback, @makaimann and @ahmed-irfan!

I addressed your comments in my changes:

  • running clang-format
  • member variable names have post-fix "_"
  • multiple PonoOptions objects can exist. Optionally, a PonoOptions object can be passed to the constructor of the Prover class, to make potentially different options available in a Prover
  • merge ProverResult and PonoResult classes, removing the latter. ProverResult now has ERROR as an additional value.

engines/bmc.h Outdated
{
public:
Bmc(const Property & p, smt::SmtSolver & solver);
Bmc(PonoOptions & opt, const Property & p, smt::SmtSolver & solver);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the options object reference be const

engines/prover.h Outdated
{
public:
Prover(const Property & p, smt::SmtSolver & s);
Prover(PonoOptions & opt, const Property & p, smt::SmtSolver & s);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const PonoOptions &opt

Copy link
Collaborator

@makaimann makaimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I just left one minor comment. IMO after that and addressing @ahmed-irfan's comments, this is ready to merge.

PonoOptions pono_options;
ProverResult res = pono_options.parse_and_set_options(argc, argv);
if (res == ERROR) return res;
assert(res == pono::UNKNOWN);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add one comment before this assert just clarifying that it should be unknown if the options are all set and error otherwise?

@lonsing
Copy link
Collaborator Author

lonsing commented Jul 15, 2020

Thanks, @makaimann and @ahmed-irfan, I included your suggested changes.

Please let me know whether you are fine with merging this.

Copy link
Collaborator

@ahmed-irfan ahmed-irfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lonsing lonsing merged commit 7f3c094 into stanford-centaur:master Jul 15, 2020
lonsing added a commit to lonsing/pono that referenced this pull request Sep 1, 2020
…-centaur#51)

* handle cmd-line options in separate class

* clang-format

* pass PonoOptions object to Prover object

* fixed options default initialization

* unify ProverResult and PonoResult (removing the latter class)

* clang-format

* passing 'const PonoOptions &', adding comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request simple A very simple (meaning easy to review) change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants