(git:374b731)
Loading...
Searching...
No Matches
dbt_tas_test.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief testing infrastructure for tall-and-skinny matrices
10!> \author Patrick Seewald
11! **************************************************************************************************
13 USE dbm_api, ONLY: &
19 USE dbt_tas_base, ONLY: &
31 USE kinds, ONLY: dp,&
32 int_8
33 USE message_passing, ONLY: mp_cart_type,&
35#include "../../base/base_uses.f90"
36
37 IMPLICIT NONE
38 PRIVATE
39
40 PUBLIC :: &
47
48 INTEGER, SAVE :: randmat_counter = 0
49 INTEGER, PARAMETER, PRIVATE :: rand_seed_init = 12341313
50
51CONTAINS
52
53! **************************************************************************************************
54!> \brief Setup tall-and-skinny matrix for testing
55!> \param matrix ...
56!> \param mp_comm_out ...
57!> \param mp_comm ...
58!> \param nrows ...
59!> \param ncols ...
60!> \param rbsizes ...
61!> \param cbsizes ...
62!> \param dist_splitsize ...
63!> \param name ...
64!> \param sparsity ...
65!> \param reuse_comm ...
66!> \author Patrick Seewald
67! **************************************************************************************************
68 SUBROUTINE dbt_tas_setup_test_matrix(matrix, mp_comm_out, mp_comm, nrows, ncols, rbsizes, &
69 cbsizes, dist_splitsize, name, sparsity, reuse_comm)
70 TYPE(dbt_tas_type), INTENT(OUT) :: matrix
71 TYPE(mp_cart_type), INTENT(OUT) :: mp_comm_out
72
73 CLASS(mp_comm_type), INTENT(IN) :: mp_comm
74 INTEGER(KIND=int_8), INTENT(IN) :: nrows, ncols
75 INTEGER, DIMENSION(nrows), INTENT(IN) :: rbsizes
76 INTEGER, DIMENSION(ncols), INTENT(IN) :: cbsizes
77 INTEGER, DIMENSION(2), INTENT(IN) :: dist_splitsize
78 CHARACTER(len=*), INTENT(IN) :: name
79 REAL(kind=dp), INTENT(IN) :: sparsity
80 LOGICAL, INTENT(IN), OPTIONAL :: reuse_comm
81
82 CHARACTER(LEN=*), PARAMETER :: routinen = 'dbt_tas_setup_test_matrix'
83
84 INTEGER :: col_size, handle, max_col_size, max_nze, &
85 max_row_size, mynode, node_holds_blk, &
86 nze, row_size
87 INTEGER(KIND=int_8) :: col, col_s, ncol, nrow, row, row_s
88 INTEGER, DIMENSION(2) :: pdims
89 INTEGER, DIMENSION(4) :: iseed, jseed
90 LOGICAL :: reuse_comm_prv, tr
91 REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: values
92 REAL(kind=dp), DIMENSION(1) :: rn
93 TYPE(dbt_tas_blk_size_arb) :: cbsize_obj, rbsize_obj
94 TYPE(dbt_tas_dist_cyclic) :: col_dist_obj, row_dist_obj
95 TYPE(dbt_tas_distribution_type) :: dist
96
97 ! we don't reserve blocks prior to putting them, so this time is meaningless and should not
98 ! be considered in benchmark!
99 CALL timeset(routinen, handle)
100
101 ! Check that the counter was initialised (or has not overflowed)
102 cpassert(randmat_counter .NE. 0)
103 ! the counter goes into the seed. Every new call gives a new random matrix
104 randmat_counter = randmat_counter + 1
105
106 IF (PRESENT(reuse_comm)) THEN
107 reuse_comm_prv = reuse_comm
108 ELSE
109 reuse_comm_prv = .false.
110 END IF
111
112 IF (reuse_comm_prv) THEN
113 mp_comm_out = mp_comm
114 ELSE
115 mp_comm_out = dbt_tas_mp_comm(mp_comm, nrows, ncols)
116 END IF
117
118 mynode = mp_comm_out%mepos
119 pdims = mp_comm_out%num_pe_cart
120
121 row_dist_obj = dbt_tas_dist_cyclic(dist_splitsize(1), pdims(1), nrows)
122 col_dist_obj = dbt_tas_dist_cyclic(dist_splitsize(2), pdims(2), ncols)
123
124 rbsize_obj = dbt_tas_blk_size_arb(rbsizes)
125 cbsize_obj = dbt_tas_blk_size_arb(cbsizes)
126
127 CALL dbt_tas_distribution_new(dist, mp_comm_out, row_dist_obj, col_dist_obj)
128 CALL dbt_tas_create(matrix, name=trim(name), dist=dist, &
129 row_blk_size=rbsize_obj, col_blk_size=cbsize_obj, own_dist=.true.)
130
131 max_row_size = maxval(rbsizes)
132 max_col_size = maxval(cbsizes)
133 max_nze = max_row_size*max_col_size
134
135 nrow = dbt_tas_nblkrows_total(matrix)
136 ncol = dbt_tas_nblkcols_total(matrix)
137
138 ALLOCATE (values(max_row_size, max_col_size))
139
140 jseed = generate_larnv_seed(7, 42, 3, 42, randmat_counter)
141
142 DO row = 1, dbt_tas_nblkrows_total(matrix)
143 DO col = 1, dbt_tas_nblkcols_total(matrix)
144 CALL dlarnv(1, jseed, 1, rn)
145 IF (rn(1) .LT. sparsity) THEN
146 tr = .false.
147 row_s = row; col_s = col
148 CALL dbt_tas_get_stored_coordinates(matrix, row_s, col_s, node_holds_blk)
149
150 IF (node_holds_blk .EQ. mynode) THEN
151 row_size = rbsize_obj%data(row_s)
152 col_size = cbsize_obj%data(col_s)
153 nze = row_size*col_size
154 iseed = generate_larnv_seed(int(row_s), int(nrow), int(col_s), int(ncol), randmat_counter)
155 CALL dlarnv(1, iseed, max_nze, values)
156 CALL dbt_tas_put_block(matrix, row_s, col_s, values(1:row_size, 1:col_size))
157 END IF
158 END IF
159 END DO
160 END DO
161
162 CALL dbt_tas_finalize(matrix)
163
164 CALL timestop(handle)
165
166 END SUBROUTINE
167
168! **************************************************************************************************
169!> \brief Benchmark routine. Due to random sparsity (as opposed to structured sparsity pattern),
170!> this may not be representative for actual applications.
171!> \param transa ...
172!> \param transb ...
173!> \param transc ...
174!> \param matrix_a ...
175!> \param matrix_b ...
176!> \param matrix_c ...
177!> \param compare_dbm ...
178!> \param filter_eps ...
179!> \param io_unit ...
180!> \author Patrick Seewald
181! **************************************************************************************************
182 SUBROUTINE dbt_tas_benchmark_mm(transa, transb, transc, matrix_a, matrix_b, matrix_c, compare_dbm, filter_eps, io_unit)
183
184 LOGICAL, INTENT(IN) :: transa, transb, transc
185 TYPE(dbt_tas_type), INTENT(INOUT) :: matrix_a, matrix_b, matrix_c
186 LOGICAL, INTENT(IN) :: compare_dbm
187 REAL(kind=dp), INTENT(IN), OPTIONAL :: filter_eps
188 INTEGER, INTENT(IN), OPTIONAL :: io_unit
189
190 INTEGER :: handle1, handle2
191 INTEGER, CONTIGUOUS, DIMENSION(:), POINTER :: cd_a, cd_b, cd_c, col_block_sizes_a, &
192 col_block_sizes_b, col_block_sizes_c, rd_a, rd_b, rd_c, row_block_sizes_a, &
193 row_block_sizes_b, row_block_sizes_c
194 INTEGER, DIMENSION(2) :: npdims
195 TYPE(dbm_distribution_obj) :: dist_a, dist_b, dist_c
196 TYPE(dbm_type) :: dbm_a, dbm_a_mm, dbm_b, dbm_b_mm, dbm_c, &
197 dbm_c_mm
198 TYPE(mp_cart_type) :: comm_dbm, mp_comm
199
200!
201! TODO: Dedup with code in dbt_tas_test_mm.
202!
203 IF (PRESENT(io_unit)) THEN
204 IF (io_unit > 0) THEN
205 WRITE (io_unit, "(A)") "starting tall-and-skinny benchmark"
206 END IF
207 END IF
208 CALL timeset("benchmark_tas_mm", handle1)
209 CALL dbt_tas_multiply(transa, transb, transc, 1.0_dp, matrix_a, matrix_b, &
210 0.0_dp, matrix_c, &
211 filter_eps=filter_eps, unit_nr=io_unit)
212 CALL timestop(handle1)
213 IF (PRESENT(io_unit)) THEN
214 IF (io_unit > 0) THEN
215 WRITE (io_unit, "(A)") "tall-and-skinny benchmark completed"
216 END IF
217 END IF
218
219 IF (compare_dbm) THEN
220 CALL dbt_tas_convert_to_dbm(matrix_a, dbm_a)
221 CALL dbt_tas_convert_to_dbm(matrix_b, dbm_b)
222 CALL dbt_tas_convert_to_dbm(matrix_c, dbm_c)
223
224 CALL dbt_tas_get_split_info(dbt_tas_info(matrix_a), mp_comm=mp_comm)
225 npdims(:) = 0
226 CALL comm_dbm%create(mp_comm, 2, npdims)
227
228 ALLOCATE (rd_a(SIZE(dbm_get_row_block_sizes(dbm_a))))
229 ALLOCATE (rd_b(SIZE(dbm_get_row_block_sizes(dbm_b))))
230 ALLOCATE (rd_c(SIZE(dbm_get_row_block_sizes(dbm_c))))
231 ALLOCATE (cd_a(SIZE(dbm_get_col_block_sizes(dbm_a))))
232 ALLOCATE (cd_b(SIZE(dbm_get_col_block_sizes(dbm_b))))
233 ALLOCATE (cd_c(SIZE(dbm_get_col_block_sizes(dbm_c))))
234
235 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_a))), &
236 npdims(1), dbm_get_row_block_sizes(dbm_a), rd_a)
237 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_a))), &
238 npdims(2), dbm_get_col_block_sizes(dbm_a), cd_a)
239 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_b))), &
240 npdims(1), dbm_get_row_block_sizes(dbm_b), rd_b)
241 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_b))), &
242 npdims(2), dbm_get_col_block_sizes(dbm_b), cd_b)
243 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_c))), &
244 npdims(1), dbm_get_row_block_sizes(dbm_c), rd_c)
245 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_c))), &
246 npdims(2), dbm_get_col_block_sizes(dbm_c), cd_c)
247
248 CALL dbm_distribution_new(dist_a, comm_dbm, rd_a, cd_a)
249 CALL dbm_distribution_new(dist_b, comm_dbm, rd_b, cd_b)
250 CALL dbm_distribution_new(dist_c, comm_dbm, rd_c, cd_c)
251 DEALLOCATE (rd_a, rd_b, rd_c, cd_a, cd_b, cd_c)
252
253 ! Store pointers in intermediate variables to workaround a CCE error.
254 row_block_sizes_a => dbm_get_row_block_sizes(dbm_a)
255 col_block_sizes_a => dbm_get_col_block_sizes(dbm_a)
256 row_block_sizes_b => dbm_get_row_block_sizes(dbm_b)
257 col_block_sizes_b => dbm_get_col_block_sizes(dbm_b)
258 row_block_sizes_c => dbm_get_row_block_sizes(dbm_c)
259 col_block_sizes_c => dbm_get_col_block_sizes(dbm_c)
260
261 CALL dbm_create(matrix=dbm_a_mm, name=dbm_get_name(dbm_a), dist=dist_a, &
262 row_block_sizes=row_block_sizes_a, col_block_sizes=col_block_sizes_a)
263
264 CALL dbm_create(matrix=dbm_b_mm, name=dbm_get_name(dbm_b), dist=dist_b, &
265 row_block_sizes=row_block_sizes_b, col_block_sizes=col_block_sizes_b)
266
267 CALL dbm_create(matrix=dbm_c_mm, name=dbm_get_name(dbm_c), dist=dist_c, &
268 row_block_sizes=row_block_sizes_c, col_block_sizes=col_block_sizes_c)
269
270 CALL dbm_finalize(dbm_a_mm)
271 CALL dbm_finalize(dbm_b_mm)
272 CALL dbm_finalize(dbm_c_mm)
273
274 CALL dbm_redistribute(dbm_a, dbm_a_mm)
275 CALL dbm_redistribute(dbm_b, dbm_b_mm)
276 IF (PRESENT(io_unit)) THEN
277 IF (io_unit > 0) THEN
278 WRITE (io_unit, "(A)") "starting dbm benchmark"
279 END IF
280 END IF
281 CALL timeset("benchmark_block_mm", handle2)
282 CALL dbm_multiply(transa, transb, 1.0_dp, dbm_a_mm, dbm_b_mm, &
283 0.0_dp, dbm_c_mm, filter_eps=filter_eps)
284 CALL timestop(handle2)
285 IF (PRESENT(io_unit)) THEN
286 IF (io_unit > 0) THEN
287 WRITE (io_unit, "(A)") "dbm benchmark completed"
288 END IF
289 END IF
290
291 CALL dbm_release(dbm_a)
292 CALL dbm_release(dbm_b)
293 CALL dbm_release(dbm_c)
294 CALL dbm_release(dbm_a_mm)
295 CALL dbm_release(dbm_b_mm)
296 CALL dbm_release(dbm_c_mm)
297 CALL dbm_distribution_release(dist_a)
298 CALL dbm_distribution_release(dist_b)
299 CALL dbm_distribution_release(dist_c)
300
301 CALL comm_dbm%free()
302 END IF
303
304 END SUBROUTINE
305
306! **************************************************************************************************
307!> \brief Test tall-and-skinny matrix multiplication for accuracy
308!> \param transa ...
309!> \param transb ...
310!> \param transc ...
311!> \param matrix_a ...
312!> \param matrix_b ...
313!> \param matrix_c ...
314!> \param filter_eps ...
315!> \param unit_nr ...
316!> \param log_verbose ...
317!> \author Patrick Seewald
318! **************************************************************************************************
319 SUBROUTINE dbt_tas_test_mm(transa, transb, transc, matrix_a, matrix_b, matrix_c, filter_eps, unit_nr, log_verbose)
320 LOGICAL, INTENT(IN) :: transa, transb, transc
321 TYPE(dbt_tas_type), INTENT(INOUT) :: matrix_a, matrix_b, matrix_c
322 REAL(kind=dp), INTENT(IN), OPTIONAL :: filter_eps
323 INTEGER, INTENT(IN) :: unit_nr
324 LOGICAL, INTENT(IN), OPTIONAL :: log_verbose
325
326 REAL(kind=dp), PARAMETER :: test_tol = 1.0e-10_dp
327
328 CHARACTER(LEN=8) :: status_str
329 INTEGER :: io_unit, mynode
330 INTEGER, CONTIGUOUS, DIMENSION(:), POINTER :: cd_a, cd_b, cd_c, col_block_sizes_a, &
331 col_block_sizes_b, col_block_sizes_c, rd_a, rd_b, rd_c, row_block_sizes_a, &
332 row_block_sizes_b, row_block_sizes_c
333 INTEGER, DIMENSION(2) :: npdims
334 LOGICAL :: abort, transa_prv, transb_prv
335 REAL(kind=dp) :: norm, rc_cs, sq_cs
336 TYPE(dbm_distribution_obj) :: dist_a, dist_b, dist_c
337 TYPE(dbm_type) :: dbm_a, dbm_a_mm, dbm_b, dbm_b_mm, dbm_c, &
338 dbm_c_mm, dbm_c_mm_check
339 TYPE(mp_cart_type) :: comm_dbm, mp_comm
340
341!
342! TODO: Dedup with code in dbt_tas_benchmark_mm.
343!
344
345 CALL dbt_tas_get_split_info(dbt_tas_info(matrix_a), mp_comm=mp_comm)
346 mynode = mp_comm%mepos
347 abort = .false.
348 io_unit = -1
349 IF (mynode .EQ. 0) io_unit = unit_nr
350
351 CALL dbt_tas_multiply(transa, transb, transc, 1.0_dp, matrix_a, matrix_b, &
352 0.0_dp, matrix_c, &
353 filter_eps=filter_eps, unit_nr=io_unit, log_verbose=log_verbose, optimize_dist=.true.)
354
355 CALL dbt_tas_convert_to_dbm(matrix_a, dbm_a)
356 CALL dbt_tas_convert_to_dbm(matrix_b, dbm_b)
357 CALL dbt_tas_convert_to_dbm(matrix_c, dbm_c)
358
359 npdims(:) = 0
360 CALL comm_dbm%create(mp_comm, 2, npdims)
361
362 ALLOCATE (rd_a(SIZE(dbm_get_row_block_sizes(dbm_a))))
363 ALLOCATE (rd_b(SIZE(dbm_get_row_block_sizes(dbm_b))))
364 ALLOCATE (rd_c(SIZE(dbm_get_row_block_sizes(dbm_c))))
365 ALLOCATE (cd_a(SIZE(dbm_get_col_block_sizes(dbm_a))))
366 ALLOCATE (cd_b(SIZE(dbm_get_col_block_sizes(dbm_b))))
367 ALLOCATE (cd_c(SIZE(dbm_get_col_block_sizes(dbm_c))))
368
369 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_a))), &
370 npdims(1), dbm_get_row_block_sizes(dbm_a), rd_a)
371 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_a))), &
372 npdims(2), dbm_get_col_block_sizes(dbm_a), cd_a)
373 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_b))), &
374 npdims(1), dbm_get_row_block_sizes(dbm_b), rd_b)
375 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_b))), &
376 npdims(2), dbm_get_col_block_sizes(dbm_b), cd_b)
377 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_row_block_sizes(dbm_c))), &
378 npdims(1), dbm_get_row_block_sizes(dbm_c), rd_c)
379 CALL dbt_tas_default_distvec(int(SIZE(dbm_get_col_block_sizes(dbm_c))), &
380 npdims(2), dbm_get_col_block_sizes(dbm_c), cd_c)
381
382 CALL dbm_distribution_new(dist_a, comm_dbm, rd_a, cd_a)
383 CALL dbm_distribution_new(dist_b, comm_dbm, rd_b, cd_b)
384 CALL dbm_distribution_new(dist_c, comm_dbm, rd_c, cd_c)
385 DEALLOCATE (rd_a, rd_b, rd_c, cd_a, cd_b, cd_c)
386
387 ! Store pointers in intermediate variables to workaround a CCE error.
388 row_block_sizes_a => dbm_get_row_block_sizes(dbm_a)
389 col_block_sizes_a => dbm_get_col_block_sizes(dbm_a)
390 row_block_sizes_b => dbm_get_row_block_sizes(dbm_b)
391 col_block_sizes_b => dbm_get_col_block_sizes(dbm_b)
392 row_block_sizes_c => dbm_get_row_block_sizes(dbm_c)
393 col_block_sizes_c => dbm_get_col_block_sizes(dbm_c)
394
395 CALL dbm_create(matrix=dbm_a_mm, name="matrix a", dist=dist_a, &
396 row_block_sizes=row_block_sizes_a, col_block_sizes=col_block_sizes_a)
397
398 CALL dbm_create(matrix=dbm_b_mm, name="matrix b", dist=dist_b, &
399 row_block_sizes=row_block_sizes_b, col_block_sizes=col_block_sizes_b)
400
401 CALL dbm_create(matrix=dbm_c_mm, name="matrix c", dist=dist_c, &
402 row_block_sizes=row_block_sizes_c, col_block_sizes=col_block_sizes_c)
403
404 CALL dbm_create(matrix=dbm_c_mm_check, name="matrix c check", dist=dist_c, &
405 row_block_sizes=row_block_sizes_c, col_block_sizes=col_block_sizes_c)
406
407 CALL dbm_finalize(dbm_a_mm)
408 CALL dbm_finalize(dbm_b_mm)
409 CALL dbm_finalize(dbm_c_mm)
410 CALL dbm_finalize(dbm_c_mm_check)
411
412 CALL dbm_redistribute(dbm_a, dbm_a_mm)
413 CALL dbm_redistribute(dbm_b, dbm_b_mm)
414 CALL dbm_redistribute(dbm_c, dbm_c_mm_check)
415
416 transa_prv = transa; transb_prv = transb
417
418 IF (.NOT. transc) THEN
419 CALL dbm_multiply(transa_prv, transb_prv, 1.0_dp, &
420 dbm_a_mm, dbm_b_mm, &
421 0.0_dp, dbm_c_mm, filter_eps=filter_eps)
422 ELSE
423 transa_prv = .NOT. transa_prv
424 transb_prv = .NOT. transb_prv
425 CALL dbm_multiply(transb_prv, transa_prv, 1.0_dp, &
426 dbm_b_mm, dbm_a_mm, &
427 0.0_dp, dbm_c_mm, filter_eps=filter_eps)
428 END IF
429
430 sq_cs = dbm_checksum(dbm_c_mm)
431 rc_cs = dbm_checksum(dbm_c_mm_check)
432 CALL dbm_scale(dbm_c_mm_check, -1.0_dp)
433 CALL dbm_add(dbm_c_mm_check, dbm_c_mm)
434 norm = dbm_maxabs(dbm_c_mm_check)
435
436 IF (io_unit > 0) THEN
437 IF (abs(norm) > test_tol) THEN
438 status_str = " failed!"
439 abort = .true.
440 ELSE
441 status_str = " passed!"
442 abort = .false.
443 END IF
444 WRITE (io_unit, "(A)") &
445 trim(dbm_get_name(matrix_a%matrix))//" x "// &
446 trim(dbm_get_name(matrix_b%matrix))//trim(status_str)
447 WRITE (io_unit, "(A,1X,E9.2,1X,E9.2)") "checksums", sq_cs, rc_cs
448 WRITE (io_unit, "(A,1X,E9.2)") "difference norm", norm
449 IF (abort) cpabort("DBT TAS test failed")
450 END IF
451
452 CALL dbm_release(dbm_a)
453 CALL dbm_release(dbm_a_mm)
454 CALL dbm_release(dbm_b)
455 CALL dbm_release(dbm_b_mm)
456 CALL dbm_release(dbm_c)
457 CALL dbm_release(dbm_c_mm)
458 CALL dbm_release(dbm_c_mm_check)
459
460 CALL dbm_distribution_release(dist_a)
461 CALL dbm_distribution_release(dist_b)
462 CALL dbm_distribution_release(dist_c)
463
464 CALL comm_dbm%free()
465
466 END SUBROUTINE dbt_tas_test_mm
467
468! **************************************************************************************************
469!> \brief Calculate checksum of tall-and-skinny matrix consistent with dbm_checksum
470!> \param matrix ...
471!> \return ...
472!> \author Patrick Seewald
473! **************************************************************************************************
474 FUNCTION dbt_tas_checksum(matrix)
475 TYPE(dbt_tas_type), INTENT(IN) :: matrix
476 REAL(kind=dp) :: dbt_tas_checksum
477
478 TYPE(dbm_type) :: dbm_m
479
480 CALL dbt_tas_convert_to_dbm(matrix, dbm_m)
482 CALL dbm_release(dbm_m)
483 END FUNCTION
484
485! **************************************************************************************************
486!> \brief Create random block sizes
487!> \param sizes ...
488!> \param repeat ...
489!> \param dbt_sizes ...
490!> \author Patrick Seewald
491! **************************************************************************************************
492 SUBROUTINE dbt_tas_random_bsizes(sizes, repeat, dbt_sizes)
493 INTEGER, DIMENSION(:), INTENT(IN) :: sizes
494 INTEGER, INTENT(IN) :: repeat
495 INTEGER, DIMENSION(:), INTENT(OUT) :: dbt_sizes
496
497 INTEGER :: d, size_i
498
499 DO d = 1, SIZE(dbt_sizes)
500 size_i = mod((d - 1)/repeat, SIZE(sizes)) + 1
501 dbt_sizes(d) = sizes(size_i)
502 END DO
503 END SUBROUTINE
504
505! **************************************************************************************************
506!> \brief Reset the seed used for generating random matrices to default value
507!> \author Patrick Seewald
508! **************************************************************************************************
510 randmat_counter = rand_seed_init
511 END SUBROUTINE
512
513END MODULE
subroutine, public dbm_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, retain_sparsity, filter_eps, flop)
Computes matrix product: matrix_c = alpha * matrix_a * matrix_b + beta * matrix_c.
Definition dbm_api.F:736
subroutine, public dbm_redistribute(matrix, redist)
Copies content of matrix_b into matrix_a. Matrices may have different distributions.
Definition dbm_api.F:412
real(kind=dp) function, public dbm_maxabs(matrix)
Returns the absolute value of the larges element of the entire given matrix.
Definition dbm_api.F:996
subroutine, public dbm_scale(matrix, alpha)
Multiplies all entries in the given matrix by the given factor alpha.
Definition dbm_api.F:631
subroutine, public dbm_distribution_release(dist)
Decreases the reference counter of the given distribution.
Definition dbm_api.F:1401
subroutine, public dbm_create(matrix, name, dist, row_block_sizes, col_block_sizes)
Creates a new matrix.
Definition dbm_api.F:293
integer function, dimension(:), pointer, contiguous, public dbm_get_row_block_sizes(matrix)
Returns the row block sizes of the given matrix.
Definition dbm_api.F:1103
character(len=default_string_length) function, public dbm_get_name(matrix)
Returns the name of the matrix of the given matrix.
Definition dbm_api.F:1023
real(kind=dp) function, public dbm_checksum(matrix)
Computes a checksum of the given matrix.
Definition dbm_api.F:969
subroutine, public dbm_add(matrix_a, matrix_b)
Adds matrix_b to matrix_a.
Definition dbm_api.F:692
subroutine, public dbm_finalize(matrix)
Needed to be called for DBCSR after blocks where inserted. For DBM it's a no-opt.
Definition dbm_api.F:339
subroutine, public dbm_release(matrix)
Releases a matrix and all its ressources.
Definition dbm_api.F:354
integer function, dimension(:), pointer, contiguous, public dbm_get_col_block_sizes(matrix)
Returns the column block sizes of the given matrix.
Definition dbm_api.F:1130
subroutine, public dbm_distribution_new(dist, mp_comm, row_dist_block, col_dist_block)
Creates a new two dimensional distribution.
Definition dbm_api.F:1294
integer function, dimension(4), public generate_larnv_seed(irow, nrow, icol, ncol, ival)
Generate a seed respecting the lapack constraints,.
Definition dbm_tests.F:435
Tall-and-skinny matrices: base routines similar to DBM API, mostly wrappers around existing DBM routi...
subroutine, public dbt_tas_convert_to_dbm(matrix_rect, matrix_dbm)
Convert a tall-and-skinny matrix into a normal DBM matrix. This is not recommended for matrices with ...
subroutine, public dbt_tas_get_stored_coordinates(matrix, row, column, processor)
As dbt_get_stored_coordinates.
integer(kind=int_8) function, public dbt_tas_nblkrows_total(matrix)
...
subroutine, public dbt_tas_finalize(matrix)
...
subroutine, public dbt_tas_distribution_new(dist, mp_comm, row_dist, col_dist, split_info, nosplit)
create new distribution. Exactly like dbm_distribution_new but with custom types for row_dist and col...
type(dbt_tas_split_info) function, public dbt_tas_info(matrix)
get info on mpi grid splitting
integer(kind=int_8) function, public dbt_tas_nblkcols_total(matrix)
...
subroutine, public dbt_tas_put_block(matrix, row, col, block, summation)
As dbm_put_block.
Global data (distribution and block sizes) for tall-and-skinny matrices For very sparse matrices with...
subroutine, public dbt_tas_default_distvec(nblk, nproc, blk_size, dist)
get a load-balanced and randomized distribution along one tensor dimension
Matrix multiplication for tall-and-skinny matrices. This uses the k-split (non-recursive) CARMA algor...
Definition dbt_tas_mm.F:18
recursive subroutine, public dbt_tas_multiply(transa, transb, transc, alpha, matrix_a, matrix_b, beta, matrix_c, optimize_dist, split_opt, filter_eps, flop, move_data_a, move_data_b, retain_sparsity, simple_split, unit_nr, log_verbose)
tall-and-skinny matrix-matrix multiplication. Undocumented dummy arguments are identical to arguments...
Definition dbt_tas_mm.F:105
methods to split tall-and-skinny matrices along longest dimension. Basically, we are splitting proces...
subroutine, public dbt_tas_get_split_info(info, mp_comm, nsplit, igroup, mp_comm_group, split_rowcol, pgrid_offset)
Get info on split.
testing infrastructure for tall-and-skinny matrices
subroutine, public dbt_tas_test_mm(transa, transb, transc, matrix_a, matrix_b, matrix_c, filter_eps, unit_nr, log_verbose)
Test tall-and-skinny matrix multiplication for accuracy.
subroutine, public dbt_tas_reset_randmat_seed()
Reset the seed used for generating random matrices to default value.
subroutine, public dbt_tas_benchmark_mm(transa, transb, transc, matrix_a, matrix_b, matrix_c, compare_dbm, filter_eps, io_unit)
Benchmark routine. Due to random sparsity (as opposed to structured sparsity pattern),...
subroutine, public dbt_tas_setup_test_matrix(matrix, mp_comm_out, mp_comm, nrows, ncols, rbsizes, cbsizes, dist_splitsize, name, sparsity, reuse_comm)
Setup tall-and-skinny matrix for testing.
real(kind=dp) function, public dbt_tas_checksum(matrix)
Calculate checksum of tall-and-skinny matrix consistent with dbm_checksum.
subroutine, public dbt_tas_random_bsizes(sizes, repeat, dbt_sizes)
Create random block sizes.
DBT tall-and-skinny base types. Mostly wrappers around existing DBM routines.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public int_8
Definition kinds.F:54
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
type for arbitrary block sizes
type for cyclic (round robin) distribution: