Add option to set number of threads in settings.xml and command line.

This commit is contained in:
Paul Romano 2013-09-01 23:45:38 -04:00
parent 68674912fa
commit f6766c169d
6 changed files with 40 additions and 1 deletions

View file

@ -212,7 +212,7 @@ module global
integer :: MPI_TALLYRESULT ! MPI datatype for TallyResult
#ifdef OPENMP
integer :: n_threads ! number of OpenMP threads
integer :: n_threads = NONE ! number of OpenMP threads
integer :: thread_id ! ID of a given thread
#endif

View file

@ -367,6 +367,23 @@ contains
case ('-g', '-geometry-debug', '--geometry-debug')
check_overlaps = .true.
case ('-t', '--threads')
! Read number of threads
i = i + 1
#ifdef OPENMP
! Read and set number of OpenMP threads
n_threads = str_to_int(argv(i))
if (n_threads < 1) then
message = "Invalid number of threads specified on command line."
call fatal_error()
end if
call omp_set_num_threads(n_threads)
#else
message = "Ignoring number of threads specified on command line."
call warning()
#endif
case ('-?', '-help', '--help')
call print_usage()
stop

View file

@ -73,6 +73,7 @@ contains
cross_sections_ = ''
output_path_ = ''
verbosity_ = 0
threads_ = NONE
energy_grid_ = 'union'
seed_ = 0_8
source_ % file = ''
@ -207,6 +208,23 @@ contains
! Verbosity
if (verbosity_ > 0) verbosity = verbosity_
! Number of OpenMP threads
if (threads_ /= NONE) then
#ifdef OPENMP
if (n_threads == NONE) then
n_threads = threads_
if (n_threads < 1) then
message = "Invalid number of threads: " // to_str(n_threads)
call fatal_error()
end if
call omp_set_num_threads(n_threads)
end if
#else
message = "Ignoring number of threads."
call warning()
#endif
end if
! ==========================================================================
! EXTERNAL SOURCE

View file

@ -170,6 +170,7 @@ contains
write(OUTPUT_UNIT,*) ' -p, --plot Run in plotting mode'
write(OUTPUT_UNIT,*) ' -r, --restart Restart a previous run from a state point'
write(OUTPUT_UNIT,*) ' or a particle restart file'
write(OUTPUT_UNIT,*) ' -t, --threads Number of OpenMP threads'
write(OUTPUT_UNIT,*) ' -v, --version Show version information'
write(OUTPUT_UNIT,*) ' -?, --help Show this message'
end if

View file

@ -97,6 +97,8 @@ element settings {
element survival_biasing { xsd:boolean }? &
element threads { xsd:positiveInteger }? &
element trace { list { xsd:positiveInteger+ } }? &
element verbosity { xsd:positiveInteger }? &

View file

@ -58,6 +58,7 @@
<variable name="source_" tag="source" type="source_xml" />
<variable name="state_point_" tag="state_point" type="statepoint_xml" dimension="1" />
<variable name="survival_" tag="survival_biasing" type="word" length="5" />
<variable name="threads_" tag="threads" type="integer" />
<variable name="trace_" tag="trace" type="integer-array" />
<variable name="uniform_fs_" tag="uniform_fs" type="mesh_xml" dimension="1" />
<variable name="verbosity_" tag="verbosity" type="integer" />