Support for -x option
authorbdemsky <bdemsky@uci.edu>
Sat, 25 Jan 2014 22:07:08 +0000 (14:07 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 25 Jan 2014 22:07:08 +0000 (14:07 -0800)
main.cc
model.cc
params.h
scanalysis.cc
scanalysis.h

diff --git a/main.cc b/main.cc
index d489d96..127ffd1 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -31,6 +31,7 @@ static void param_defaults(struct model_params *params)
        params->expireslop = 4;
        params->verbose = !!DBG_ENABLED();
        params->uninitvalue = 0;
+       params->maxexecutions = 0;
 }
 
 static void print_usage(const char *program_name, struct model_params *params)
@@ -77,13 +78,16 @@ static void print_usage(const char *program_name, struct model_params *params)
 "-b, --bound=MAX             Upper length bound.\n"
 "                              Default: %d\n"
 "-v[NUM], --verbose[=NUM]    Print verbose execution information. NUM is optional:\n"
-"                              0 is quiet; 1 is noisy; 2 is noisier.\n"
+"                              0 is quiet; 1 shows valid executions; 2 is noisy;\n"
+"                              3 is noisier.\n"
 "                              Default: %d\n"
 "-u, --uninitialized=VALUE   Return VALUE any load which may read from an\n"
 "                              uninitialized atomic.\n"
 "                              Default: %u\n"
 "-t, --analysis=NAME         Use Analysis Plugin.\n"
 "-o, --options=NAME          Option for previous analysis plugin.  \n"
+"-x, --maxexec=NUM           Maximum number of executions.\n"
+"                            Default: %u\n"
 "                            -o help for a list of options\n"
 " --                         Program arguments follow.\n\n",
                program_name,
@@ -97,7 +101,8 @@ static void print_usage(const char *program_name, struct model_params *params)
                params->enabledcount,
                params->bound,
                params->verbose,
-               params->uninitvalue);
+    params->uninitvalue,
+               params->maxexecutions);
        model_print("Analysis plugins:\n");
        for(unsigned int i=0;i<registeredanalysis->size();i++) {
                TraceAnalysis * analysis=(*registeredanalysis)[i];
@@ -123,7 +128,7 @@ bool install_plugin(char * name) {
 
 static void parse_options(struct model_params *params, int argc, char **argv)
 {
-       const char *shortopts = "hyYt:o:m:M:s:S:f:e:b:u:v::";
+       const char *shortopts = "hyYt:o:m:M:s:S:f:e:b:u:x:v::";
        const struct option longopts[] = {
                {"help", no_argument, NULL, 'h'},
                {"liveness", required_argument, NULL, 'm'},
@@ -139,6 +144,7 @@ static void parse_options(struct model_params *params, int argc, char **argv)
                {"uninitialized", optional_argument, NULL, 'u'},
                {"analysis", optional_argument, NULL, 't'},
                {"options", optional_argument, NULL, 'o'},
+               {"maxexecutions", required_argument, NULL, 'x'},
                {0, 0, 0, 0} /* Terminator */
        };
        int opt, longindex;
@@ -148,6 +154,9 @@ static void parse_options(struct model_params *params, int argc, char **argv)
                case 'h':
                        print_usage(argv[0], params);
                        break;
+               case 'x':
+                       params->maxexecutions = atoi(optarg);
+                       break;
                case 's':
                        params->maxfuturedelay = atoi(optarg);
                        break;
index 230607a..e7c48ed 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -255,7 +255,7 @@ void ModelChecker::print_execution(bool printbugs) const
                        get_execution_number());
        print_program_output();
 
-       if (params.verbose >= 2) {
+       if (params.verbose >= 3) {
                model_print("\nEarliest divergence point since last feasible execution:\n");
                if (earliest_diverge)
                        earliest_diverge->print();
@@ -303,7 +303,7 @@ bool ModelChecker::next_execution()
        record_stats();
 
        /* Output */
-       if (params.verbose || (complete && execution->have_bug_reports()))
+       if ( (complete && params.verbose) || params.verbose>1 || (complete && execution->have_bug_reports()))
                print_execution(complete);
        else
                clear_program_output();
@@ -321,6 +321,9 @@ bool ModelChecker::next_execution()
 
        execution_number++;
 
+       if (params.maxexecutions != 0 && stats.num_complete >= params.maxexecutions)
+               return false;
+
        reset_to_initial_state();
        return true;
 }
index ac5dd96..c5b617b 100644 (file)
--- a/params.h
+++ b/params.h
@@ -14,6 +14,7 @@ struct model_params {
        unsigned int enabledcount;
        unsigned int bound;
        unsigned int uninitvalue;
+       unsigned int maxexecutions;
 
        /** @brief Maximum number of future values that can be sent to the same
         *  read */
index 1776387..6fc1e08 100644 (file)
@@ -39,6 +39,9 @@ void SCAnalysis::finish() {
                model_print("Elapsed time in usec %llu\n", stats->elapsedtime);
        model_print("SC count: %u\n", stats->sccount);
        model_print("Non-SC count: %u\n", stats->nonsccount);
+       model_print("Total actions: %llu\n", stats->actions);
+       unsigned long long actionperexec=(stats->actions)/(stats->sccount+stats->nonsccount);
+       model_print("Actions per execution: %llu\n", actionperexec);
 }
 
 bool SCAnalysis::option(char * opt) {
@@ -251,6 +254,8 @@ ModelAction * SCAnalysis::pruneArray(ModelAction **array,int count) {
 
 action_list_t * SCAnalysis::generateSC(action_list_t *list) {
        int numactions=buildVectors(list);
+       stats->actions+=numactions;
+
        computeCV(list);
 
        action_list_t *sclist = new action_list_t();
index 988c8f7..23d127b 100644 (file)
@@ -7,6 +7,7 @@ struct sc_statistics {
        unsigned long long elapsedtime;
        unsigned int sccount;
        unsigned int nonsccount;
+       unsigned long long actions;
 };
 
 class SCAnalysis : public TraceAnalysis {