A call to the ADAMS_SMP_GROUP subroutine informs Adams Solver (C++) that, if the user-written subroutine is executed in parallel, it must be executed in the same thread as other subroutines with the same ADAMS_SMP_GROUP id.
Use
Called By
Any user-written subroutine. However, this utility subroutine only has an effect when both a) the model is being run in parallel (with preferences/nthreads=n, where n>1) and b) the user-written subroutine has also made a call to ADAMS_DECLARE_THREADSAFE such that it can be executed in parallel.
Prerequisite
None
Calling Sequence
CALL ADAMS_SMP_GROUP ( groupId )
Input Arguments
groupId | An integer variable giving the smp group id. All user-written subroutines with the same group id will be executed in the same thread.
Valid group ids are any nonzero positive integer.
A group id of zero explicitly states that this user-written subroutine is not part of a smp group and, if executed in parallel, can be executed by any available thread. This is the default case. |
Output Arguments
None
Extended Definition
If the user-written subroutine making the call is written in FORTRAN and the input parameter IFLAG is declared LOGICAL, then the call to ADAMS_SMP_GROUP must be done when IFLAG is TRUE. If the input parameter IFLAG is declared INTEGER, then the call to ADAMS_SMP_GROUP should be made when IFLAG=1 (initialization). If the user-written subroutine making the call is written in C/C++, the input parameter IFLAG is declared as int (integer) and the call to ADAMS_SMP_GROUP should be done when IFLAG==1 (initialization). Additional calls done when IFLAG is different than zero will cause no errors.
A call to ADAMS_SMP_GROUP is not enough to guarantee the subroutine will be executed in parallel; a call to ADAMS_SMP_GROUP must be accompanied by a call to ADAMS_DECLARE_THREADSAFE. For example, a threadsafe SFOSUB might include the following code snippet:
SUBROUTINE SFOSUB(ID,. . .
. . .
C Mapping dependencies
IF (IFLAG.EQ.1)
THEN
CALL ADAMS_SMP_GROUP(37)
CALL ADAMS_DECLARE_THREADSAFE()
ENDIF
C
. . .
In this example the user makes the call to have all objects using this subroutine join a group labeled as 37.
A large amount of user-written subroutines exist for use with Adams solvers. Many of these user-written subroutines are not threadsafe and thus cannot take advantage of the parallelism in Adams. However, it is often the case that the non-threadsafe character of these user-written subroutines is only in relation to a few specific other user-written subroutines, or a few specific user-written subroutines that are referenced by specific Adams modeling elements. Consequently, by identifying a ‘group’ of user-written subroutines which must be executed in the same thread, some threadsafety issues can be avoided such that these non-threadsafe user-written subroutines can still take advantage of parallel execution.
For example, a complex user-defined bushing might make use of several user-written subroutines which are not threadsafe. However, it is possible that if there are multiple bushings in the model and all user-written subroutines that affect a particular bushing are run in the same thread, that the non-threadsafe issues can be avoided. The ADAMS_SMP_GROUP utility subroutine would permit parallelism in this case if each use of the user-written subroutines gave the bushing id as its group id.
Within each SMP group, the user-written subroutines are evaluated in the order that they would have been evaluated if the model were run serially.
It is not recommended that this be used as a substitute to writing completely threadsafe user subroutines. User-written subroutines which are completely threadsafe will be able to take more effective advantage of parallelism in Adams.
Notes: | Argument IFLAG should be declared of type INTEGER when using FORTRAN. A call to ADAMS_SMP_GROUP must be complemented by a call to ADAMS_DECLARE_THREADSAFE. Calls to ADAMS_SMP_GROUP take effect only if the value of NTHREADS is bigger than one. See the PREFERENCES statement. |