$extrastylesheet
Dakota
Version 6.2
|
Derived application interface class that spawns a simulation code using a separate process, receives a process identifier, and communicates with the spawned process through files. More...
Public Member Functions | |
ProcessHandleApplicInterface (const ProblemDescDB &problem_db) | |
constructor | |
~ProcessHandleApplicInterface () | |
destructor | |
Protected Member Functions | |
int | synchronous_local_analysis (int analysis_id) |
void | init_communicators_checks (int max_eval_concurrency) |
void | set_communicators_checks (int max_eval_concurrency) |
void | map_bookkeeping (pid_t pid, int fn_eval_id) |
bookkeeping of process and evaluation ids for asynchronous maps | |
pid_t | create_evaluation_process (bool block_flag) |
virtual pid_t | create_analysis_process (bool block_flag, bool new_group)=0 |
spawn a child process for an analysis component within an evaluation | |
virtual size_t | wait_local_analyses ()=0 |
wait for asynchronous analyses on the local processor, completing at least one job | |
virtual size_t | test_local_analyses_send (int analysis_id)=0 |
test for asynchronous analysis completions on the local processor and return results for any completions by sending messages | |
virtual void | join_evaluation_process_group (bool new_group) |
create (if new_group) and join the process group for asynch evaluations | |
virtual void | join_analysis_process_group (bool new_group) |
create (if new_group) and join the process group for asynch analyses | |
virtual void | evaluation_process_group_id (pid_t pgid) |
set evalProcGroupId | |
virtual pid_t | evaluation_process_group_id () const |
return evalProcGroupId | |
virtual void | analysis_process_group_id (pid_t pgid) |
set analysisProcGroupId | |
virtual pid_t | analysis_process_group_id () const |
return analysisProcGroupId | |
void | process_local_evaluation (PRPQueue &prp_queue, const pid_t pid) |
Common processing code used by {wait,test}_local_evaluations. | |
void | check_wait (pid_t pid, int status) |
check the exit status of a forked process and abort if an error code was returned | |
void | asynchronous_local_analyses (int start, int end, int step) |
execute analyses asynchronously on the local processor | |
void | serve_analyses_asynch () |
serve the analysis scheduler and execute analysis jobs asynchronously | |
void | ifilter_argument_list () |
set argList for execution of the input filter | |
void | ofilter_argument_list () |
set argList for execution of the output filter | |
void | driver_argument_list (int analysis_id) |
set argList for execution of the specified analysis driver | |
void | create_command_arguments (boost::shared_array< const char * > &av, StringArray &driver_and_args) |
parse argList into argument array av suitable for passing to execvp, appending parameters and results filenames if requested by commandLineArgs | |
Protected Attributes | |
std::map< pid_t, int > | evalProcessIdMap |
map of fork process id's to function evaluation id's for asynchronous evaluations | |
std::map< pid_t, int > | analysisProcessIdMap |
map of fork process id's to analysis job id's for asynchronous analyses | |
std::vector< std::string > | argList |
an array of strings for use with execvp(const char *, char * const *). These are converted to an array of const char*'s in fork_program(). |
Derived application interface class that spawns a simulation code using a separate process, receives a process identifier, and communicates with the spawned process through files.
ProcessHandleApplicInterface is subclassed for fork/execvp/waitpid (Unix) and spawnvp (Windows).
ProcessHandleApplicInterface | ( | const ProblemDescDB & | problem_db | ) | [inline] |
constructor
argList sized 3 for [driver name, input file, output file]
int synchronous_local_analysis | ( | int | analysis_id | ) | [inline, protected, virtual] |
This code provides the derived function used by ApplicationInterface:: serve_analyses_synch() as well as a convenience function for ProcessHandleApplicInterface::synchronous_local_analyses() below.
Reimplemented from ApplicationInterface.
References ProcessHandleApplicInterface::create_analysis_process(), and ProcessHandleApplicInterface::driver_argument_list().
void init_communicators_checks | ( | int | max_eval_concurrency | ) | [inline, protected, virtual] |
No derived interface plug-ins, so perform construct-time checks. However, process init issues as warnings since some contexts (e.g., HierarchSurrModel) initialize more configurations than will be used.
Reimplemented from ApplicationInterface.
References ApplicationInterface::check_multiprocessor_analysis(), and ApplicationInterface::check_multiprocessor_asynchronous().
void set_communicators_checks | ( | int | max_eval_concurrency | ) | [inline, protected, virtual] |
Process run-time issues as hard errors.
Reimplemented from ApplicationInterface.
References Dakota::abort_handler(), ApplicationInterface::check_multiprocessor_analysis(), and ApplicationInterface::check_multiprocessor_asynchronous().
pid_t create_evaluation_process | ( | bool | block_flag | ) | [protected, virtual] |
Manage the input filter, 1 or more analysis programs, and the output filter in blocking or nonblocking mode as governed by block_flag. In the case of a single analysis and no filters, a single fork is performed, while in other cases, an initial fork is reforked multiple times. Called from derived_map() with block_flag == BLOCK and from derived_map_asynch() with block_flag == FALL_THROUGH. Uses create_analysis_process() to spawn individual program components within the function evaluation.
Implements ProcessApplicInterface.
References Dakota::abort_handler(), ProcessHandleApplicInterface::analysis_process_group_id(), ApplicationInterface::analysisServerId, ApplicationInterface::asynchLocalAnalysisConcurrency, ApplicationInterface::asynchLocalAnalysisFlag, ProcessHandleApplicInterface::asynchronous_local_analyses(), ParallelLibrary::barrier_e(), ProcessApplicInterface::commandLineArgs, ProcessHandleApplicInterface::create_analysis_process(), ProcessHandleApplicInterface::driver_argument_list(), ApplicationInterface::eaDedMasterFlag, ApplicationInterface::evalCommRank, ApplicationInterface::evalCommSize, ProcessHandleApplicInterface::evalProcessIdMap, ProcessHandleApplicInterface::evaluation_process_group_id(), Dakota::flush(), ProcessHandleApplicInterface::ifilter_argument_list(), ProcessApplicInterface::iFilterName, ProcessHandleApplicInterface::join_evaluation_process_group(), ApplicationInterface::master_dynamic_schedule_analyses(), ProcessApplicInterface::multipleParamsFiles, ApplicationInterface::numAnalysisDrivers, ApplicationInterface::numAnalysisServers, ProcessHandleApplicInterface::ofilter_argument_list(), ProcessApplicInterface::oFilterName, ApplicationInterface::parallelLib, ProcessApplicInterface::paramsFileName, ProcessApplicInterface::programNames, ProcessApplicInterface::resultsFileName, ProcessHandleApplicInterface::serve_analyses_asynch(), ApplicationInterface::serve_analyses_synch(), ApplicationInterface::suppressOutput, and ProcessApplicInterface::synchronous_local_analyses().
void check_wait | ( | pid_t | pid, |
int | status | ||
) | [protected] |
check the exit status of a forked process and abort if an error code was returned
Check to see if the process terminated abnormally (WIFEXITED(status)==0) or if either execvp or the application returned a status code of -1 (WIFEXITED(status)!=0 && (signed char)WEXITSTATUS(status)==-1). If one of these conditions is detected, output a failure message and abort. Note: the application code should not return a status code of -1 unless an immediate abort of dakota is wanted. If for instance, failure capturing is to be used, the application code should write the word "FAIL" to the appropriate results file and return a status code of 0 through exit().
References Dakota::abort_handler().
Referenced by ForkApplicInterface::create_analysis_process(), SpawnApplicInterface::test_local_analyses_send(), SpawnApplicInterface::test_local_evaluations(), ForkApplicInterface::wait(), SpawnApplicInterface::wait_local_analyses(), and SpawnApplicInterface::wait_local_evaluations().
void asynchronous_local_analyses | ( | int | start, |
int | end, | ||
int | step | ||
) | [protected] |
execute analyses asynchronously on the local processor
Schedule analyses asynchronously on the local processor using a dynamic scheduling approach (start to end in step increments). Concurrency is limited by asynchLocalAnalysisConcurrency. Modeled after ApplicationInterface::asynchronous_local_evaluations(). NOTE: This function should be elevated to ApplicationInterface if and when another derived interface class supports asynchronous local analyses.
References Dakota::abort_handler(), ProcessHandleApplicInterface::analysisProcessIdMap, ApplicationInterface::asynchLocalAnalysisConcurrency, ProcessHandleApplicInterface::create_analysis_process(), ProcessHandleApplicInterface::driver_argument_list(), ApplicationInterface::numAnalysisDrivers, and ProcessHandleApplicInterface::wait_local_analyses().
Referenced by ProcessHandleApplicInterface::create_evaluation_process().
void serve_analyses_asynch | ( | ) | [protected] |
serve the analysis scheduler and execute analysis jobs asynchronously
This code runs multiple asynch analyses on each server. It is modeled after ApplicationInterface::serve_evaluations_asynch(). NOTE: This fn should be elevated to ApplicationInterface if and when another derived interface class supports hybrid analysis parallelism.
References Dakota::abort_handler(), ProcessHandleApplicInterface::analysisProcessIdMap, ApplicationInterface::asynchLocalAnalysisConcurrency, ProcessHandleApplicInterface::create_analysis_process(), ProcessHandleApplicInterface::driver_argument_list(), ParallelLibrary::irecv_ea(), ApplicationInterface::numAnalysisDrivers, ApplicationInterface::parallelLib, ParallelLibrary::recv_ea(), ParallelLibrary::test(), and ProcessHandleApplicInterface::test_local_analyses_send().
Referenced by ProcessHandleApplicInterface::create_evaluation_process().
void create_command_arguments | ( | boost::shared_array< const char * > & | av, |
StringArray & | driver_and_args | ||
) | [protected] |
parse argList into argument array av suitable for passing to execvp, appending parameters and results filenames if requested by commandLineArgs
This function will split the analysis command in argList[0] based on whitespace, but preserve spaces within quoted strings, such that quoted strings can be passed as single command arguments. NOTE: This function allocates memory in av that might be implicitly freed when the child exits (control never returns to caller). driver_and_args needs to be a return argument because av will contain pointers into its c_str()'s when done.
References ProcessHandleApplicInterface::argList, ProcessApplicInterface::commandLineArgs, and WorkdirHelper::tokenize_driver().
Referenced by SpawnApplicInterface::create_analysis_process(), and ForkApplicInterface::create_analysis_process().