21#include "../base/base_uses.f90"
23# include "libxsmm_version.h"
26#if CPVERSION_CHECK(1, 11, <=, LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
27 USE libxsmm,
ONLY: libxsmm_diff
30# define PURE_ARRAY_EQ PURE
35 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dbt_array_list_methods'
54 INTEGER,
DIMENSION(:),
ALLOCATABLE :: col_data
55 INTEGER,
DIMENSION(:),
ALLOCATABLE :: ptr
59 MODULE PROCEDURE allocate_and_get_ith_array
84 INTEGER,
DIMENSION(number_of_arrays(list)),
INTENT(IN) :: indices
89 DO i = 1,
SIZE(indices)
90 ind = indices(i) +
list%ptr(i) - 1
106 INTEGER,
INTENT(IN) :: ndata
107 INTEGER,
DIMENSION(:),
INTENT(IN),
OPTIONAL :: data_1, data_2, data_3, data_4
108 INTEGER :: ptr, size_all
112 IF (ndata .GE. 1)
THEN
113 cpassert(
PRESENT(data_1))
114 size_all = size_all +
SIZE(data_1)
116 IF (ndata .GE. 2)
THEN
117 cpassert(
PRESENT(data_2))
118 size_all = size_all +
SIZE(data_2)
120 IF (ndata .GE. 3)
THEN
121 cpassert(
PRESENT(data_3))
122 size_all = size_all +
SIZE(data_3)
124 IF (ndata .GE. 4)
THEN
125 cpassert(
PRESENT(data_4))
126 size_all = size_all +
SIZE(data_4)
129 ALLOCATE (
list%ptr(ndata + 1))
130 ALLOCATE (
list%col_data(size_all))
135 IF (ndata .GE. 1)
THEN
136 list%col_data(ptr:ptr +
SIZE(data_1) - 1) = data_1(:)
137 ptr = ptr +
SIZE(data_1)
140 IF (ndata .GE. 2)
THEN
141 list%col_data(ptr:ptr +
SIZE(data_2) - 1) = data_2(:)
142 ptr = ptr +
SIZE(data_2)
145 IF (ndata .GE. 3)
THEN
146 list%col_data(ptr:ptr +
SIZE(data_3) - 1) = data_3(:)
147 ptr = ptr +
SIZE(data_3)
150 IF (ndata .GE. 4)
THEN
151 list%col_data(ptr:ptr +
SIZE(data_4) - 1) = data_4(:)
152 ptr = ptr +
SIZE(data_4)
166 INTEGER,
DIMENSION(:),
INTENT(IN) :: i_selected
169 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: data_1, data_2, data_3, data_4
171 ndata =
SIZE(i_selected)
182 CALL get_arrays(
list, data_1, data_2, data_3, i_selected=i_selected)
186 CALL get_arrays(
list, data_1, data_2, data_3, data_4, i_selected=i_selected)
198 DEALLOCATE (
list%ptr,
list%col_data)
207 SUBROUTINE get_arrays(list, data_1, data_2, data_3, data_4, i_selected)
210 INTEGER,
ALLOCATABLE,
DIMENSION(:),
INTENT(OUT), &
211 OPTIONAL :: data_1, data_2, data_3, data_4
212 INTEGER,
DIMENSION(:),
INTENT(IN), &
213 OPTIONAL :: i_selected
215 INTEGER,
DIMENSION(number_of_arrays(list)) :: o
218 IF (
PRESENT(i_selected))
THEN
219 ndata =
SIZE(i_selected)
220 o(1:ndata) = i_selected(:)
223 o(1:ndata) = (/(i, i=1, ndata)/)
226 associate(ptr =>
list%ptr, col_data =>
list%col_data)
228 ALLOCATE (data_1, source=col_data(ptr(o(1)):ptr(o(1) + 1) - 1))
231 ALLOCATE (data_2, source=col_data(ptr(o(2)):ptr(o(2) + 1) - 1))
234 ALLOCATE (data_3, source=col_data(ptr(o(3)):ptr(o(3) + 1) - 1))
237 ALLOCATE (data_4, source=col_data(ptr(o(4)):ptr(o(4) + 1) - 1))
249 INTEGER,
INTENT(IN) :: i
250 INTEGER,
INTENT(IN) :: array_size
251 INTEGER,
DIMENSION(array_size),
INTENT(OUT) :: array
253 associate(ptr =>
list%ptr, col_data =>
list%col_data)
256 array(:) = col_data(ptr(i):ptr(i + 1) - 1)
266 SUBROUTINE allocate_and_get_ith_array(list, i, array)
268 INTEGER,
INTENT(IN) :: i
269 INTEGER,
DIMENSION(:),
ALLOCATABLE,
INTENT(OUT) :: array
271 associate(ptr =>
list%ptr, col_data =>
list%col_data)
274 ALLOCATE (array, source=col_data(ptr(i):ptr(i + 1) - 1))
286 INTEGER :: i_data, num_data
290 DO i_data = 1, num_data
303 INTEGER :: i_data, num_data
307 DO i_data = 1, num_data
321 INTEGER :: i_data, i_ptr, num_data, partial_sum
324 ALLOCATE (list_out%ptr, source=list_in%ptr)
325 ALLOCATE (list_out%col_data(
SIZE(list_in%col_data)))
326 DO i_data = 1, num_data
328 DO i_ptr = list_out%ptr(i_data), list_out%ptr(i_data + 1) - 1
329 list_out%col_data(i_ptr) = partial_sum
330 partial_sum = partial_sum + list_in%col_data(i_ptr)
342 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: data_1, data_2, data_3, data_4
343 INTEGER,
DIMENSION(number_of_arrays(list_in)), &
347 CALL get_arrays(list_in, data_1, data_2, i_selected=dbt_inverse_order(order))
352 CALL get_arrays(list_in, data_1, data_2, data_3, i_selected=dbt_inverse_order(order))
354 data_1, data_2, data_3)
357 CALL get_arrays(list_in, data_1, data_2, data_3, data_4, i_selected=dbt_inverse_order(order))
359 data_1, data_2, data_3, data_4)
372 check_equal = array_eq_i(list1%col_data, list2%col_data) .AND. array_eq_i(list1%ptr, list2%ptr)
379 pure_array_eq
FUNCTION array_eq_i(arr1, arr2)
380 INTEGER,
INTENT(IN),
DIMENSION(:) :: arr1
381 INTEGER,
INTENT(IN),
DIMENSION(:) :: arr2
382 LOGICAL :: array_eq_i
384#if CPVERSION_CHECK(1, 11, <=, LIBXSMM_CONFIG_VERSION_MAJOR, LIBXSMM_CONFIG_VERSION_MINOR)
385 array_eq_i = .NOT. libxsmm_diff(arr1, arr2)
388 IF (
SIZE(arr1) .EQ.
SIZE(arr2)) array_eq_i = all(arr1 == arr2)
Wrapper for allocating, copying and reshaping arrays.
Representation of arbitrary number of 1d integer arrays with arbitrary sizes. This is needed for gene...
integer function, dimension(:), allocatable, public sum_of_arrays(list)
sum of all elements for each array stored in list
subroutine, public get_arrays(list, data_1, data_2, data_3, data_4, i_selected)
Get all arrays contained in list.
subroutine, public create_array_list(list, ndata, data_1, data_2, data_3, data_4)
collects any number of arrays of different sizes into a single array (listcol_data),...
subroutine, public destroy_array_list(list)
destroy array list.
integer function, dimension(:), allocatable, public sizes_of_arrays(list)
sizes of arrays stored in list
pure integer function, public number_of_arrays(list)
number of arrays stored in list
subroutine, public array_offsets(list_in, list_out)
partial sums of array elements.
pure integer function, dimension(number_of_arrays(list)), public get_array_elements(list, indices)
Get an element for each array.
type(array_list) function, public array_sublist(list, i_selected)
extract a subset of arrays
subroutine, public reorder_arrays(list_in, list_out, order)
reorder array list.
logical function, public check_equal(list1, list2)
check whether two array lists are equal
tensor index and mapping to DBM index
pure integer function, dimension(size(order)), public dbt_inverse_order(order)
Invert order.
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...