From f068d73ef1ef33b8bb5ca162573edee5950dc4ef Mon Sep 17 00:00:00 2001 From: sfilippone Date: Sun, 16 Apr 2023 11:30:09 +0200 Subject: [PATCH] First working version --- base/modules/desc/psb_hash_map_mod.F90 | 20 ++++++++++++++------ base/tools/psb_cspins.F90 | 4 ++-- base/tools/psb_dspins.F90 | 4 ++-- base/tools/psb_sspins.F90 | 4 ++-- base/tools/psb_zspins.F90 | 4 ++-- test/omp/psb_tomp.F90 | 4 ++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/base/modules/desc/psb_hash_map_mod.F90 b/base/modules/desc/psb_hash_map_mod.F90 index 0f9af7ef..eac8cc7a 100644 --- a/base/modules/desc/psb_hash_map_mod.F90 +++ b/base/modules/desc/psb_hash_map_mod.F90 @@ -649,7 +649,7 @@ contains integer(psb_ipk_) :: me, np character(len=20) :: name,ch_err logical, allocatable :: mask_(:) - logical :: use_openmp = .false. + logical :: use_openmp = .true. #ifdef OPENMP integer(kind = OMP_lock_kind) :: ins_lck #endif @@ -681,7 +681,7 @@ contains nrow = idxmap%get_lr() if (use_openmp) then -#ifdef OPENMP +#ifdef OPENMP !call OMP_init_lock(ins_lck) if (idxmap%is_bld()) then @@ -697,6 +697,7 @@ contains if (present(lidx)) then if (present(mask)) then + !$omp critical(hash_g2l_ins) ! $ OMP PARALLEL DO default(none) schedule(DYNAMIC) & ! $ OMP shared(name,me,is,idx,ins_lck,mask,mglob,idxmap,ncol,nrow,laddsz,lidx) & @@ -775,11 +776,13 @@ contains end do ! $ OMP END PARALLEL DO + !$omp end critical(hash_g2l_ins) if (.not. isLoopValid) then goto 9999 end if else + !$omp critical(hash_g2l_ins) ! $ OMP PARALLEL DO default(none) schedule(DYNAMIC) & ! $ OMP shared(name,me,is,idx,ins_lck,mglob,idxmap,ncol,nrow,laddsz,lidx) & @@ -851,7 +854,8 @@ contains end do ! $ OMP END PARALLEL DO - + !$omp end critical(hash_g2l_ins) + if (.not. isLoopValid) then goto 9999 end if @@ -861,7 +865,9 @@ contains ! $ OMP PARALLEL DO default(none) schedule(DYNAMIC) & ! $ OMP shared(name,me,is,idx,ins_lck,mask,mglob,idxmap,ncol,nrow,laddsz) & ! $ OMP private(i,ip,lip,tlip,nxt,info) & - ! $ OMP reduction(.AND.:isLoopValid) + ! $ OMP reduction(.AND.:isLoopValid) + !$omp critical(hash_g2l_ins) + do i = 1, is info = 0 if (mask(i)) then @@ -934,7 +940,8 @@ contains end do ! $ OMP END PARALLEL DO - + !$omp end critical(hash_g2l_ins) + if (.not. isLoopValid) then goto 9999 end if @@ -943,6 +950,7 @@ contains ! $ OMP shared(name,me,is,idx,ins_lck,mglob,idxmap,ncol,nrow,laddsz) & ! $ OMP private(i,ip,lip,tlip,nxt,info) & ! $ OMP reduction(.AND.:isLoopValid) + !$omp critical(hash_g2l_ins) do i = 1, is info = 0 ip = idx(i) @@ -1011,6 +1019,7 @@ contains end do ! $ OMP END PARALLEL DO + !$omp end critical(hash_g2l_ins) if (.not. isLoopValid) then goto 9999 @@ -1024,7 +1033,6 @@ contains info = -1 end if !call OMP_destroy_lock(ins_lck) - #endif else if (.not.use_openmp) then #ifdef OPENMP diff --git a/base/tools/psb_cspins.F90 b/base/tools/psb_cspins.F90 index 0a65fb5c..cfa88c55 100644 --- a/base/tools/psb_cspins.F90 +++ b/base/tools/psb_cspins.F90 @@ -145,12 +145,12 @@ subroutine psb_cspins(nz,ia,ja,val,a,desc_a,info,rebuild,local) #endif call desc_a%indxmap%g2l(ia(1:nz),ila(1:nz),info,owned=.true.) #if defined(OPENMP) - !$omp critical(cSPINS) + !$omp critical(cspins) #endif if (info == 0) call desc_a%indxmap%g2l_ins(ja(1:nz),jla(1:nz),info,& & mask=(ila(1:nz)>0)) #if defined(OPENMP) - !$omp end critical(cSPINS) + !$omp end critical(cspins) #endif if (info /= psb_success_) then diff --git a/base/tools/psb_dspins.F90 b/base/tools/psb_dspins.F90 index 6f700bcc..0ba71096 100644 --- a/base/tools/psb_dspins.F90 +++ b/base/tools/psb_dspins.F90 @@ -145,12 +145,12 @@ subroutine psb_dspins(nz,ia,ja,val,a,desc_a,info,rebuild,local) #endif call desc_a%indxmap%g2l(ia(1:nz),ila(1:nz),info,owned=.true.) #if defined(OPENMP) - !$omp critical(dSPINS) + !$omp critical(dspins) #endif if (info == 0) call desc_a%indxmap%g2l_ins(ja(1:nz),jla(1:nz),info,& & mask=(ila(1:nz)>0)) #if defined(OPENMP) - !$omp end critical(dSPINS) + !$omp end critical(dspins) #endif if (info /= psb_success_) then diff --git a/base/tools/psb_sspins.F90 b/base/tools/psb_sspins.F90 index 1e7f9037..71cd293a 100644 --- a/base/tools/psb_sspins.F90 +++ b/base/tools/psb_sspins.F90 @@ -145,12 +145,12 @@ subroutine psb_sspins(nz,ia,ja,val,a,desc_a,info,rebuild,local) #endif call desc_a%indxmap%g2l(ia(1:nz),ila(1:nz),info,owned=.true.) #if defined(OPENMP) - !$omp critical(sSPINS) + !$omp critical(sspins) #endif if (info == 0) call desc_a%indxmap%g2l_ins(ja(1:nz),jla(1:nz),info,& & mask=(ila(1:nz)>0)) #if defined(OPENMP) - !$omp end critical(sSPINS) + !$omp end critical(sspins) #endif if (info /= psb_success_) then diff --git a/base/tools/psb_zspins.F90 b/base/tools/psb_zspins.F90 index 40c0783b..be24a047 100644 --- a/base/tools/psb_zspins.F90 +++ b/base/tools/psb_zspins.F90 @@ -145,12 +145,12 @@ subroutine psb_zspins(nz,ia,ja,val,a,desc_a,info,rebuild,local) #endif call desc_a%indxmap%g2l(ia(1:nz),ila(1:nz),info,owned=.true.) #if defined(OPENMP) - !$omp critical(zSPINS) + !$omp critical(zspins) #endif if (info == 0) call desc_a%indxmap%g2l_ins(ja(1:nz),jla(1:nz),info,& & mask=(ila(1:nz)>0)) #if defined(OPENMP) - !$omp end critical(zSPINS) + !$omp end critical(zspins) #endif if (info /= psb_success_) then diff --git a/test/omp/psb_tomp.F90 b/test/omp/psb_tomp.F90 index 7965a5f4..0a13a41b 100644 --- a/test/omp/psb_tomp.F90 +++ b/test/omp/psb_tomp.F90 @@ -639,7 +639,7 @@ contains write(psb_out_unit,'("-total time : ",es12.5)') ttot end if - !call a%print('a.mtx',head='Test') + call a%print('a.mtx',head='Test') call psb_erractionrestore(err_act) return @@ -731,7 +731,7 @@ program psb_d_pde3d if(psb_errstatus_fatal()) goto 9999 name='pde3d90' call psb_set_errverbosity(itwo) - !call psb_cd_set_large_threshold(2000_psb_ipk_) + call psb_cd_set_large_threshold(2000_psb_ipk_) ! ! Hello world !