Skip to content

Commit

Permalink
Merge branch 'release-2.1.0-rc11'
Browse files Browse the repository at this point in the history
  • Loading branch information
pseewald committed Apr 8, 2020
2 parents ec43e67 + 36e12cb commit 3c72df6
Show file tree
Hide file tree
Showing 38 changed files with 921 additions and 718 deletions.
1 change: 1 addition & 0 deletions .ci/daint.cscs.ch/cray.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cmake \
-DBLAS_FOUND=ON -DBLAS_LIBRARIES="-lsci_cray_mpi_mp" \
-DLAPACK_FOUND=ON -DLAPACK_LIBRARIES="-lsci_cray_mpi_mp" \
-DMPIEXEC_EXECUTABLE="$(command -v srun)" \
-DMPIEXEC_PREFLAGS="-u" \
-DTEST_MPI_RANKS=${SLURM_NTASKS} \
-DTEST_OMP_THREADS=${SLURM_CPUS_PER_TASK} \
"${WORKSPACE}" |& tee -a "${STAGE_NAME}.out"
Expand Down
3 changes: 3 additions & 0 deletions .cp2k/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ CXXFLAGS += -D__CUDA
ifeq (,$(findstring -arch,$(ACCFLAGS)))
override ACCFLAGS += -arch sm_$(ARCH_NUMBER)
endif
ifeq (,$(findstring -Xcompiler,$(ACCFLAGS)))
override ACCFLAGS += -Xcompiler="$(CXXFLAGS)"
endif
# If compiling with hipcc
else ifneq (,$(findstring hipcc,$(ACC)))
override ACCFLAGS += -D__HIP
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit/check_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from contextlib import contextmanager

