|
Packit Service |
c5cf8c |
! This file created from f77/pt2pt/greqf.f with f77tof90
|
|
Packit Service |
c5cf8c |
! -*- Mode: Fortran; -*-
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
! See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
subroutine query_fn( extrastate, status, ierr )
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer status(MPI_STATUS_SIZE), ierr
|
|
Packit Service |
c5cf8c |
integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! set a default status
|
|
Packit Service |
c5cf8c |
status(MPI_SOURCE) = MPI_UNDEFINED
|
|
Packit Service |
c5cf8c |
status(MPI_TAG) = MPI_UNDEFINED
|
|
Packit Service |
c5cf8c |
call mpi_status_set_cancelled( status, .false., ierr)
|
|
Packit Service |
c5cf8c |
call mpi_status_set_elements( status, MPI_BYTE, 0, ierr )
|
|
Packit Service |
c5cf8c |
ierr = MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
end
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
subroutine free_fn( extrastate, ierr )
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer value, ierr
|
|
Packit Service |
c5cf8c |
integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
integer freefncall
|
|
Packit Service |
c5cf8c |
common /fnccalls/ freefncall
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! For testing purposes, the following print can be used to check whether
|
|
Packit Service |
c5cf8c |
! the free_fn is called
|
|
Packit Service |
c5cf8c |
! print *, 'Free_fn called'
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
extrastate = extrastate - 1
|
|
Packit Service |
c5cf8c |
! The value returned by the free function is the error code
|
|
Packit Service |
c5cf8c |
! returned by the wait/test function
|
|
Packit Service |
c5cf8c |
ierr = MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
end
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
subroutine cancel_fn( extrastate, complete, ierr )
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer ierr
|
|
Packit Service |
c5cf8c |
logical complete
|
|
Packit Service |
c5cf8c |
integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ierr = MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
end
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! This is a very simple test of generalized requests. Normally, the
|
|
Packit Service |
c5cf8c |
! MPI_Grequest_complete function would be called from another routine,
|
|
Packit Service |
c5cf8c |
! often running in a separate thread. This simple code allows us to
|
|
Packit Service |
c5cf8c |
! check that requests can be created, tested, and waited on in the
|
|
Packit Service |
c5cf8c |
! case where the request is complete before the wait is called.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! Note that MPI did *not* define a routine that can be called within
|
|
Packit Service |
c5cf8c |
! test or wait to advance the state of a generalized request.
|
|
Packit Service |
c5cf8c |
! Most uses of generalized requests will need to use a separate thread.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
program main
|
|
Packit Service |
c5cf8c |
use mpi
|
|
Packit Service |
c5cf8c |
integer errs, ierr
|
|
Packit Service |
c5cf8c |
logical flag
|
|
Packit Service |
c5cf8c |
integer status(MPI_STATUS_SIZE)
|
|
Packit Service |
c5cf8c |
integer request
|
|
Packit Service |
c5cf8c |
external query_fn, free_fn, cancel_fn
|
|
Packit Service |
c5cf8c |
integer (kind=MPI_ADDRESS_KIND) extrastate, valin, valout, val
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
integer freefncall
|
|
Packit Service |
c5cf8c |
common /fnccalls/ freefncall
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
errs = 0
|
|
Packit Service |
c5cf8c |
freefncall = 0
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call MTest_Init( ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
extrastate = 0
|
|
Packit Service |
c5cf8c |
call mpi_grequest_start( query_fn, free_fn, cancel_fn, &
|
|
Packit Service |
c5cf8c |
& extrastate, request, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_test( request, flag, status, ierr )
|
|
Packit Service |
c5cf8c |
if (flag) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Generalized request marked as complete'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mpi_grequest_complete( request, ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call MPI_Wait( request, status, ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
extrastate = 1
|
|
Packit Service |
c5cf8c |
call mpi_grequest_start( query_fn, free_fn, cancel_fn, &
|
|
Packit Service |
c5cf8c |
& extrastate, request, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_grequest_complete( request, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_wait( request, MPI_STATUS_IGNORE, ierr )
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! The following routine may prevent an optimizing compiler from
|
|
Packit Service |
c5cf8c |
! just remembering that extrastate was set in grequest_start
|
|
Packit Service |
c5cf8c |
call dummyupdate(extrastate)
|
|
Packit Service |
c5cf8c |
if (extrastate .ne. 0) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
if (freefncall .eq. 0) then
|
|
Packit Service |
c5cf8c |
print *, 'Free routine not called'
|
|
Packit Service |
c5cf8c |
else
|
|
Packit Service |
c5cf8c |
print *, 'Free routine did not update extra_data'
|
|
Packit Service |
c5cf8c |
print *, 'extrastate = ', extrastate
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
call MTest_Finalize( errs )
|
|
Packit Service |
c5cf8c |
end
|
|
Packit Service |
c5cf8c |
!
|