[AMBER] [PATCH 4/8] sqm: Fix OpenMP build

From: Reinis Danne <gam4rei.gmail.com>
Date: Tue, 23 Oct 2012 01:14:57 +0300

From: Reinis Danne <rei4dan.gmail.com>

Surprisingly it didn't even build with OpenMP and the issue was raised
on ML at least once. This fixes the build, but still it is of limited
utility since it hardcodes the number of threads and sets it to 1 thread
by default.

It could be easily made to use omp_get_max_threads() to set number of
threads and then users could influence it by setting environment
variable OMP_NUM_THREADS to desired value. But even then one would need
relatively large molecule to make any use of more than one thread (100
atoms is not nearly enough to make good use of even 2 threads). So it
might be better to consider it as input option.

I haven't looked how well MPI version paralellizes, maybe there is
possibility to reuse some of its logic for pure OpenMP build.
---
 AmberTools/src/sqm/qm2_read_nm_and_alloc.F90 | 3 +++
 AmberTools/src/sqm/qm2_scf.F90               | 5 +++--
 AmberTools/src/sqm/qmmm_module.F90           | 3 +++
 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/AmberTools/src/sqm/qm2_read_nm_and_alloc.F90 b/AmberTools/src/sqm/qm2_read_nm_and_alloc.F90
index 6b9de9f..fa743a6 100644
--- a/AmberTools/src/sqm/qm2_read_nm_and_alloc.F90
+++ b/AmberTools/src/sqm/qm2_read_nm_and_alloc.F90
.. -23,6 +23,9 .. subroutine read_qmmm_nm_and_alloc( igb, ih, ix, x, cut, use_pme, ntb )
 
    use findmask
    use constants, only : RETIRED_INPUT_OPTION
+#ifdef OPENMP
+   use qmmm_module, only : qmmm_omp
+#endif
    use qmmm_module, only : qmmm_struct, qm2_struct, qmmm_nml, &
                            validate_qm_atoms, qmsort, &
                            allocate_qmmm, get_atomic_number, qmmm_div, &
diff --git a/AmberTools/src/sqm/qm2_scf.F90 b/AmberTools/src/sqm/qm2_scf.F90
index 1793db5..c6e9248 100644
--- a/AmberTools/src/sqm/qm2_scf.F90
+++ b/AmberTools/src/sqm/qm2_scf.F90
.. -1118,8 +1118,9 .. subroutine qm2_pseudo_diag(matrix,vectors,noccupied,eigen,norbs,smallsum, &
 #ifdef OPENMP
 !$OMP PARALLEL &
 !$OMP DEFAULT(PRIVATE) &
-!$OMP SHARED(lumo, norbs, noccupied, matrix, vectors, scratch_matrix, matrix_workspace, veccount, eigeni, eigen, c,d, smallsum, vectmp1,vectmp2,vectmp3,vecjs)
-!workspace can be shared for OMP since no two threads should do the same value of i.
+!$OMP SHARED(lumo, norbs, noccupied, matrix, vectors, scratch_matrix, matrix_workspace, &
+!$OMP        veccount, eigeni, eigen, c,d, smallsum, vectmp1,vectmp2,vectmp3,vecjs)
+! workspace can be shared for OMP since no two threads should do the same value of i.
 !$OMP DO SCHEDULE(guided)
 #endif
   do i = lumo,norbs
diff --git a/AmberTools/src/sqm/qmmm_module.F90 b/AmberTools/src/sqm/qmmm_module.F90
index 976da6a..dd4ef80 100644
--- a/AmberTools/src/sqm/qmmm_module.F90
+++ b/AmberTools/src/sqm/qmmm_module.F90
.. -46,6 +46,9 .. module qmmm_module
   public :: qmmm_scratch, qmmm_div, qmmm_vsolv, qmmm_opnq
   public :: qm2_struct, qm2_rij_eqns, qm2_params
   public :: qmewald, qm_gb
+#ifdef OPENMP
+  public :: qmmm_omp
+#endif
 
   ! functions and subroutines
   public :: validate_qm_atoms
-- 
1.7.12.4
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Mon Oct 22 2012 - 15:30:07 PDT
Custom Search