gotoHomeFree Source CodeModule fthreadsFact SheetEmail us |
Purple Sage Computing Solutions, Inc. |
|
Home --> Free Source Code --> fthreads --> fthreads Usage --> fthreads Teams fthreads Teams
Introduction to TeamsA team is a programmer chosen group of threads. For example, the threads performing I/O operations may be grouped into a team in order to share a mutex controlling access to the I/O library. A team may have a name, for example, a team for performing I/O may be named "IO_Team". A team is initialized by declaring a variable of type team_t, and passing it, together with an array of integers (representing the not-yet-created thread ids), to team_init(). Any synchronization object initialized with a team variable on the argument list of the respective init routine (barrier_init(), event_init(), mutex_init()) will apply only to threads which are members of that team. Calls to those synchronization objects from other threads will be ignored and have no effect. This provides an additional layer of control in designing error-free threaded applications beyond the Fortran interface system. There are tow predefined teams. One is designated by the team variable all_threads and includes all threads in a process including the primary thread. The other is designated by the team variable all_workers and includes all threads in a process except the primary thread. By default, synchronization objects apply to team all_workers. Activities of the team routines may be traced via the fthreads tracing facility (by the usual means of including a trace variable on the team routine's argument list), and team statistics may be gathered by the team_status() routine. A team has a team id, a unique integer for each team. A predefined team of all threads has a team variable all_threads and has id all_threads_id and a predefined team of all worker threads has a team variable all_workers has team id all_workers_id. These constants are declared in module fthreads. All programmer defined teams have a team id between one and the maximum number of teams declared in fthread_init(). Team Routinesteam_init()The team_init() routine initializes a new team of threads.
interface
subroutine team_init( tm, ths, name, &
trace_v, flag)
type( team_t), intent( out) :: tm
integer, dimension(:), &
intent( in) :: ths
character( len= *), optional, &
intent( in) :: name
type( trace_t), optional, &
intent( inout) :: trace_v
integer, optional, &
intent( out) :: flag
end subroutine team_init
end interface
The type team_t team variable is returned, referring to the team just initialized. The team consists of the threads indicated by the array of integers representing thread ids. The threads will get ids in the order of the calls to thread_create(). The team is named by the optional character variable name. The optional type trace_t trace variable trace_v and the optional integer variable flag provide tracing and feedback. team_del()The team_del() routine deletes a team.
interface
subroutine team_del( tm, trace_v, flag)
type( team_t), intent( out) :: tm
type( trace_t), optional, &
intent( inout) :: trace_v
integer, optional, &
intent( out) :: flag
end subroutine team_del
end interface
The team indicated by the type team_t team variable is deleted. The optional type trace_t trace variable trace_v and the optional integer variable flag provide tracing and feedback. team_id()The team_id() return the team id.
interface
integer function team_id( tm)
type( team_t), intent( in) :: tm
end function team_id
end interface
The integer function team_id() returns the team id of the team indicated by the type team_t team variable. The team id is a positive integer from one through the number of teams. team_member()The team_member() returns true if the thread indicated is a member of the team indicated.
interface
logical function team_member( tm, th)
type( team_t), intent( in) :: tm
type( thread_t), intent( out) :: th
end function team_id
end interface
The logical function team_member() returns true if the thread indicated by the type thread_t thread variable th is a member of the team indicated by the type team_t team variable tm. team_status()The team_status() returns statistics about the team. of the team indicated.
interface
subroutine team_status( tm, name, &
members, b, ev, m, trace_v)
type( team_t), intent( in) :: tm
character( len= *), optional, &
intent( out) :: name
integer, optional, &
intent( out) :: members
integer, optional, &
intent( out) :: b
integer, optional, &
intent( out) :: ev
integer, optional, &
intent( out) :: m
type( trace_t), optional, &
intent( inout) :: trace_v
end subroutine team_status
end interface
The subroutine team_status() returns statistics about the team indicated by the type team_t team varaible tm. The optional character variable name returns the team's name. The optional integer variables b, ev and m count the number of barriers, events and mutexs, respectively, with which this team is associated. The optional type trace_t trace variable trace_v provides for tracing of this routine's activities. Please see our Fact Sheet, or E-mail us for more information. |
|
| Home - Fact Sheet - Free Source Code - Fortran Links - Email us |