Fixed CRITICAL in hash_mod

dev-openmp
sfilippone 1 year ago
parent def0635c53
commit e31dd52c41

@ -458,7 +458,7 @@ contains
integer(psb_ipk_), intent(out) :: val, info integer(psb_ipk_), intent(out) :: val, info
integer(psb_ipk_) :: hsize,hmask, hk, hd integer(psb_ipk_) :: hsize,hmask, hk, hd
logical :: redo
info = HashOK info = HashOK
hsize = hash%hsize hsize = hash%hsize
hmask = hash%hmask hmask = hash%hmask
@ -483,6 +483,7 @@ contains
info = HashDuplicate info = HashDuplicate
return return
end if end if
redo = .false.
!$OMP CRITICAL !$OMP CRITICAL
if (hash%table(hk,1) == HashFreeEntry) then if (hash%table(hk,1) == HashFreeEntry) then
if (hash%nk == hash%hsize -1) then if (hash%nk == hash%hsize -1) then
@ -497,8 +498,9 @@ contains
info = HashOutOfMemory info = HashOutOfMemory
!return !return
else else
call psb_hash_searchinskey(key,val,nextval,hash,info) redo = .true.
!return !!$ call psb_hash_searchinskey(key,val,nextval,hash,info)
!!$ return
end if end if
else else
hash%nk = hash%nk + 1 hash%nk = hash%nk + 1
@ -509,6 +511,7 @@ contains
end if end if
end if end if
!$OMP END CRITICAL !$OMP END CRITICAL
if (redo) call psb_hash_searchinskey(key,val,nextval,hash,info)
if (info /= HashOk) return if (info /= HashOk) return
if (val > 0) return if (val > 0) return
hk = hk - hd hk = hk - hd

Loading…
Cancel
Save