goto


Home

Free Source Code

Module fthreads

Fact Sheet

Email us


Purple Sage Computing Solutions, Inc.

fthreads Routines

Home --> Free Source Code --> fthreads --> fthreads Usage --> fthreads Routines

fthreads Routines

These links may be helpful navigating around the fthreads pages.

This page provides a look at using the fthreads routines. This page generally assumes that you've read the page fthread Usage.

Back to the Top

Introduction to fthreads

Other than the trace variables which are declared by the programmer, most fthreads data exists in data structures allocated by fthread_init(). These data structures are deallocated by fthread_end(). fthreads attempts to require that the program not call fthread_init() twice without calling fthread_end() once in between, and vice versa. The program should not call any fthreads routine, excepting the trace routines, and the inquiry routines fthread_cpus(), fthread_is_error() and fthread_msg(), before calling fthread_init() or after calling fthread_end().

Note that once the program calls fthread_end(), statistics gathered by fthread_count(), fthread_status(), thread_status(), team_status(), barrier_status(), event_status(), and mutex_status(), will no longer be available.

Back to the Top

fthreads Routines

fthread_init()

The fthread_init() routine initializes the fthreads system, and allocates space for all fthreads user-accessible variables except trace variables.

interface
   subroutine fthread_init( max_threads, &
   max_teams, max_barriers, max_events, &
   max_mutexs, thread_name, trace_v, flag)
      integer, intent( in) :: max_threads
      integer, optional, &
               intent( in) :: max_teams
      integer, optional, &
               intent( in) :: max_barriers
      integer, optional, &
               intent( in) :: max_events
      integer, optional, &
               intent( in) :: max_mutexs
      character( len= *), optional, &
               intent( in) :: thread_name
      type( trace_t), optional, &
            intent( inout) :: trace_v
      integer, optional, &
               intent( out) :: flag
   end subroutine fthread_init
end interface
			

The fthreads system is initialized, space is allocated for max_threads threads, max_teams teams, max_barriers barriers, max_events events and max_mutexs mutexs. The Primary thread is optionally given the name thread_name. The actions of fthread_init() are optionally recorded via the type trace_t trace variable trace_v and status is optionally returned via the integer flag. Note that fthread_init() can only be run once per process without an intervening call to fthread_end().

Back to the Top

fthread_end()

The fthread_end() routine terminates the fthreads system, and deallocates all the space allocated by fthread_init().

interface
   subroutine fthread_end( th, trace_v, &
                               flag)
      type( thread_t), intent( in) :: th
      type( trace_t), optional, &
            intent( inout) :: trace_v
      integer, optional, &
               intent( out) :: flag
   end subroutine fthread_end
end interface
			

The fthreads system is terminated, and all space allocated by fthread_init() is deallocated. The actions of fthread_end() are optionally recorded via the type trace_t trace variable trace_v and status is optionally returned via the integer flag. Note that use of fthread_end() is optional, it need only be used between two calls to fthread_init(). It may not be called before fthread_init().

Back to the Top

fthread_status()

The fthread_status() returns statistics concerning the fthreads system as a whole.

interface
   subroutine fthread_status( th, maxth, &
         tm, maxtm, b, maxb, ev, maxev, &
         m, maxm, init, trace_v))
      integer, optional, &
               intent( out) :: th
      integer, optional, &
               intent( out) :: maxth
      integer, optional, &
               intent( out) :: tm
      integer, optional, &
               intent( out) :: maxtm
      integer, optional, &
               intent( out) :: b
      integer, optional, &
               intent( out) :: maxb
      integer, optional, &
               intent( out) :: ev
      integer, optional, &
               intent( out) :: maxev
      integer, optional, &
               intent( out) :: m
      integer, optional, &
               intent( out) :: maxm
      logical, optional, &
               intent( out) :: init
      type( trace_t), optional, &
            intent( inout) :: trace_v
   end subroutine fthread_status
end interface
			

The fthreads system is queried for various statistics. The optional integer th returns the current number of threads, the optional integer maxth returns the number of threads fthread's data structures can hold. The optional integer tm returns the current number of teams, the optional integer maxtm returns the number of teams fthread's data structures can hold. The optional integer integer b returns the current number of barriers, the optional integer maxb returns the number fthread's data structures can hold. The integer ev returns the current number of events, the optional integer returns the number of events fthread's data structures can hold. The optional integer m returns the current number of mutexs, the optional integer maxm returns the number of mutexs fthread's data structures can hold. The optional logical returns the state of fthreads, initialized or not. The optional type trace_t trace variable records the status activity. The numbers of objects fthread's data structures can hold is determined by the amounts requested on the call to fthreads, or by default values if the optional argument was missing from fthread_init(). This routine cannot be called before fthread_init() nor after fthread_end().

Back to the Top

fthread_cpus()

The fthread_cpus() returns the number of processors as a whole.

interface
   integer function fthread_cpus() 
   end function fthread_cpus
end interface
			

The Win32 operating system is queried for various the number of hardware processors. This function may be called before fthread_init(), or after fthread_end().

Back to the Top

fthread_count()

The fthread_count() returns the number of threads currently active as a whole.

interface
   integer function fthread_count() 
   end function fthread_count
end interface
			

The fthreads data structures are queried for the number of threads currently active. This function may not be called before fthread_init() nor after fthread_end().

Back to the Top

fthread_is_error()

The fthread_is_error() returns true if the status value is an error code, and false otherwise.

interface
   logical function fthread_is_error( &
                    flag) 
      integer, intent( in) :: flag
   end function fthread_is_error
end interface
			

This function returns true if the integer flag contains an fthread error code, and flase otherwise. This function may be called before fthread_init(), or after fthread_end().

Back to the Top

fthread_msg()

The fthread_msg() returns an error message associated with a status value.

interface
   subroutine fthread_msg( flag, msg)
      integer, intent( in) :: flag
      character( len= *), intent( out)
   end subroutine fthread_msg
end interface
			

This subroutine returns an error message associated with a status value. It may be called at any time.

Back to the Top

Please see our Fact Sheet, or E-mail us for more information.


Home - Fact Sheet - Free Source Code - Fortran Links - Email us

Back to the Top