1 /********************* */
2 /*! \file portfolio_util.cpp
4 ** Original author: kshitij
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version):
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
14 ** \brief Code relevant only for portfolio builds
20 #include "options/options.h"
21 #include "main/options.h"
22 #include "prop/options.h"
23 #include "smt/options.h"
29 vector
<Options
> parseThreadSpecificOptions(Options opts
)
31 vector
<Options
> threadOptions
;
33 unsigned numThreads
= opts
[options::threads
];
36 * Use satRandomSeed for generating random numbers, in particular
39 srand((unsigned int)(-opts
[options::satRandomSeed
]));
41 for(unsigned i
= 0; i
< numThreads
; ++i
) {
42 threadOptions
.push_back(opts
);
43 Options
& tOpts
= threadOptions
.back();
45 // Set thread identifier
46 tOpts
.set(options::thread_id
, i
);
48 // If the random-seed is negative, pick a random seed randomly
49 if(opts
[options::satRandomSeed
] < 0) {
50 tOpts
.set(options::satRandomSeed
, (double)rand());
53 if(i
< opts
[options::threadArgv
].size() &&
54 !opts
[options::threadArgv
][i
].empty()) {
56 // separate out the thread's individual configuration string
58 optidss
<< "--thread" << i
;
59 string optid
= optidss
.str();
61 char* tbuf
= strdup(opts
[options::threadArgv
][i
].c_str());
63 // string length is certainly an upper bound on size needed
64 char** targv
= new char*[opts
[options::threadArgv
][i
].size()];
66 *vp
++ = strdup(optid
.c_str());
71 p
= strtok(NULL
, " ");
74 if(targc
> 1) { // this is necessary in case you do e.g. --thread0=" "
76 tOpts
.parseOptions(targc
, targv
);
77 } catch(OptionException
& e
) {
79 ss
<< optid
<< ": " << e
.getMessage();
80 throw OptionException(ss
.str());
84 ss
<< "unused argument `" << targv
[optind
]
85 << "' in thread configuration " << optid
<< " !";
86 throw OptionException(ss
.str());
88 if(tOpts
[options::threads
] != numThreads
89 || tOpts
[options::threadArgv
] != opts
[options::threadArgv
]) {
91 ss
<< "not allowed to set thread options in " << optid
<< " !";
92 throw OptionException(ss
.str());
101 assert(numThreads
>= 1); //do we need this?
103 return threadOptions
;