Obtaining Parallel Processes Information

Several different utility routines are available to provide detailed information about your parallel processes.

This page discusses:

GETNUMCPUS and VGETNUMCPUS (Obtain the Number of Processes)

Utility routine GETNUMCPUS can be called from any Abaqus/Standard user subroutine. GETNUMCPUS returns the number of MPI processes.

Utility routine VGETNUMCPUS can be called from any Abaqus/Explicit user subroutine in a domain-parallel run. VGETNUMCPUS provides the number of processes used for the parallel run.

Utility Routine Interface

         CALL GETNUMCPUS( NUMPROCESSES )
         CALL VGETNUMCPUS( NUMPROCESSES )
         ...

Variables Returned from the Utility Routine

NUMPROCESSES

Number of processes specified for the analysis.

GETRANK and VGETRANK (Obtain the Process Number)

Utility routine GETRANK can be called from any Abaqus/Standard user subroutine. GETRANK returns the rank of the MPI process from which the function is called. For example, in a hybrid MPI and thread parallel execution scheme, multiple threads may all return the rank of their parent MPI process (see Parallel Execution in Abaqus/Standard).

Utility routine VGETRANK can be called from any Abaqus/Explicit user subroutine in a domain-parallel run. VGETRANK provides the individual process rank (see Parallel Execution in Abaqus/Explicit).

Utility Routine Interface

         CALL GETRANK( KPROCESSNUM )
         CALL VGETRANK( KPROCESSNUM )
         ...

Variables Returned from the Utility Routine

KPROCESSNUM

Process number or rank. A process number is either zero or a positive integer.

GETNUMTHREADS (Obtain the Number of Threads)

Utility routine GETNUMTHREADS can be called from any Abaqus user subroutine. It returns the number of threads in a process. In a hybrid parallel execution mode, there will be several Abaqus MPI processes, each having several threads.

Utility Routine Interface

Fortran:
#include <SMAAspUserSubroutines.hdr>

         integer numThreads 
         numThreads = GETNUMTHREADS()

C++:
         #include <SMAAspUserSubroutines.h>

         int numThreads = GETNUMTHREADS();

Get_Thread_Id

You can determine the ID of the thread you are in by calling the utility function get_thread_id. The returned ID is an integer that Abaqus assigns to each of its threads. The main thread will have the ID=0, and each subsequent thread will have an ID of 1, 2, 3, 4, ..., N. This function can be called from any Abaqus user subroutine and from both the Fortran and C/C++ codes.

Utility Routine Interface

FOTRAN:
#include <SMAAspUserSubroutines.hdr>    

         INTEGER myThreadID

         myThreadID = get_thread_id()

C++:
         #include <SMAAspUserSubroutines.h>

         int myThreadID = get_thread_id()

Variables Returned from the Utility Routine

thread_id

Current thread ID, an integer.

GETCOMMUNICATOR (Fortran)

Utility function GETCOMMUNICATOR can be called from any Abaqus user subroutine. GETCOMMUNICATOR returns a communicator that Abaqus defines for its worker processes, similar to MPI_COMM_WORLD. In Fortran its type is an INTEGER. The communicator thus obtained can be used for subsequent MPI communication routines. In a nonparallel run, when the MPI subsystem is not initialized, communicators do not exist and GET_COMMUNICATOR() will return 0. Another way of testing is to call the MPI_Initialized(flag) function. This function will set the flag to 1 if MPI has been initialized.

Utility Routine Interface

#include <SMAAspUserSubroutines.hdr>

         integer ABA_COMM_WORLD

         ABA_COMM_WORLD = GETCOMMUNICATOR()

         if (ABA_COMM_WORLD.ne.0) then
             ...do some parallel work, using MPI ...
         else
             ...do some work in a single process ...
         end if

Variables Returned from the Utility Routine

INTEGER

Communicator handle identifier of type INTEGER. In a non-MPI run, the value returned will be zero.

Get_Communicator (C++)

Utility function get_communicator can be called from any Abaqus user subroutine. get_communicator returns a communicator that Abaqus defines for its worker processes. In C++ this function is called get_communicator() and returns a value of the type MPI_Comm. The communicator thus obtained can be used for subsequent MPI communication routines. In a nonparallel run, when the MPI subsystem is not initialized, communicators do not exist and get_communicator() will return 0. Another way of testing is to call the MPI_Initialized(flag) function. This function will set the flag to 1 if MPI has been initialized.

Utility Routine Interface

         #include <mpi.h>
         #include <SMAAspUserSubroutines.h>

         MPI_Comm ABA_COMM_WORLD = get_communicator()

         if (ABA_COMM_WORLD) {
            // ... do some parallel work, using MPI ... 
         }
         else{
            // ...do some work in a single process ...
         }

Variables Returned from the Utility Routine

MPI_Comm

Communicator handle of type MPI_Comm. In a non-MPI run, the value returned will be zero. The type MPI_Comm is defined in the mpi.h header file.