ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
This module contains procedures and generic interfaces for facilitating parallel computations or computing the performance of the parallel Coarray/MPI/OpenMP algorithms. More...
Data Types | |
type | image_type |
This is the image_type type for generating objects that contain information about the current image/processor/thread and facilitate its synchronization with other processes, or the global finalization of all inter-process parallel communications (e.g., as is done in MPI applications). More... | |
type | imageis_type |
This is the imageis_type type for generating objects with components of type logical of default kind LK that contain information about the current image/processor/thread.More... | |
interface | setForkJoinScaling |
Return the predicted parallel Fork-Join speedup scaling behavior for simulations whose image contributions are stochastically accepted only from the first successful image starting from image ID 1 . More... | |
Functions/Subroutines | |
type(image_type) function | image_typer () |
Generate and return an object of class image_type containing information and statistics of the parallel images/processes/threads available, depending on the type of parallelism requested. More... | |
subroutine | setImageSynced () |
Synchronize all existing parallel images and return nothing. More... | |
subroutine | setImageFinalized () |
Finalize the current parallel simulation and return nothing. More... | |
integer(IK) function | getImageID () |
Generate and return the ID of the current Coarray image / MPI process / OpenMP thread, all starting with 1 .More... | |
integer(IK) function | getImageCount () |
Generate and return the number of available processes in the current parallel world communication. More... | |
integer(IK) integer(IK) function | getImageCountMPI () |
Generate and return the number of available processes in the current MPI-parallel world communication. More... | |
integer(IK) integer(IK) function | getImageCountOMP () |
Generate and return the number of available processes in the current OpenMP-parallel world communication. More... | |
subroutine | setImageCount (count) |
Set the number the parallel threads for an OpenMP-enabled application. More... | |
logical(LK) function | isFailedImage (failed) |
Broadcast the error condition from all images/processes to all images/processes. More... | |
Variables | |
character(*, SK), parameter | MODULE_NAME = SK_"@pm_parallelism" |
character(*, SK), parameter | PARALLELIZATION_MODE = SK_"parallel" |
The scalar constant of type character of default kind SK, whose value is set to parallel if the ParaMonte library is built with the preprocessor macro -DCAF_ENABLED=1 -DMPI_ENABLED=1 , otherwise, it is set to "serial" .More... | |
This module contains procedures and generic interfaces for facilitating parallel computations or computing the performance of the parallel Coarray/MPI/OpenMP algorithms.
A primary goal for the design of this type and the associated procedures is to facilitate parallelism-agnostic coding within a codebase.
As such, the attributes and procedures within this module are guaranteed to also work in serial applications.
However, the procedures of this module typically do nothing when the application is serial or the parallelism is not recognized.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
integer(IK) function pm_parallelism::getImageCount |
Generate and return the number of available processes in the current parallel world communication.
imageCount
: The output scalar integer
of default kind IK representing the number of available processes in the current world communication.imageCount
is set to,num_images()
in Coarray parallel applications, mpi_comm_size()
subroutine in MPI parallel applications, omp_get_num_threads()
in OpenMP parallel applications, 1
in serial applications, omp_get_num_threads()
routine, that is, the number of threads in the team that is executing the parallel region to which the routine region binds.1
.1
, this routine must be called from within an OpenMP-enabled parallel region.omp_set_num_threads()
.
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 599 of file pm_parallelism.F90.
References getImageCountMPI(), and getImageCountOMP().
Referenced by image_typer().
integer(IK) integer(IK) function pm_parallelism::getImageCountMPI |
Generate and return the number of available processes in the current MPI-parallel world communication.
imageCount
: The output scalar integer
of default kind IK representing the number of available processes in the current MPI-parallel world communication.imageCount
is set to,mpi_comm_size()
subroutine in MPI parallel applications, 0
if the ParaMonte library build is not for MPI applications,
Possible calling interfaces ⛓
mpiexec
launcher in dynamic programming languages.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 654 of file pm_parallelism.F90.
Referenced by getImageCount().
integer(IK) integer(IK) function pm_parallelism::getImageCountOMP |
Generate and return the number of available processes in the current OpenMP-parallel world communication.
imageCount
: The output scalar integer
of default kind IK representing the number of available processes in the current OpenMP-parallel world communication.imageCount
is set to,mpi_comm_size()
subroutine in OpenMP parallel applications, 0
if the ParaMonte library build is not for OpenMP applications,
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 712 of file pm_parallelism.F90.
Referenced by getImageCount().
integer(IK) function pm_parallelism::getImageID |
Generate and return the ID of the current Coarray image / MPI process / OpenMP thread, all starting with 1
.
imageID
: The output scalar integer
of default kind IK representing the ID of the current image/process/thread.imageID
is set to, this_image()
in Coarray applications, mpi_comm_rank() + 1
in MPI applications, omp_get_thread_num() + 1
in OpenMP applications, 1
in serial applications,
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 523 of file pm_parallelism.F90.
Referenced by image_typer().
type(image_type) function pm_parallelism::image_typer |
Generate and return an object of class image_type containing information and statistics of the parallel images/processes/threads available, depending on the type of parallelism requested.
This procedure is the constructor of the type image_type.
See the documentation of image_type for further details and example usage.
image
: The output scalar of type image_type.
Possible calling interfaces ⛓
id
assigned to the zeroth process is 1
in this type.omp_get_num_threads()
routine, that is, the number of threads in the team that is executing the parallel region to which the routine region binds.1
.1
, this routine must be called from within an OpenMP-enabled parallel region.omp_set_num_threads()
.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 363 of file pm_parallelism.F90.
References getImageCount(), and getImageID().
logical(LK) function pm_parallelism::isFailedImage | ( | logical(LK), intent(in) | failed | ) |
Broadcast the error condition from all images/processes to all images/processes.
This procedure exists primarily to aid the detection and graceful handling of runtime errors during the testing of ParaMonte library samplers or less frequently, when calling the samplers from dynamic programming languages or interactive environments such as Jupyter which require graceful handling of any errors to avoid environment shutdown.
The use of this procedure is essential to avoid runtime parallel deadlocks.
[in] | failed | : The input scalar logical of default kind LK that should be .true. if and only if a fatal error has occurred.The value of failed is typically the occurred component of an object of type err_type.On input, the specified value for failed is broadcast to all other active processes in the program. |
failedParallelism
: The output scalar of type logical
of default kind LK that is .true.
if and only if the input argument failed
on any image/process in the current parallel simulation is .true.
.
Possible calling interfaces ⛓
impure
.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 828 of file pm_parallelism.F90.
subroutine pm_parallelism::setImageCount | ( | integer(IK), intent(in), optional | count | ) |
Set the number the parallel threads for an OpenMP-enabled application.
This generic interface is exclusively relevant to the OpenMP-enabled ParaMonte library builds and applications.
This interface offers a convenient consistent cross-platform method of setting the number of runtime OpenMP threads for a parallel code section.
It does so by calling the OpenMP intrinsic
[in] | count | : The input scalar of type integer of default kind IK containing the requested number of OpenMP threads.This argument is relevant only if the OpenMP parallelism is enabled at the time of building the ParaMonte library. Unlike Coarray or MPI parallelism paradigms, the number of images (threads) can be (re)set at runtime in OpenMP applications, hence the need for this argument. If the input count is non-positive, this generic interface uses the output of OpenMP intrinsic omp_get_num_procs() as the number of threads.This is unlike the default behavior of Intel and GNU OpenMP libraries which set the number of threads to max(count, 1) .(optional, default = omp_get_num_procs() ) |
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 761 of file pm_parallelism.F90.
subroutine pm_parallelism::setImageFinalized |
Finalize the current parallel simulation and return nothing.
This is a static member of the image_type class.
sync all
for Coarray applications and returns.
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 465 of file pm_parallelism.F90.
subroutine pm_parallelism::setImageSynced |
Synchronize all existing parallel images and return nothing.
This is a static member of the image_type class.
This procedure synchronizes all images in the current communication world by,
sync all
in Coarray applications. mpi_barrier()
in MPI applications.
Possible calling interfaces ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 412 of file pm_parallelism.F90.
character(*, SK), parameter pm_parallelism::MODULE_NAME = SK_"@pm_parallelism" |
Definition at line 42 of file pm_parallelism.F90.
character(*) SK parameter pm_parallelism::PARALLELIZATION_MODE = SK_"parallel" |
The scalar constant of type character
of default kind SK, whose value is set to parallel
if the ParaMonte library is built with the preprocessor macro -DCAF_ENABLED=1
-DMPI_ENABLED=1
, otherwise, it is set to "serial"
.
Definition at line 49 of file pm_parallelism.F90.