Utilizing Sherpa's Parallelized Functions
Sherpa Threads (CIAO 4.15 Sherpa)
Several computationally intensive functions in Sherpa are parallelized to make use of multi-core systems (i.e., laptops or desktops with two or more cores), providing users with significant improvements in efficiency. This thread describes the options available for specifying the number of cores to use when these commands are executed.
Last Update: 29 Nov 2022 - reviewed for CIAO 4.15, revised sherpa.rc formatting.
- Parallelized Sherpa Commands
- Specifying the Number of Cores
Parallelized Sherpa Commands
Each of the parallelized commands in Sherpa, listed below, contains a numcores argument for specifying the number of cores which should be utilized when these commands are run; the default is to use all available cores. Note that the number of cores is set for the conf and proj commands via set_conf_opt and set_proj_opt.
conf projection get_conf get_proj int_proj int_unc get_int_proj get_int_unc reg_proj reg_unc get_reg_proj get_reg_unc plot_photon_flux plot_energy_flux get_photon_flux_hist get_energy_flux_hist gridsearch normal_sample t_sample uniform_sample plot_pvalue get_pvalue_plot sample_flux
Specifying the Number of Cores
The number of cores to use when running a parallelized command may be set in one of two ways: when the command is run in the Sherpa session, or in the ~/sherpa.rc customization file.
When a given parallelized command is run on the Sherpa command-line, its numcores argument is set as shown in the following example:
sherpa> plot_energy_flux(id="src", numcores=2)
The plot_energy_flux command in this example will utilize two cores of the user's system in creating a plot of the energy flux distribution of the data set "src".
Another example is shown below, where the numcores option of the set_conf_opt command is used to specify that four cores should be used when the computationally intensive confidence command is run, after a fit to estimate the errors on the fit parameters:
sherpa> fit() sherpa> set_conf_opt('numcores', 4) sherpa> conf()
Sherpa Customization File
The user can also specify a default number of cores to use whenever a parallelized command is run in Sherpa, to avoid having to set the numcores argument each time the command is run. This is done by setting the number of cores to the desired value in the parallel section of the Sherpa customization file, sherpa.rc, located in the user's home directory.
unix% more ~/.sherpa.rc [options] # Plotting packages available- pylab, chips plot_pkg : pylab # IO packages available- pyfits, crates io_pkg : crates # For shell script "sherpa", NOT a Python config option # Which language will shell script choose? By default # load modules into IPython, but set to "slang" to # start slsh and import Sherpa S-Lang wrapper. shell : python . . . [parallel] # Integral number of cores to use for all parallel operations # 'None' indicates that all available cores will be used. # Fewer than 2 will turn off parallel processing. numcores: 4
The default numcores value in the customization file is None to indicate that all available cores will be used for parallelized functions. This setting may be overridden on the Sherpa command-line by using a parallelized function's numcores argument, as demonstrated in the previous section.
|30 Mar 2012||original version|
|04 Dec 2013||reviewed for CIAO 4.6: no changes|
|04 Dec 2014||reviewed and edited for CIAO 4.7: no content change|
|01 Dec 2015||reviewed for CIAO 4.8: no content change|
|15 Nov 2016||reviewed for CIAO 4.9: no content change|
|11 Apr 2018||reviewed for CIAO 4.10: no content change|
|13 Dec 2018||reviewed for CIAO 4.11: revised list of tools using 'numcores'|
|29 Nov 2022||reviewed for CIAO 4.15, revised sherpa.rc formatting.|