From 1270aed5d1ac393c9e6f2fa2533404629baab9de Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 3 May 2024 11:53:05 -0400 Subject: [PATCH] avoid "done" message when there is no request --- CHANGELOG.md | 2 ++ pfio/BaseThread.F90 | 12 ++++++++++++ pfio/ClientThread.F90 | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb095ae09e1a..02a92546ba6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- pFIO Clients don't send "Done" message when there is no request + ### Fixed ### Removed diff --git a/pfio/BaseThread.F90 b/pfio/BaseThread.F90 index d5eb16e9c987..32dc7dc18c8b 100644 --- a/pfio/BaseThread.F90 +++ b/pfio/BaseThread.F90 @@ -29,6 +29,7 @@ module pFIO_BaseThreadMod procedure :: clear_RequestHandle procedure :: get_RequestHandle procedure :: insert_RequestHandle + procedure :: isEmpty_RequestHandle end type BaseThread contains @@ -66,6 +67,17 @@ function get_RequestHandle(this,request_id, rc) result(rh_ptr) _RETURN(_SUCCESS) end function get_RequestHandle + function isEmpty_RequestHandle(this, rc) result(empty) + class (BaseThread), target, intent(in) :: this + integer, optional, intent(out) :: rc + logical :: empty + type (IntegerRequestMapIterator) :: iter + + iter = this%open_requests%begin() + empty = (iter == this%open_requests%end()) + _RETURN(_SUCCESS) + end function isEmpty_RequestHandle + subroutine insert_RequestHandle(this,request_id, handle, rc) class (BaseThread), target, intent(inout) :: this integer, intent(in) :: request_id diff --git a/pfio/ClientThread.F90 b/pfio/ClientThread.F90 index 40b778c633d7..146c0f9b4745 100644 --- a/pfio/ClientThread.F90 +++ b/pfio/ClientThread.F90 @@ -410,6 +410,10 @@ subroutine done_prefetch(this, rc) class(AbstractSocket),pointer :: connection integer :: status + if (this%isEmpty_RequestHandle()) then + _RETURN(_SUCCESS) + endif + connection=>this%get_connection() call connection%send(PrefetchDoneMessage(),_RC) _RETURN(_SUCCESS) @@ -420,6 +424,10 @@ subroutine done_collective_prefetch(this, rc) integer, optional, intent(out) :: rc class(AbstractSocket),pointer :: connection integer :: status + + if (this%isEmpty_RequestHandle()) then + _RETURN(_SUCCESS) + endif connection=>this%get_connection() call connection%send(CollectivePrefetchDoneMessage(),_RC) @@ -432,6 +440,10 @@ subroutine done_stage(this, rc) class(AbstractSocket),pointer :: connection integer :: status + if (this%isEmpty_RequestHandle()) then + _RETURN(_SUCCESS) + endif + connection=>this%get_connection() call connection%send(StageDoneMessage(),_RC) _RETURN(_SUCCESS) @@ -443,6 +455,10 @@ subroutine done_collective_stage(this, rc) class(AbstractSocket),pointer :: connection integer :: status + if (this%isEmpty_RequestHandle()) then + _RETURN(_SUCCESS) + endif + connection=>this%get_connection() call connection%send(CollectiveStageDoneMessage(),_RC) _RETURN(_SUCCESS)