TYPES = {
"c_cpp": [".c", "h", ".cc", ".hh", ".cxx", ".cpp", ".hpp", ".cu"],
"c_cpp": [".c", ".h", ".cc", ".hh", ".cxx", ".hxx", ".cpp", ".hpp", ".cu"],
"python": [".py"],
"fortran": [".F", ".f", ".f90", ".f03"],
}
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR = 2
MINOR = 1
PATCH = 0-rc10
PATCH = 0-rc11
# A specific DATE (YYYY-MM-DD) fixes an official release, otherwise
# it is considered Development version.
DATE =
4 changes: 2 additions & 2 deletions cmake/CompilerConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -C=all") # some checks are not available with OpenMP
endif ()
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
set(CMAKE_Fortran_FLAGS "-f free -M3105") # -M3105: hide a false-positive warning about modified loop variables due to loop fusing
set(CMAKE_Fortran_FLAGS "-f free -M3105 -ME7212") # -M3105: hide a false-positive warning about modified loop variables due to loop fusing, promote warning 7212 to an error
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-G2 -ME7212") # promote warning 7212 to an error
set(CMAKE_Fortran_FLAGS_DEBUG "-G2")
set(CMAKE_Fortran_MODOUT_FLAG "-ef") # override to get lower-case module file names
else ()
message(WARNING "\
Expand Down
9 changes: 6 additions & 3 deletions src/base/dbcsr_base_uses.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@
! and will be optimized away completely by the compiler
#define MARK_USED(foo) IF(.FALSE.)THEN; DO ; IF(SIZE(SHAPE(foo))==-1) EXIT ; END DO ; ENDIF

! Calculate version number from 3-components. Can be used for comparison e.g.,
! TO_VERSION(4, 9, 0) <= TO_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#define TO_VERSION(MAJOR, MINOR, UPDATE) ((MAJOR) * 10000 + (MINOR) * 100 + (UPDATE))
! Calculate version number from 2 or 3 components. Can be used for comparison e.g.,
! TO_VERSION3(4, 9, 0) <= TO_VERSION3(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
! TO_VERSION(8, 0) <= TO_VERSION(__GNUC__, __GNUC_MINOR__)
#define TO_VERSION2(MAJOR, MINOR) ((MAJOR) * 10000 + (MINOR) * 100)
#define TO_VERSION3(MAJOR, MINOR, UPDATE) (TO_VERSION2(MAJOR, MINOR) + (UPDATE))
#define TO_VERSION TO_VERSION2

! LIBXSMM has a FORTRAN-suitable header with macro/version definitions (since v1.8.2).
! Allows macro-toggles (in addition to parameters).
Expand Down
27 changes: 8 additions & 19 deletions src/block/dbcsr_block_access.f90
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ SUBROUTINE dbcsr_put_block2d_${nametype1}$ (matrix, row, col, block, lb_row_col,
INTEGER, INTENT(IN) :: row, col
!! the row
!! the column
${type1}$, DIMENSION(:, :), INTENT(IN) :: block
${type1}$, DIMENSION(:, :), INTENT(IN), &
CONTIGUOUS, TARGET :: block
!! the block to put
INTEGER, DIMENSION(2), OPTIONAL, INTENT(INOUT) :: lb_row_col
LOGICAL, INTENT(IN), OPTIONAL :: transposed, summation
Expand All @@ -262,28 +263,16 @@ SUBROUTINE dbcsr_put_block2d_${nametype1}$ (matrix, row, col, block, lb_row_col,
${type1}$, INTENT(IN), OPTIONAL :: scale
!! scale the block being added

${type1}$, DIMENSION(:), POINTER :: block_1d

CHARACTER(len=*), PARAMETER :: routineN = 'dbcsr_put_block2d_${nametype1}$', &
routineP = moduleN//':'//routineN

LOGICAL :: tr, do_sum
NULLIFY(block_1d)

IF (PRESENT(transposed)) THEN
tr = transposed
ELSE
tr = .FALSE.
ENDIF
IF (PRESENT(summation)) THEN
do_sum = summation
ELSE
do_sum = .FALSE.
ENDIF
IF (PRESENT(scale)) THEN
CALL dbcsr_put_block(matrix, row, col, &
RESHAPE(block, (/SIZE(block)/)), lb_row_col, tr, do_sum, flop, scale)
ELSE
CALL dbcsr_put_block(matrix, row, col, &
RESHAPE(block, (/SIZE(block)/)), lb_row_col, tr, do_sum, flop)
ENDIF
block_1d(1:SIZE(block)) => block

CALL dbcsr_put_block(matrix, row, col, block_1d, lb_row_col, transposed, summation, flop, scale)
END SUBROUTINE dbcsr_put_block2d_${nametype1}$

SUBROUTINE dbcsr_put_block_${nametype1}$ (matrix, row, col, block, lb_row_col, transposed, &
Expand Down
4 changes: 2 additions & 2 deletions src/block/dbcsr_block_operations.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ MODULE dbcsr_block_operations

!$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_get_thread_num, omp_get_num_threads
IMPLICIT NONE
#if defined(__LIBXSMM) && TO_VERSION(1, 10, 0) < TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR, LIBXSMM_CONFIG_VERSION_UPDATE)
#if defined(__LIBXSMM) && TO_VERSION(1, 10) < TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
# define __LIBXSMM_BLOCKOPS
#endif
#if defined(__LIBXSMM) && TO_VERSION(1, 10, 0) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR, LIBXSMM_CONFIG_VERSION_UPDATE)
#if defined(__LIBXSMM) && TO_VERSION(1, 10) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
# define __LIBXSMM_TRANS
#endif
#if defined(__MKL) || defined(__LIBXSMM_TRANS) || defined(__LIBXSMM_BLOCKOPS) || !defined(NDEBUG)
Expand Down
35 changes: 30 additions & 5 deletions src/core/dbcsr_array_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
MODULE dbcsr_array_types
!! Array objects with reference counting.

#include "base/dbcsr_base_uses.f90"
#if TO_VERSION(1, 11) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
USE libxsmm, ONLY: libxsmm_diff
# define PURE_ARRAY_EQUALITY
#else
# define PURE_ARRAY_EQUALITY PURE
#endif

IMPLICIT NONE
PRIVATE

Expand Down Expand Up @@ -45,12 +53,10 @@ MODULE dbcsr_array_types
INTERFACE array_size
MODULE PROCEDURE array_size_i1d
END INTERFACE

INTERFACE array_equality
MODULE PROCEDURE array_equality_i1
MODULE PROCEDURE array_equality_i1d
END INTERFACE

INTERFACE array_get
MODULE PROCEDURE array_get_i1d
MODULE PROCEDURE array_get_i1
Expand All @@ -60,6 +66,7 @@ MODULE dbcsr_array_types
INTEGER, DIMENSION(:), POINTER :: DATA => Null()
INTEGER :: refcount = 0
END TYPE array_i1d_type

TYPE array_i1d_obj
TYPE(array_i1d_type), POINTER :: low => Null()
END TYPE array_i1d_obj
Expand Down Expand Up @@ -88,6 +95,7 @@ SUBROUTINE array_new_i1d(array, DATA, gift)
array%low%data(:) = DATA(:)
ENDIF
END SUBROUTINE array_new_i1d

SUBROUTINE array_new_i1d_lb(array, DATA, lb)
TYPE(array_i1d_obj), INTENT(OUT) :: array
INTEGER, DIMENSION(:), INTENT(IN) :: DATA
Expand All @@ -101,12 +109,13 @@ SUBROUTINE array_new_i1d_lb(array, DATA, lb)
ALLOCATE (array%low%data(lb:ub))
array%low%data(:) = DATA(:)
END SUBROUTINE array_new_i1d_lb

SUBROUTINE array_hold_i1d(array)
TYPE(array_i1d_obj), INTENT(INOUT) :: array

!$OMP ATOMIC
array%low%refcount = array%low%refcount + 1
END SUBROUTINE array_hold_i1d

SUBROUTINE array_release_i1d(array)
TYPE(array_i1d_obj), INTENT(INOUT) :: array

Expand All @@ -118,18 +127,21 @@ SUBROUTINE array_release_i1d(array)
ENDIF
ENDIF
END SUBROUTINE array_release_i1d

PURE SUBROUTINE array_nullify_i1d(array)
TYPE(array_i1d_obj), INTENT(INOUT) :: array

NULLIFY (array%low)
END SUBROUTINE array_nullify_i1d

PURE FUNCTION array_exists_i1d(array) RESULT(array_exists)
TYPE(array_i1d_obj), INTENT(IN) :: array
LOGICAL :: array_exists

array_exists = ASSOCIATED(array%low)
IF (array_exists) array_exists = array%low%refcount .GT. 0
END FUNCTION array_exists_i1d

FUNCTION array_data_i1d(array) RESULT(DATA)
TYPE(array_i1d_obj), INTENT(IN) :: array
INTEGER, DIMENSION(:), POINTER :: DATA
Expand All @@ -140,6 +152,7 @@ FUNCTION array_data_i1d(array) RESULT(DATA)
NULLIFY (DATA)
ENDIF
END FUNCTION array_data_i1d

PURE FUNCTION array_size_i1d(array) RESULT(the_size)
TYPE(array_i1d_obj), INTENT(IN) :: array
INTEGER :: the_size
Expand All @@ -150,33 +163,45 @@ PURE FUNCTION array_size_i1d(array) RESULT(the_size)
the_size = 0
ENDIF
END FUNCTION array_size_i1d
PURE FUNCTION array_equality_i1(array1, array2) RESULT(are_equal)

PURE_ARRAY_EQUALITY FUNCTION array_equality_i1(array1, array2) RESULT(are_equal)
INTEGER, DIMENSION(:), POINTER :: array1, array2
LOGICAL :: are_equal

are_equal = .FALSE.
IF (ASSOCIATED(array1) .AND. ASSOCIATED(array2)) THEN
#if TO_VERSION(1, 11) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
are_equal = .NOT. libxsmm_diff(array1, array2)
#else
IF (SIZE(array1) .NE. SIZE(array2)) RETURN
are_equal = ALL(array1 .EQ. array2)
#endif
ENDIF
END FUNCTION array_equality_i1
PURE FUNCTION array_equality_i1d(array1, array2) RESULT(are_equal)

PURE_ARRAY_EQUALITY FUNCTION array_equality_i1d(array1, array2) RESULT(are_equal)
TYPE(array_i1d_obj), INTENT(IN) :: array1, array2
LOGICAL :: are_equal

are_equal = .FALSE.
IF (ASSOCIATED(array1%low) .AND. ASSOCIATED(array2%low)) THEN
#if TO_VERSION(1, 11) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
are_equal = .NOT. libxsmm_diff(array1%low%data, array2%low%data)
#else
IF (SIZE(array1%low%data) .NE. SIZE(array2%low%data)) RETURN
are_equal = ALL(array1%low%data .EQ. array2%low%data)
#endif
ENDIF
END FUNCTION array_equality_i1d

PURE FUNCTION array_get_i1d(array, index1) RESULT(value)
TYPE(array_i1d_obj), INTENT(IN) :: array
INTEGER, INTENT(IN) :: index1
INTEGER :: value

value = array%low%data(index1)
END FUNCTION array_get_i1d

PURE FUNCTION array_get_i1(array, index1) RESULT(value)
INTEGER, DIMENSION(:), INTENT(IN), POINTER :: array
INTEGER, INTENT(IN) :: index1
Expand Down
3 changes: 3 additions & 0 deletions src/core/dbcsr_config.F
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ SUBROUTINE dbcsr_print_config(unit_nr)
"DBCSR| Multiplication size k stacks", dbcsr_cfg%nk_stacks
ENDIF

WRITE (UNIT=unit_nr, FMT='(1X,A,T80,L1)') &
"DBCSR| Use memory pool for CPU allocation", dbcsr_cfg%use_mempools_cpu

IF (has_mpi) THEN
IF (dbcsr_cfg%num_layers_3D < 2) THEN
WRITE (UNIT=unit_nr, FMT='(1X,A,T75,A)') &
Expand Down
2 changes: 0 additions & 2 deletions src/data/dbcsr_ptr_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ SUBROUTINE mem_alloc_${nametype1}$ (mem, n, mem_type)
IF (mem_type%acc_hostalloc .AND. n > 1) THEN
CALL acc_hostmem_allocate(mem, n, mem_type%acc_stream)
ELSE IF (mem_type%mpi .AND. dbcsr_data_allocation%use_mpi_allocator) THEN
!$OMP critical(allocate)
CALL mp_allocate(mem, n)
!$OMP end critical(allocate)
ELSE
ALLOCATE (mem(n))
ENDIF
Expand Down
12 changes: 8 additions & 4 deletions src/dist/dbcsr_dist_util.F
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,19 @@ END SUBROUTINE dbcsr_verify_matrix

PURE SUBROUTINE count_bins(nelements, bins, nbins, bin_counts)
INTEGER, INTENT(IN) :: nelements
INTEGER, DIMENSION(1:nelements), INTENT(IN) :: bins
INTEGER, DIMENSION(:), INTENT(IN) :: bins
INTEGER, INTENT(IN) :: nbins
INTEGER, DIMENSION(1:nbins), INTENT(OUT) :: bin_counts

INTEGER :: el
INTEGER :: bin, i, i0, i1

! PURE: DBCSR_ASSERT(nelements .EQ. SIZE(bins))
bin_counts(:) = 0
DO el = 1, nelements
bin_counts(bins(el)) = bin_counts(bins(el)) + 1
i0 = LBOUND(bins, 1)
i1 = i0 + nelements - 1
DO i = i0, i1
bin = bins(i)
bin_counts(bin) = bin_counts(bin) + 1
ENDDO
END SUBROUTINE count_bins

Expand Down
2 changes: 1 addition & 1 deletion src/mm/dbcsr_mm_cannon.F
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ SUBROUTINE multiply_cannon(left_set, right_set, product_matrix, &
CALL dbcsr_print(right_buffer_calc%mats(v_ki_right, 1), nodata=.TRUE.)
ENDIF
!
! form here the code for dbcsr_mm_driver_inner_init was taken
! from here the code for dbcsr_mm_driver_inner_init was taken
!
IF (.FALSE.) WRITE (*, *) routineN//" TICK", metronome
! Since the right matrix is shifted vertically, the
Expand Down
57 changes: 37 additions & 20 deletions src/mm/dbcsr_mm_common.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,56 @@
!--------------------------------------------------------------------------------------------------!

#:include '../data/dbcsr.fypp'
#:for n, nametype1, base1, prec1, kind1, type1, dkind1 in inst_params_float
#:for n, nametype1, base1, prec1, kind1, type1, typesize1, dkind1 in inst_params_float
SUBROUTINE calc_norms_${nametype1}$ (norms, nblks, &
blki, rbs, cbs, DATA)
!! Calculates norms of the entire matrix with minimal overhead.
REAL(kind=sp), DIMENSION(:), INTENT(OUT) :: norms
INTEGER, INTENT(IN) :: nblks
INTEGER, DIMENSION(3, nblks), INTENT(IN) :: blki
INTEGER, DIMENSION(3, nblks), INTENT(IN) :: blki
INTEGER, DIMENSION(:), INTENT(IN) :: rbs, cbs
${type1}$, DIMENSION(:), &
INTENT(IN) :: DATA
INTENT(IN) :: DATA

INTEGER :: blk, bp, bpe, row, col
REAL(kind=sp) :: val
INTEGER, PARAMETER :: nsimd = (4*64)/${typesize1}$
INTEGER :: i, n, blk, bp, bpe, row, col
REAL(kind=sp) :: vals(nsimd)

! ---------------------------------------------------------------------------

!$OMP parallel default(none) &
!$OMP private (row, col, blk, bp, bpe, val) &
!$OMP shared (nblks) &
!$OMP shared (rbs, cbs, blki, &
!$OMP data, norms)
!$OMP do
DO blk = 1, nblks
IF (blki(3, blk) .NE. 0) THEN
row = blki(1, blk)
col = blki(2, blk)
bp = blki(3, blk)
bpe = bp + rbs(row)*cbs(col) - 1
val = SQRT(REAL(SUM(ABS(DATA(bp:bpe))**2), KIND=sp))
ELSE
val = 0.0_sp
!$OMP shared(DATA, norms, nblks, rbs, cbs, blki) &
!$OMP private(vals, i, n, row, col, blk, bp, bpe)
!$OMP do schedule(dynamic)
DO i = 0, nblks - 1, nsimd
n = MIN(nsimd, nblks - i)
DO blk = 1, n
bp = blki(3, blk + i)
IF (bp .NE. 0) THEN
row = blki(1, blk + i)
col = blki(2, blk + i)
bpe = bp + rbs(row)*cbs(col) - 1
#:if nametype1 in ['d', 's']
vals(blk) = REAL(SUM(DATA(bp:bpe)**2), KIND=sp)
#:else
vals(blk) = REAL(SUM(ABS(DATA(bp:bpe))**2), KIND=sp)
#:endif
ELSE
vals(blk) = 0.0_sp
ENDIF
ENDDO
! SIMD: SQRT is intentionally not in above IF-condition
IF (n .EQ. nsimd) THEN
!$OMP simd
DO blk = 1, nsimd
norms(blk + i) = SQRT(vals(blk))
ENDDO
!$OMP end simd
ELSE ! remainder
DO blk = 1, n
norms(blk + i) = SQRT(vals(blk))
ENDDO
ENDIF
norms(blk) = val
ENDDO
!$OMP end do
!$OMP end parallel
Expand Down
2 changes: 1 addition & 1 deletion src/mm/dbcsr_mm_hostdrv.F
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ SUBROUTINE dbcsr_mm_hostdrv_process(this, left, right, params, stack_size, &
#if defined(__LIBXSMM)
CASE (mm_driver_xsmm)
SELECT CASE (this%data_area%d%data_type)
#if TO_VERSION(1, 10, 0) < TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR, LIBXSMM_CONFIG_VERSION_UPDATE)
#if TO_VERSION(1, 10) < TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
CASE (dbcsr_type_real_4)
CALL xsmm_process_mm_batch_s(stack_descr, params, stack_size, &
left%data_area%d%r_sp, right%data_area%d%r_sp, this%data_area%d%r_sp, used_smm)
Expand Down
Loading

0 comments on commit 3c72df6

Please sign in to comment.