Skip to content

Commit

Permalink
Add sanity check on partitions
Browse files Browse the repository at this point in the history
Check whether cores are in several partitions.
  • Loading branch information
nicolasbock committed Apr 17, 2017
1 parent de6b9c3 commit e66d6b4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ if(PROGRESS_MPI)
# add_definitions(-DDO_MPI_BLOCK)
endif()

set(SANITY_CHECK FALSE CACHE BOOL "Additional sanity checks")
if(SANITY_CHECK)
message(STATUS "Will add sanity checks")
add_definitions(-DSANITY_CHECK)
endif()

add_subdirectory(src)

find_package(Doxygen)
Expand Down
25 changes: 14 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ EOF
echo "INSTALL_DIR Path to install dir (default is ${INSTALL_DIR})"
echo "EXTRA_FCFLAGS Extra fortran flags (default is ${EXTRA_FCFLAGS})"
echo "EXTRA_LINK_FLAGS Any extra link flag (default is ${EXTRA_LINK_FLAGS})"
echo "SANITY_CHECK Add sanity checks (default is ${SANITY_CHECK})"
}

set_defaults() {
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
CC="${CC:=gcc}"
CXX="${CXX:=g++}"
FC="${FC:=gfortran}"
PROGRESS_OPENMP=${PROGRESS_OPENMP:=yes}
PROGRESS_MPI=${PROGRESS_MPI:=no}
PROGRESS_EXAMPLES=${PROGRESS_EXAMPLES:=no}
PROGRESS_GRAPHLIB=${PROGRESS_GRAPHLIB:=no}
EXTRA_FCFLAGS="${EXTRA_FCFLAGS:=}"
EXTRA_LINK_FLAGS=${EXTRA_LINK_FLAGS:=""}
PROGRESS_TESTING=${PROGRESS_TESTING:=no}
: ${CMAKE_BUILD_TYPE:=Release}
: "${CC:=gcc}"
: "${CXX:=g++}"
: "${FC:=gfortran}"
: ${PROGRESS_OPENMP:=yes}
: ${PROGRESS_MPI:=no}
: ${PROGRESS_TESTING:=no}
: ${PROGRESS_EXAMPLES:=no}
: ${PROGRESS_GRAPHLIB:=no}
: "${EXTRA_FCFLAGS:=}"
: ${EXTRA_LINK_FLAGS:=""}
: ${SANITY_CHECK:=no}
}

die() {
Expand Down Expand Up @@ -111,6 +113,7 @@ configure() {
-DEXTRA_FCFLAGS="${EXTRA_FCFLAGS}" \
-DEXTRA_LINK_FLAGS="${EXTRA_LINK_FLAGS}" \
-DCMAKE_VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE} \
-DSANITY_CHECK=${SANITY_CHECK} \
| tee -a "${LOG_FILE}"
check_pipe_error
cd "${TOP_DIR}"
Expand Down
38 changes: 36 additions & 2 deletions examples/gpmdcov/gpmdcov.F90
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ subroutine gpmd_Part
integer, allocatable :: graph_h(:,:)
integer, allocatable :: graph_p(:,:)
real(dp) :: mls_ii
integer :: iptt

if(mdstep < 1)then
if(lt%verbose >= 1 .and. myRank == 1)call prg_get_mem("gpmdcov", "Before prg_get_covgraph")
Expand Down Expand Up @@ -385,6 +386,24 @@ subroutine gpmd_Part
! write(*,*)"part by mol"
! call prg_molpartition(sy,nparts_cov,nl%nnStructMindist,nl%nnStruct,nl%nrnnstruct,"O ",gpat)

#ifdef SANITY_CHECK
write(*, *) "sanity check before bml_matrix2submatrix_index"
do ipt = 1,gpat%TotalParts
do iptt = ipt+1,gpat%TotalParts
do i = 1, gpat%sgraph(ipt)%llsize
do j = 1, gpat%sgraph(iptt)%llsize
if(gpat%sgraph(ipt)%core_halo_index(i) == gpat%sgraph(iptt)%core_halo_index(j))then
write(*,*)"cores are repeated in partitions",mdstep
write(*,*)ipt,gpat%sgraph(ipt)%core_halo_index(i),iptt,gpat%sgraph(ipt)%core_halo_index(j)
write(*,*)i,j
stop
endif
enddo
enddo
enddo
enddo
#endif

mls_ii = mls()
do i=1,gpat%TotalParts
call bml_matrix2submatrix_index(g_bml,&
Expand All @@ -397,9 +416,25 @@ subroutine gpmd_Part

if(lt%verbose >= 1 .and. myRank == 1)write(*,*)"Time for bml_matrix2submatrix_index "//to_string(mls()-mls_ii)//" ms"


call gpmd_reshuffle()

#ifdef SANITY_CHECK
write(*, *) "sanity check after bml_matrix2submatrix_index"
do ipt = 1,gpat%TotalParts
do iptt = ipt+1,gpat%TotalParts
do i = 1, gpat%sgraph(ipt)%llsize
do j = 1, gpat%sgraph(iptt)%llsize
if(gpat%sgraph(ipt)%core_halo_index(i) == gpat%sgraph(iptt)%core_halo_index(j))then
write(*,*)"cores are repeated in partitions",mdstep
write(*,*)ipt,gpat%sgraph(ipt)%core_halo_index(i),iptt,gpat%sgraph(ipt)%core_halo_index(j)
write(*,*)i,j
stop
endif
enddo
enddo
enddo
enddo
#endif

if(allocated(syprt))deallocate(syprt)
allocate(syprt(gpat%TotalParts))
Expand Down Expand Up @@ -434,7 +469,6 @@ subroutine gpmd_Part

end subroutine gpmd_Part


!> Initialize the partition.
!!
subroutine gpmd_InitParts
Expand Down

0 comments on commit e66d6b4

Please sign in to comment.