Skip to content

Commit

Permalink
Implement array_eq_i using libxsmm_diff
Browse files Browse the repository at this point in the history
- Removed duplicated array_eq_i.
  • Loading branch information
hfp committed Oct 8, 2024
1 parent ef9e905 commit 2a252fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
14 changes: 12 additions & 2 deletions src/tensors/dbcsr_array_list_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ MODULE dbcsr_array_list_methods
USE dbcsr_allocate_wrap, ONLY: allocate_any

#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_EQ
#else
# define PURE_ARRAY_EQ PURE
#endif

IMPLICIT NONE
PRIVATE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'dbcsr_array_list_methods'
Expand Down Expand Up @@ -275,15 +282,18 @@ FUNCTION check_equal(list1, list2)
check_equal = array_eq_i(list1%col_data, list2%col_data) .AND. array_eq_i(list1%ptr, list2%ptr)
END FUNCTION

PURE FUNCTION array_eq_i(arr1, arr2)
PURE_ARRAY_EQ FUNCTION array_eq_i(arr1, arr2)
!! check whether two arrays are equal
INTEGER, INTENT(IN), DIMENSION(:) :: arr1
INTEGER, INTENT(IN), DIMENSION(:) :: arr2
LOGICAL :: array_eq_i

#if TO_VERSION(1, 11) <= TO_VERSION(LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
array_eq_i = .NOT. libxsmm_diff(arr1, arr2)
#else
array_eq_i = .FALSE.
IF (SIZE(arr1) .EQ. SIZE(arr2)) array_eq_i = ALL(arr1 == arr2)

#endif
END FUNCTION

END MODULE dbcsr_array_list_methods
12 changes: 0 additions & 12 deletions src/tensors/dbcsr_tensor_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -698,18 +698,6 @@ SUBROUTINE dbcsr_t_distribution_new_expert(dist, pgrid, map1_2d, map2_2d, ${varl
ALLOCATE (dist%refcount)
dist%refcount = 1
CALL timestop(handle)

CONTAINS
PURE FUNCTION array_eq_i(arr1, arr2)
INTEGER, INTENT(IN), DIMENSION(:) :: arr1
INTEGER, INTENT(IN), DIMENSION(:) :: arr2
LOGICAL :: array_eq_i

array_eq_i = .FALSE.
IF (SIZE(arr1) .EQ. SIZE(arr2)) array_eq_i = ALL(arr1 == arr2)

END FUNCTION

END SUBROUTINE

SUBROUTINE dbcsr_t_distribution_destroy(dist)
Expand Down

0 comments on commit 2a252fd

Please sign in to comment.