Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Performance tests for basic tasks like matrix multiplies, copy, fft.
10 : !> \par History
11 : !> 30-Nov-2000 (JGH) added input
12 : !> 02-Jan-2001 (JGH) Parallel FFT
13 : !> 28-Feb-2002 (JGH) Clebsch-Gordon Coefficients
14 : !> 06-Jun-2003 (JGH) Real space grid test
15 : !> Eigensolver test (29.08.05,MK)
16 : !> \author JGH 6-NOV-2000
17 : ! **************************************************************************************************
18 : MODULE library_tests
19 :
20 : USE ai_coulomb_test, ONLY: eri_test
21 : USE cell_methods, ONLY: cell_create,&
22 : init_cell
23 : USE cell_types, ONLY: cell_release,&
24 : cell_type
25 : USE cg_test, ONLY: gaunt_coefficient_test
26 : USE cp_blacs_env, ONLY: cp_blacs_env_create,&
27 : cp_blacs_env_release,&
28 : cp_blacs_env_type
29 : USE cp_dbcsr_api, ONLY: dbcsr_reset_randmat_seed,&
30 : dbcsr_run_tests
31 : USE cp_eri_mme_interface, ONLY: cp_eri_mme_perf_acc_test
32 : USE cp_files, ONLY: close_file,&
33 : open_file
34 : USE cp_fm_basic_linalg, ONLY: cp_fm_gemm
35 : USE cp_fm_diag, ONLY: cp_fm_syevd,&
36 : cp_fm_syevx
37 : USE cp_fm_struct, ONLY: cp_fm_struct_create,&
38 : cp_fm_struct_get,&
39 : cp_fm_struct_release,&
40 : cp_fm_struct_type
41 : USE cp_fm_types, ONLY: cp_fm_create,&
42 : cp_fm_pilaenv,&
43 : cp_fm_release,&
44 : cp_fm_set_all,&
45 : cp_fm_set_submatrix,&
46 : cp_fm_to_fm,&
47 : cp_fm_type
48 : USE cp_log_handling, ONLY: cp_get_default_logger,&
49 : cp_logger_type
50 : USE cp_output_handling, ONLY: cp_print_key_finished_output,&
51 : cp_print_key_unit_nr
52 : USE cp_realspace_grid_init, ONLY: init_input_type
53 : USE dbm_tests, ONLY: dbm_run_tests
54 : USE fft_api, ONLY: FFT_LIBRARY_BACKEND_FFTW,&
55 : FFT_LIBRARY_BACKEND_GPU
56 : USE fft_tools, ONLY: BWFFT,&
57 : FFT_RADIX_CLOSEST,&
58 : FWFFT,&
59 : fft3d,&
60 : fft_radix_operations,&
61 : finalize_fft,&
62 : init_fft
63 : USE global_types, ONLY: global_environment_type
64 : USE input_constants, ONLY: do_diag_syevd,&
65 : do_diag_syevx,&
66 : do_mat_random,&
67 : do_mat_read,&
68 : do_pwgrid_ns_fullspace,&
69 : do_pwgrid_ns_halfspace,&
70 : do_pwgrid_spherical
71 : USE input_section_types, ONLY: section_vals_get,&
72 : section_vals_get_subs_vals,&
73 : section_vals_type,&
74 : section_vals_val_get
75 : USE kinds, ONLY: dp
76 : USE machine, ONLY: m_flush,&
77 : m_walltime
78 : USE mathconstants, ONLY: gaussi
79 : USE message_passing, ONLY: mp_para_env_type
80 : USE minimax_exp, ONLY: validate_exp_minimax
81 : USE mp_perf_test, ONLY: mpi_perf_test
82 : USE parallel_gemm_api, ONLY: parallel_gemm
83 : USE parallel_rng_types, ONLY: UNIFORM,&
84 : rng_stream_type
85 : USE pw_grid_types, ONLY: FULLSPACE,&
86 : HALFSPACE,&
87 : pw_grid_type
88 : USE pw_grids, ONLY: pw_grid_create,&
89 : pw_grid_release
90 : USE pw_methods, ONLY: pw_transfer,&
91 : pw_zero
92 : USE pw_types, ONLY: pw_c1d_gs_type,&
93 : pw_c3d_rs_type,&
94 : pw_r3d_rs_type
95 : USE realspace_grid_types, ONLY: &
96 : realspace_grid_desc_type, realspace_grid_input_type, realspace_grid_type, rs_grid_create, &
97 : rs_grid_create_descriptor, rs_grid_print, rs_grid_release, rs_grid_release_descriptor, &
98 : rs_grid_zero, transfer_pw2rs, transfer_rs2pw
99 : USE shg_integrals_test, ONLY: shg_integrals_perf_acc_test
100 : USE time_frequency_grids, ONLY: test_least_square_ft
101 : #include "./base/base_uses.f90"
102 :
103 : IMPLICIT NONE
104 :
105 : PRIVATE
106 : PUBLIC :: lib_test
107 :
108 : INTEGER :: runtest(100)
109 : REAL(KIND=dp) :: max_memory
110 : REAL(KIND=dp), PARAMETER :: threshold = 1.0E-8_dp
111 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'library_tests'
112 :
113 : CONTAINS
114 :
115 : ! **************************************************************************************************
116 : !> \brief Master routine for tests
117 : !> \param root_section ...
118 : !> \param para_env ...
119 : !> \param globenv ...
120 : !> \par History
121 : !> none
122 : !> \author JGH 6-NOV-2000
123 : ! **************************************************************************************************
124 720 : SUBROUTINE lib_test(root_section, para_env, globenv)
125 :
126 : TYPE(section_vals_type), POINTER :: root_section
127 : TYPE(mp_para_env_type), POINTER :: para_env
128 : TYPE(global_environment_type), POINTER :: globenv
129 :
130 : CHARACTER(LEN=*), PARAMETER :: routineN = 'lib_test'
131 :
132 : INTEGER :: handle, iw
133 : LOGICAL :: explicit
134 : TYPE(cp_logger_type), POINTER :: logger
135 : TYPE(section_vals_type), POINTER :: cp_dbcsr_test_section, cp_fm_gemm_test_section, &
136 : dbm_test_section, eigensolver_section, eri_mme_test_section, pw_transfer_section, &
137 : rs_pw_transfer_section, shg_integrals_test_section
138 :
139 80 : CALL timeset(routineN, handle)
140 :
141 80 : logger => cp_get_default_logger()
142 80 : iw = cp_print_key_unit_nr(logger, root_section, "TEST%PROGRAM_RUN_INFO", extension=".log")
143 :
144 80 : IF (iw > 0) THEN
145 40 : WRITE (iw, '(T2,79("*"))')
146 40 : WRITE (iw, '(A,T31,A,T80,A)') ' *', ' PERFORMANCE TESTS ', '*'
147 40 : WRITE (iw, '(T2,79("*"))')
148 : END IF
149 : !
150 80 : CALL test_input(root_section, para_env)
151 : !
152 80 : IF (runtest(1) /= 0) CALL copy_test(para_env, iw)
153 : !
154 80 : IF (runtest(2) /= 0) CALL matmul_test(para_env, test_matmul=.TRUE., test_dgemm=.FALSE., iw=iw)
155 80 : IF (runtest(5) /= 0) CALL matmul_test(para_env, test_matmul=.FALSE., test_dgemm=.TRUE., iw=iw)
156 : !
157 80 : IF (runtest(3) /= 0) CALL fft_test(iw, globenv%fftw_plan_type, &
158 2 : globenv%fftw_wisdom_file_name)
159 : !
160 80 : IF (runtest(4) /= 0) CALL eri_test(iw)
161 : !
162 80 : IF (runtest(6) /= 0) CALL gaunt_coefficient_test()
163 : !
164 : ! runtest 7 has been deleted and can be recycled
165 : !
166 80 : IF (runtest(8) /= 0) CALL mpi_perf_test(para_env, runtest(8), iw)
167 : !
168 80 : IF (runtest(10) /= 0) CALL validate_exp_minimax(runtest(10), iw)
169 : !
170 80 : IF (runtest(11) /= 0) CALL test_least_square_ft(runtest(11), iw)
171 : !
172 :
173 80 : rs_pw_transfer_section => section_vals_get_subs_vals(root_section, "TEST%RS_PW_TRANSFER")
174 80 : CALL section_vals_get(rs_pw_transfer_section, explicit=explicit)
175 80 : IF (explicit) THEN
176 2 : CALL rs_pw_transfer_test(para_env, iw, globenv, rs_pw_transfer_section)
177 : END IF
178 :
179 80 : pw_transfer_section => section_vals_get_subs_vals(root_section, "TEST%PW_TRANSFER")
180 80 : CALL section_vals_get(pw_transfer_section, explicit=explicit)
181 80 : IF (explicit) THEN
182 10 : CALL pw_fft_test(para_env, iw, globenv, pw_transfer_section)
183 : END IF
184 :
185 80 : cp_fm_gemm_test_section => section_vals_get_subs_vals(root_section, "TEST%CP_FM_GEMM")
186 80 : CALL section_vals_get(cp_fm_gemm_test_section, explicit=explicit)
187 80 : IF (explicit) THEN
188 4 : CALL cp_fm_gemm_test(para_env, iw, cp_fm_gemm_test_section)
189 : END IF
190 :
191 80 : eigensolver_section => section_vals_get_subs_vals(root_section, "TEST%EIGENSOLVER")
192 80 : CALL section_vals_get(eigensolver_section, explicit=explicit)
193 80 : IF (explicit) THEN
194 2 : CALL eigensolver_test(para_env, iw, eigensolver_section)
195 : END IF
196 :
197 80 : eri_mme_test_section => section_vals_get_subs_vals(root_section, "TEST%ERI_MME_TEST")
198 80 : CALL section_vals_get(eri_mme_test_section, explicit=explicit)
199 80 : IF (explicit) THEN
200 8 : CALL cp_eri_mme_perf_acc_test(para_env, iw, eri_mme_test_section)
201 : END IF
202 :
203 80 : shg_integrals_test_section => section_vals_get_subs_vals(root_section, "TEST%SHG_INTEGRALS_TEST")
204 80 : CALL section_vals_get(shg_integrals_test_section, explicit=explicit)
205 80 : IF (explicit) THEN
206 4 : CALL shg_integrals_perf_acc_test(iw, shg_integrals_test_section)
207 : END IF
208 :
209 : ! DBCSR tests
210 80 : cp_dbcsr_test_section => section_vals_get_subs_vals(root_section, "TEST%CP_DBCSR")
211 80 : CALL section_vals_get(cp_dbcsr_test_section, explicit=explicit)
212 80 : IF (explicit) THEN
213 32 : CALL cp_dbcsr_tests(para_env, iw, cp_dbcsr_test_section)
214 : END IF
215 :
216 : ! DBM tests
217 80 : dbm_test_section => section_vals_get_subs_vals(root_section, "TEST%DBM")
218 80 : CALL section_vals_get(dbm_test_section, explicit=explicit)
219 80 : IF (explicit) THEN
220 14 : CALL run_dbm_tests(para_env, iw, dbm_test_section)
221 : END IF
222 :
223 80 : CALL cp_print_key_finished_output(iw, logger, root_section, "TEST%PROGRAM_RUN_INFO")
224 :
225 80 : CALL timestop(handle)
226 :
227 80 : END SUBROUTINE lib_test
228 :
229 : ! **************************************************************************************************
230 : !> \brief Reads input section &TEST ... &END
231 : !> \param root_section ...
232 : !> \param para_env ...
233 : !> \author JGH 30-NOV-2000
234 : !> \note
235 : !> I---------------------------------------------------------------------------I
236 : !> I SECTION: &TEST ... &END I
237 : !> I I
238 : !> I MEMORY max_memory I
239 : !> I COPY n I
240 : !> I MATMUL n I
241 : !> I FFT n I
242 : !> I ERI n I
243 : !> I PW_FFT n I
244 : !> I Clebsch-Gordon n -> Gaunt coefficients I
245 : !> I RS_GRIDS n I
246 : !> I MPI n I
247 : !> I RNG n -> Parallel random number generator I
248 : !> I---------------------------------------------------------------------------I
249 : ! **************************************************************************************************
250 160 : SUBROUTINE test_input(root_section, para_env)
251 : TYPE(section_vals_type), POINTER :: root_section
252 : TYPE(mp_para_env_type), POINTER :: para_env
253 :
254 : TYPE(section_vals_type), POINTER :: test_section
255 :
256 : !
257 : !..defaults
258 : ! using this style is not recommended, introduce sections instead (see e.g. cp_fm_gemm)
259 :
260 80 : runtest = 0
261 80 : test_section => section_vals_get_subs_vals(root_section, "TEST")
262 80 : CALL section_vals_val_get(test_section, "MEMORY", r_val=max_memory)
263 80 : CALL section_vals_val_get(test_section, 'COPY', i_val=runtest(1))
264 80 : CALL section_vals_val_get(test_section, 'MATMUL', i_val=runtest(2))
265 80 : CALL section_vals_val_get(test_section, 'DGEMM', i_val=runtest(5))
266 80 : CALL section_vals_val_get(test_section, 'FFT', i_val=runtest(3))
267 80 : CALL section_vals_val_get(test_section, 'ERI', i_val=runtest(4))
268 80 : CALL section_vals_val_get(test_section, 'CLEBSCH_GORDON', i_val=runtest(6))
269 80 : CALL section_vals_val_get(test_section, 'MPI', i_val=runtest(8))
270 80 : CALL section_vals_val_get(test_section, 'MINIMAX', i_val=runtest(10))
271 80 : CALL section_vals_val_get(test_section, 'LEAST_SQ_FT', i_val=runtest(11))
272 :
273 80 : CALL para_env%sync()
274 80 : END SUBROUTINE test_input
275 :
276 : ! **************************************************************************************************
277 : !> \brief Tests the performance to copy two vectors.
278 : !> \param para_env ...
279 : !> \param iw ...
280 : !> \par History
281 : !> none
282 : !> \author JGH 6-NOV-2000
283 : !> \note
284 : !> The results of these tests allow to determine the size of the cache
285 : !> of the CPU. This can be used to optimize the performance of the
286 : !> FFTSG library.
287 : ! **************************************************************************************************
288 2 : SUBROUTINE copy_test(para_env, iw)
289 : TYPE(mp_para_env_type), POINTER :: para_env
290 : INTEGER :: iw
291 :
292 : INTEGER :: i, j, len, ntim, siz
293 : REAL(KIND=dp) :: perf, t, tend, tstart
294 2 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: ca, cb
295 :
296 : ! test for copy --> Cache size
297 :
298 2 : siz = ABS(runtest(1))
299 2 : IF (para_env%is_source()) WRITE (iw, '(//,A,/)') " Test of copy ( F95 ) "
300 34 : DO i = 6, 24
301 34 : len = 2**i
302 34 : IF (8.0_dp*REAL(len, KIND=dp) > max_memory*0.5_dp) EXIT
303 96 : ALLOCATE (ca(len))
304 64 : ALLOCATE (cb(len))
305 :
306 32 : CALL RANDOM_NUMBER(ca)
307 32 : ntim = NINT(1.e7_dp/REAL(len, KIND=dp))
308 32 : ntim = MAX(ntim, 1)
309 32 : ntim = MIN(ntim, siz*10000)
310 :
311 32 : tstart = m_walltime()
312 512524 : DO j = 1, ntim
313 315058412 : cb(:) = ca(:)
314 512524 : ca(1) = REAL(j, KIND=dp)
315 : END DO
316 32 : tend = m_walltime()
317 32 : t = tend - tstart + threshold
318 32 : IF (t > 0.0_dp) THEN
319 32 : perf = REAL(ntim, KIND=dp)*REAL(len, KIND=dp)*1.e-6_dp/t
320 : ELSE
321 0 : perf = 0.0_dp
322 : END IF
323 :
324 32 : IF (para_env%is_source()) THEN
325 16 : WRITE (iw, '(A,i2,i10,A,T59,F14.4,A)') " Copy test: Size = 2^", i, &
326 32 : len/1024, " Kwords", perf, " Mcopy/s"
327 : END IF
328 :
329 32 : DEALLOCATE (ca)
330 34 : DEALLOCATE (cb)
331 : END DO
332 2 : CALL para_env%sync()
333 2 : END SUBROUTINE copy_test
334 :
335 : ! **************************************************************************************************
336 : !> \brief Tests the performance of different kinds of matrix matrix multiply
337 : !> kernels for the BLAS and F95 intrinsic matmul.
338 : !> \param para_env ...
339 : !> \param test_matmul ...
340 : !> \param test_dgemm ...
341 : !> \param iw ...
342 : !> \par History
343 : !> none
344 : !> \author JGH 6-NOV-2000
345 : ! **************************************************************************************************
346 2 : SUBROUTINE matmul_test(para_env, test_matmul, test_dgemm, iw)
347 : TYPE(mp_para_env_type), POINTER :: para_env
348 : LOGICAL :: test_matmul, test_dgemm
349 : INTEGER :: iw
350 :
351 : INTEGER :: i, j, len, ntim, siz
352 : REAL(KIND=dp) :: perf, t, tend, tstart, xdum
353 2 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: ma, mb, mc
354 :
355 : ! test for matrix multpies
356 :
357 2 : IF (test_matmul) THEN
358 2 : siz = ABS(runtest(2))
359 2 : IF (para_env%is_source()) WRITE (iw, '(//,A,/)') " Test of matmul ( F95 ) "
360 2 : DO i = 5, siz, 2
361 4 : len = 2**i + 1
362 4 : IF (8.0_dp*REAL(len*len, KIND=dp) > max_memory*0.3_dp) EXIT
363 16 : ALLOCATE (ma(len, len))
364 12 : ALLOCATE (mb(len, len))
365 12 : ALLOCATE (mc(len, len))
366 4 : mc = 0.0_dp
367 :
368 4 : CALL RANDOM_NUMBER(xdum)
369 35788 : ma = xdum
370 4 : CALL RANDOM_NUMBER(xdum)
371 35788 : mb = xdum
372 4 : ntim = NINT(1.e8_dp/(2.0_dp*REAL(len, KIND=dp)**3))
373 4 : ntim = MAX(ntim, 1)
374 4 : ntim = MIN(ntim, siz*200)
375 4 : tstart = m_walltime()
376 2832 : DO j = 1, ntim
377 2828 : mc(:, :) = MATMUL(ma, mb)
378 2832 : ma(1, 1) = REAL(j, KIND=dp)
379 : END DO
380 4 : tend = m_walltime()
381 4 : t = tend - tstart + threshold
382 4 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
383 4 : IF (para_env%is_source()) THEN
384 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
385 2 : " Matrix multiply test: c = a * b Size = ", len, perf, " Mflop/s"
386 : END IF
387 4 : tstart = m_walltime()
388 2832 : DO j = 1, ntim
389 3895652 : mc(:, :) = mc + MATMUL(ma, mb)
390 2832 : ma(1, 1) = REAL(j, KIND=dp)
391 : END DO
392 4 : tend = m_walltime()
393 4 : t = tend - tstart + threshold
394 4 : IF (t > 0.0_dp) THEN
395 4 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
396 : ELSE
397 0 : perf = 0.0_dp
398 : END IF
399 :
400 4 : IF (para_env%is_source()) THEN
401 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
402 2 : " Matrix multiply test: a = a * b Size = ", len, perf, " Mflop/s"
403 : END IF
404 :
405 4 : tstart = m_walltime()
406 2832 : DO j = 1, ntim
407 3895652 : mc(:, :) = mc + MATMUL(ma, TRANSPOSE(mb))
408 2832 : ma(1, 1) = REAL(j, KIND=dp)
409 : END DO
410 4 : tend = m_walltime()
411 4 : t = tend - tstart + threshold
412 4 : IF (t > 0.0_dp) THEN
413 4 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
414 : ELSE
415 0 : perf = 0.0_dp
416 : END IF
417 :
418 4 : IF (para_env%is_source()) THEN
419 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
420 2 : " Matrix multiply test: c = a * b(T) Size = ", len, perf, " Mflop/s"
421 : END IF
422 :
423 4 : tstart = m_walltime()
424 2832 : DO j = 1, ntim
425 3895652 : mc(:, :) = mc + MATMUL(TRANSPOSE(ma), mb)
426 2832 : ma(1, 1) = REAL(j, KIND=dp)
427 : END DO
428 4 : tend = m_walltime()
429 4 : t = tend - tstart + threshold
430 4 : IF (t > 0.0_dp) THEN
431 4 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
432 : ELSE
433 0 : perf = 0.0_dp
434 : END IF
435 :
436 4 : IF (para_env%is_source()) THEN
437 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
438 2 : " Matrix multiply test: c = a(T) * b Size = ", len, perf, " Mflop/s"
439 : END IF
440 :
441 4 : DEALLOCATE (ma)
442 4 : DEALLOCATE (mb)
443 4 : DEALLOCATE (mc)
444 : END DO
445 : END IF
446 :
447 : ! test for matrix multpies
448 2 : IF (test_dgemm) THEN
449 0 : siz = ABS(runtest(5))
450 0 : IF (para_env%is_source()) WRITE (iw, '(//,A,/)') " Test of matmul ( BLAS ) "
451 0 : DO i = 5, siz, 2
452 0 : len = 2**i + 1
453 0 : IF (8.0_dp*REAL(len*len, KIND=dp) > max_memory*0.3_dp) EXIT
454 0 : ALLOCATE (ma(len, len))
455 0 : ALLOCATE (mb(len, len))
456 0 : ALLOCATE (mc(len, len))
457 0 : mc = 0.0_dp
458 :
459 0 : CALL RANDOM_NUMBER(xdum)
460 0 : ma = xdum
461 0 : CALL RANDOM_NUMBER(xdum)
462 0 : mb = xdum
463 0 : ntim = NINT(1.e8_dp/(2.0_dp*REAL(len, KIND=dp)**3))
464 0 : ntim = MAX(ntim, 1)
465 0 : ntim = MIN(ntim, 1000)
466 :
467 0 : tstart = m_walltime()
468 0 : DO j = 1, ntim
469 0 : CALL dgemm("N", "N", len, len, len, 1.0_dp, ma, len, mb, len, 1.0_dp, mc, len)
470 : END DO
471 0 : tend = m_walltime()
472 0 : t = tend - tstart + threshold
473 0 : IF (t > 0.0_dp) THEN
474 0 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
475 : ELSE
476 0 : perf = 0.0_dp
477 : END IF
478 :
479 0 : IF (para_env%is_source()) THEN
480 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
481 0 : " Matrix multiply test: c = a * b Size = ", len, perf, " Mflop/s"
482 : END IF
483 :
484 0 : tstart = m_walltime()
485 0 : DO j = 1, ntim
486 0 : CALL dgemm("N", "N", len, len, len, 1.0_dp, ma, len, mb, len, 1.0_dp, mc, len)
487 : END DO
488 0 : tend = m_walltime()
489 0 : t = tend - tstart + threshold
490 0 : IF (t > 0.0_dp) THEN
491 0 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
492 : ELSE
493 0 : perf = 0.0_dp
494 : END IF
495 :
496 0 : IF (para_env%is_source()) THEN
497 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
498 0 : " Matrix multiply test: a = a * b Size = ", len, perf, " Mflop/s"
499 : END IF
500 :
501 0 : tstart = m_walltime()
502 0 : DO j = 1, ntim
503 0 : CALL dgemm("N", "T", len, len, len, 1.0_dp, ma, len, mb, len, 1.0_dp, mc, len)
504 : END DO
505 0 : tend = m_walltime()
506 0 : t = tend - tstart + threshold
507 0 : IF (t > 0.0_dp) THEN
508 0 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
509 : ELSE
510 0 : perf = 0.0_dp
511 : END IF
512 :
513 0 : IF (para_env%is_source()) THEN
514 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
515 0 : " Matrix multiply test: c = a * b(T) Size = ", len, perf, " Mflop/s"
516 : END IF
517 :
518 0 : tstart = m_walltime()
519 0 : DO j = 1, ntim
520 0 : CALL dgemm("T", "N", len, len, len, 1.0_dp, ma, len, mb, len, 1.0_dp, mc, len)
521 : END DO
522 0 : tend = m_walltime()
523 0 : t = tend - tstart + threshold
524 0 : IF (t > 0.0_dp) THEN
525 0 : perf = REAL(ntim, KIND=dp)*2.0_dp*REAL(len, KIND=dp)**3*1.e-6_dp/t
526 : ELSE
527 0 : perf = 0.0_dp
528 : END IF
529 :
530 0 : IF (para_env%is_source()) THEN
531 : WRITE (iw, '(A,i6,T59,F14.4,A)') &
532 0 : " Matrix multiply test: c = a(T) * b Size = ", len, perf, " Mflop/s"
533 : END IF
534 :
535 0 : DEALLOCATE (ma)
536 0 : DEALLOCATE (mb)
537 0 : DEALLOCATE (mc)
538 : END DO
539 : END IF
540 :
541 2 : CALL para_env%sync()
542 :
543 2 : END SUBROUTINE matmul_test
544 :
545 : ! **************************************************************************************************
546 : !> \brief Tests the performance of all available FFT libraries for 3D FFTs
547 : !> \param iw ...
548 : !> \param fftw_plan_type ...
549 : !> \param wisdom_file where FFTW3 should look to save/load wisdom
550 : !> \par History
551 : !> none
552 : !> \author JGH 6-NOV-2000
553 : ! **************************************************************************************************
554 2 : SUBROUTINE fft_test(iw, fftw_plan_type, wisdom_file)
555 :
556 : INTEGER :: iw, fftw_plan_type
557 : CHARACTER(LEN=*), INTENT(IN) :: wisdom_file
558 :
559 : INTEGER, PARAMETER :: backends(2) = [FFT_LIBRARY_BACKEND_FFTW, FFT_LIBRARY_BACKEND_GPU], &
560 : ndate(3) = [12, 48, 96]
561 :
562 : INTEGER :: iall, it, j, len, n(3), ntim, radix_in, &
563 : radix_out, siz, status
564 : COMPLEX(KIND=dp), DIMENSION(4, 4, 4) :: zz
565 2 : COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: ca, cb, cc
566 : CHARACTER(LEN=7) :: method
567 : REAL(KIND=dp) :: flops, perf, scale, t, tdiff, tend, &
568 : tstart
569 2 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: ra
570 :
571 : ! test for 3d FFT
572 :
573 2 : IF (iw > 0) WRITE (iw, '(//,A,/)') " Test of 3D-FFT "
574 2 : siz = ABS(runtest(3))
575 :
576 6 : DO iall = 1, 2
577 4 : IF (backends(iall) == FFT_LIBRARY_BACKEND_FFTW) THEN
578 2 : method = "FFTW "
579 2 : ELSE IF (backends(iall) == FFT_LIBRARY_BACKEND_GPU) THEN
580 2 : method = "GPU "
581 : ELSE
582 : EXIT
583 : END IF
584 : CALL init_fft(backends(iall), alltoall=.FALSE., wisdom_file=wisdom_file, &
585 4 : pool_limit=10, plan_style=fftw_plan_type, status=status)
586 4 : IF (status /= 0) CYCLE
587 8 : n = 4
588 2 : zz = 0.0_dp
589 2 : CALL fft3d(FWFFT, n, zz)
590 8 : DO it = 1, 3
591 6 : radix_in = ndate(it)
592 6 : CALL fft_radix_operations(radix_in, radix_out, FFT_RADIX_CLOSEST)
593 6 : len = radix_out
594 24 : n = len
595 6 : IF (16.0_dp*REAL(len*len*len, KIND=dp) > max_memory*0.5_dp) EXIT
596 30 : ALLOCATE (ra(len, len, len))
597 30 : ALLOCATE (ca(len, len, len))
598 6 : CALL RANDOM_NUMBER(ra)
599 2017758 : ca(:, :, :) = ra
600 6 : CALL RANDOM_NUMBER(ra)
601 2017758 : ca(:, :, :) = ca + gaussi*ra
602 6 : flops = REAL(len**3, KIND=dp)*15.0_dp*LOG(REAL(len, KIND=dp))
603 6 : ntim = NINT(siz*1.e7_dp/flops)
604 6 : ntim = MAX(ntim, 1)
605 6 : ntim = MIN(ntim, 200)
606 6 : scale = 1.0_dp/REAL(len**3, KIND=dp)
607 6 : tstart = m_walltime()
608 442 : DO j = 1, ntim
609 436 : CALL fft3d(FWFFT, n, ca)
610 442 : CALL fft3d(BWFFT, n, ca)
611 : END DO
612 6 : tend = m_walltime()
613 6 : t = tend - tstart + threshold
614 6 : IF (t > 0.0_dp) THEN
615 6 : perf = REAL(ntim, KIND=dp)*2.0_dp*flops*1.e-6_dp/t
616 : ELSE
617 0 : perf = 0.0_dp
618 : END IF
619 :
620 6 : IF (iw > 0) THEN
621 : WRITE (iw, '(T2,A,A,i6,T59,F14.4,A)') &
622 3 : ADJUSTR(method), " test (in-place) Size = ", len, perf, " Mflop/s"
623 : END IF
624 6 : DEALLOCATE (ca)
625 8 : DEALLOCATE (ra)
626 : END DO
627 2 : IF (iw > 0) WRITE (iw, *)
628 : ! test if input data is preserved
629 2 : len = 24
630 8 : n = len
631 2 : ALLOCATE (ra(len, len, len))
632 2 : ALLOCATE (ca(len, len, len))
633 2 : ALLOCATE (cb(len, len, len))
634 2 : ALLOCATE (cc(len, len, len))
635 2 : CALL RANDOM_NUMBER(ra)
636 28850 : ca(:, :, :) = ra
637 2 : CALL RANDOM_NUMBER(ra)
638 28850 : ca(:, :, :) = ca + gaussi*ra
639 28850 : cc(:, :, :) = ca
640 2 : CALL fft3d(FWFFT, n, ca, cb)
641 28850 : tdiff = MAXVAL(ABS(ca - cc))
642 2 : IF (tdiff > 1.0E-12_dp) THEN
643 0 : IF (iw > 0) THEN
644 0 : WRITE (iw, '(T2,A,A,A)') ADJUSTR(method), " FWFFT ", &
645 0 : " Input array is changed in out-of-place FFT !"
646 : END IF
647 : ELSE
648 2 : IF (iw > 0) THEN
649 1 : WRITE (iw, '(T2,A,A,A)') ADJUSTR(method), " FWFFT ", &
650 2 : " Input array is not changed in out-of-place FFT !"
651 : END IF
652 : END IF
653 28850 : ca(:, :, :) = cc
654 2 : CALL fft3d(BWFFT, n, ca, cb)
655 28850 : tdiff = MAXVAL(ABS(ca - cc))
656 2 : IF (tdiff > 1.0E-12_dp) THEN
657 0 : IF (iw > 0) THEN
658 0 : WRITE (iw, '(T2,A,A,A)') ADJUSTR(method), " BWFFT ", &
659 0 : " Input array is changed in out-of-place FFT !"
660 : END IF
661 : ELSE
662 2 : IF (iw > 0) THEN
663 1 : WRITE (iw, '(T2,A,A,A)') ADJUSTR(method), " BWFFT ", &
664 2 : " Input array is not changed in out-of-place FFT !"
665 : END IF
666 : END IF
667 2 : IF (iw > 0) WRITE (iw, *)
668 :
669 2 : DEALLOCATE (ra)
670 2 : DEALLOCATE (ca)
671 2 : DEALLOCATE (cb)
672 2 : DEALLOCATE (cc)
673 :
674 6 : CALL finalize_fft(wisdom_file)
675 : END DO
676 :
677 2 : END SUBROUTINE fft_test
678 :
679 : ! **************************************************************************************************
680 : !> \brief test rs_pw_transfer performance
681 : !> \param para_env ...
682 : !> \param iw ...
683 : !> \param globenv ...
684 : !> \param rs_pw_transfer_section ...
685 : !> \author Joost VandeVondele
686 : !> 9.2008 Randomise rs grid [Iain Bethune]
687 : !> (c) The Numerical Algorithms Group (NAG) Ltd, 2008 on behalf of the HECToR project
688 : ! **************************************************************************************************
689 2 : SUBROUTINE rs_pw_transfer_test(para_env, iw, globenv, rs_pw_transfer_section)
690 :
691 : TYPE(mp_para_env_type), POINTER :: para_env
692 : INTEGER :: iw
693 : TYPE(global_environment_type), POINTER :: globenv
694 : TYPE(section_vals_type), POINTER :: rs_pw_transfer_section
695 :
696 : CHARACTER(LEN=*), PARAMETER :: routineN = 'rs_pw_transfer_test'
697 :
698 : INTEGER :: halo_size, handle, i_loop, n_loop, &
699 : ns_max, status
700 : INTEGER, DIMENSION(3) :: no, np
701 2 : INTEGER, DIMENSION(:), POINTER :: i_vals
702 : LOGICAL :: do_rs2pw
703 : REAL(KIND=dp) :: tend, tstart
704 : TYPE(cell_type), POINTER :: box
705 : TYPE(pw_grid_type), POINTER :: grid
706 : TYPE(pw_r3d_rs_type) :: ca
707 : TYPE(realspace_grid_desc_type), POINTER :: rs_desc
708 : TYPE(realspace_grid_input_type) :: input_settings
709 32 : TYPE(realspace_grid_type) :: rs_grid
710 : TYPE(section_vals_type), POINTER :: rs_grid_section
711 :
712 2 : CALL timeset(routineN, handle)
713 :
714 : !..set fft lib
715 : CALL init_fft(globenv%default_fft_library, alltoall=.FALSE., &
716 : pool_limit=globenv%fft_pool_scratch_limit, &
717 : wisdom_file=globenv%fftw_wisdom_file_name, &
718 2 : plan_style=globenv%fftw_plan_type, status=status)
719 2 : IF (status /= 0) THEN
720 0 : CPABORT("Initialization of the FFT library failed!")
721 : END IF
722 :
723 : ! .. set cell (should otherwise be irrelevant)
724 2 : NULLIFY (box)
725 2 : CALL cell_create(box)
726 : box%hmat = RESHAPE([20.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 20.0_dp, 0.0_dp, &
727 26 : 0.0_dp, 0.0_dp, 20.0_dp], [3, 3])
728 2 : CALL init_cell(box)
729 :
730 : ! .. grid type and pw_grid
731 2 : NULLIFY (grid)
732 2 : CALL section_vals_val_get(rs_pw_transfer_section, "GRID", i_vals=i_vals)
733 8 : np = i_vals
734 2 : CALL pw_grid_create(grid, para_env, box%hmat, grid_span=FULLSPACE, npts=np, fft_usage=.TRUE., iounit=iw)
735 8 : no = grid%npts
736 :
737 2 : CALL ca%create(grid)
738 2 : CALL pw_zero(ca)
739 :
740 : ! .. rs input setting type
741 2 : CALL section_vals_val_get(rs_pw_transfer_section, "HALO_SIZE", i_val=halo_size)
742 2 : rs_grid_section => section_vals_get_subs_vals(rs_pw_transfer_section, "RS_GRID")
743 2 : ns_max = 2*halo_size + 1
744 2 : CALL init_input_type(input_settings, ns_max, rs_grid_section, 1, [-1, -1, -1])
745 :
746 : ! .. rs type
747 2 : NULLIFY (rs_desc)
748 2 : CALL rs_grid_create_descriptor(rs_desc, pw_grid=grid, input_settings=input_settings)
749 2 : CALL rs_grid_create(rs_grid, rs_desc)
750 2 : CALL rs_grid_print(rs_grid, iw)
751 2 : CALL rs_grid_zero(rs_grid)
752 :
753 : ! Put random values on the grid, so summation check will pick up errors
754 2 : CALL RANDOM_NUMBER(rs_grid%r)
755 :
756 2 : CALL section_vals_val_get(rs_pw_transfer_section, "N_loop", i_val=N_loop)
757 2 : CALL section_vals_val_get(rs_pw_transfer_section, "RS2PW", l_val=do_rs2pw)
758 :
759 : ! go for the real loops, sync to get max timings
760 2 : IF (para_env%is_source()) THEN
761 1 : WRITE (iw, '(T2,A)') ""
762 1 : WRITE (iw, '(T2,A)') "Timing rs_pw_transfer routine"
763 1 : WRITE (iw, '(T2,A)') ""
764 1 : WRITE (iw, '(T2,A)') "iteration time[s]"
765 : END IF
766 8 : DO i_loop = 1, N_loop
767 6 : CALL para_env%sync()
768 6 : tstart = m_walltime()
769 6 : IF (do_rs2pw) THEN
770 6 : CALL transfer_rs2pw(rs_grid, ca)
771 : ELSE
772 0 : CALL transfer_pw2rs(rs_grid, ca)
773 : END IF
774 6 : CALL para_env%sync()
775 6 : tend = m_walltime()
776 8 : IF (para_env%is_source()) THEN
777 3 : WRITE (iw, '(T2,I9,1X,F12.6)') i_loop, tend - tstart
778 : END IF
779 : END DO
780 :
781 : !cleanup
782 2 : CALL rs_grid_release(rs_grid)
783 2 : CALL rs_grid_release_descriptor(rs_desc)
784 2 : CALL ca%release()
785 2 : CALL pw_grid_release(grid)
786 2 : CALL cell_release(box)
787 2 : CALL finalize_fft(globenv%fftw_wisdom_file_name)
788 :
789 2 : CALL timestop(handle)
790 :
791 10 : END SUBROUTINE rs_pw_transfer_test
792 :
793 : ! **************************************************************************************************
794 : !> \brief Tests the performance of PW calls to FFT routines
795 : !> \param para_env ...
796 : !> \param iw ...
797 : !> \param globenv ...
798 : !> \param pw_transfer_section ...
799 : !> \par History
800 : !> JGH 6-Feb-2001 : Test and performance code
801 : !> Made input sensitive [Joost VandeVondele]
802 : !> \author JGH 1-JAN-2001
803 : ! **************************************************************************************************
804 10 : SUBROUTINE pw_fft_test(para_env, iw, globenv, pw_transfer_section)
805 :
806 : TYPE(mp_para_env_type), POINTER :: para_env
807 : INTEGER :: iw
808 : TYPE(global_environment_type), POINTER :: globenv
809 : TYPE(section_vals_type), POINTER :: pw_transfer_section
810 :
811 : REAL(KIND=dp), PARAMETER :: toler = 1.e-11_dp
812 :
813 : INTEGER :: blocked_id, grid_span, i_layout, i_rep, &
814 : ig, ip, itmp, n_loop, n_rep, nn, p, q, &
815 : status
816 10 : INTEGER, ALLOCATABLE, DIMENSION(:, :) :: layouts
817 : INTEGER, DIMENSION(2) :: distribution_layout
818 : INTEGER, DIMENSION(3) :: no, np
819 10 : INTEGER, DIMENSION(:), POINTER :: i_vals
820 : LOGICAL :: debug, is_fullspace, odd, &
821 : pw_grid_layout_all, spherical
822 : REAL(KIND=dp) :: em, et, flops, gsq, perf, t, t_max, &
823 : t_min, tend, tstart
824 10 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: t_end, t_start
825 : TYPE(cell_type), POINTER :: box
826 : TYPE(pw_c1d_gs_type) :: ca, cc
827 : TYPE(pw_c3d_rs_type) :: cb
828 : TYPE(pw_grid_type), POINTER :: grid
829 :
830 : !..set fft lib
831 :
832 : CALL init_fft(globenv%default_fft_library, alltoall=.FALSE., &
833 : pool_limit=globenv%fft_pool_scratch_limit, &
834 : wisdom_file=globenv%fftw_wisdom_file_name, &
835 10 : plan_style=globenv%fftw_plan_type, status=status)
836 10 : IF (status /= 0) THEN
837 0 : CPABORT("Initialization of the FFT library failed!")
838 : END IF
839 :
840 : !..the unit cell (should not really matter, the number of grid points do)
841 10 : NULLIFY (box, grid)
842 10 : CALL cell_create(box)
843 : box%hmat = RESHAPE([10.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 8.0_dp, 0.0_dp, &
844 130 : 0.0_dp, 0.0_dp, 7.0_dp], [3, 3])
845 10 : CALL init_cell(box)
846 :
847 10 : CALL section_vals_get(pw_transfer_section, n_repetition=n_rep)
848 70 : DO i_rep = 1, n_rep
849 :
850 : ! how often should we do the transfer
851 60 : CALL section_vals_val_get(pw_transfer_section, "N_loop", i_rep_section=i_rep, i_val=N_loop)
852 180 : ALLOCATE (t_start(N_loop))
853 120 : ALLOCATE (t_end(N_loop))
854 :
855 : ! setup of the grids
856 60 : CALL section_vals_val_get(pw_transfer_section, "GRID", i_rep_section=i_rep, i_vals=i_vals)
857 240 : np = i_vals
858 :
859 60 : CALL section_vals_val_get(pw_transfer_section, "PW_GRID_BLOCKED", i_rep_section=i_rep, i_val=blocked_id)
860 60 : CALL section_vals_val_get(pw_transfer_section, "DEBUG", i_rep_section=i_rep, l_val=debug)
861 :
862 : CALL section_vals_val_get(pw_transfer_section, "PW_GRID_LAYOUT_ALL", i_rep_section=i_rep, &
863 60 : l_val=pw_grid_layout_all)
864 :
865 : ! prepare to loop over all or a specific layout
866 60 : IF (pw_grid_layout_all) THEN
867 : ! count layouts that fit
868 8 : itmp = 0
869 : ! start from 2, (/1,para_env%num_pe/) is not supported
870 16 : DO p = 2, para_env%num_pe
871 8 : q = para_env%num_pe/p
872 16 : IF (p*q == para_env%num_pe) THEN
873 8 : itmp = itmp + 1
874 : END IF
875 : END DO
876 : ! build list
877 24 : ALLOCATE (layouts(2, itmp))
878 8 : itmp = 0
879 16 : DO p = 2, para_env%num_pe
880 8 : q = para_env%num_pe/p
881 16 : IF (p*q == para_env%num_pe) THEN
882 8 : itmp = itmp + 1
883 24 : layouts(:, itmp) = [p, q]
884 : END IF
885 : END DO
886 : ELSE
887 52 : CALL section_vals_val_get(pw_transfer_section, "PW_GRID_LAYOUT", i_rep_section=i_rep, i_vals=i_vals)
888 52 : ALLOCATE (layouts(2, 1))
889 156 : layouts(:, 1) = i_vals
890 : END IF
891 :
892 120 : DO i_layout = 1, SIZE(layouts, 2)
893 :
894 180 : distribution_layout = layouts(:, i_layout)
895 :
896 60 : CALL section_vals_val_get(pw_transfer_section, "PW_GRID", i_rep_section=i_rep, i_val=itmp)
897 :
898 : ! from cp_control_utils
899 16 : SELECT CASE (itmp)
900 : CASE (do_pwgrid_spherical)
901 16 : spherical = .TRUE.
902 16 : is_fullspace = .FALSE.
903 : CASE (do_pwgrid_ns_fullspace)
904 28 : spherical = .FALSE.
905 28 : is_fullspace = .TRUE.
906 : CASE (do_pwgrid_ns_halfspace)
907 16 : spherical = .FALSE.
908 60 : is_fullspace = .FALSE.
909 : END SELECT
910 :
911 : ! from pw_env_methods
912 60 : IF (spherical) THEN
913 16 : grid_span = HALFSPACE
914 16 : spherical = .TRUE.
915 16 : odd = .TRUE.
916 44 : ELSE IF (is_fullspace) THEN
917 28 : grid_span = FULLSPACE
918 28 : spherical = .FALSE.
919 28 : odd = .FALSE.
920 : ELSE
921 16 : grid_span = HALFSPACE
922 16 : spherical = .FALSE.
923 16 : odd = .TRUE.
924 : END IF
925 :
926 : ! actual setup
927 : CALL pw_grid_create(grid, para_env, box%hmat, grid_span=grid_span, odd=odd, spherical=spherical, &
928 : blocked=blocked_id, npts=np, fft_usage=.TRUE., &
929 60 : rs_dims=distribution_layout, iounit=iw)
930 :
931 60 : IF (iw > 0) CALL m_flush(iw)
932 :
933 : ! note that the number of grid points might be different from what the user requested (fft-able needed)
934 240 : no = grid%npts
935 :
936 60 : CALL ca%create(grid)
937 60 : CALL cb%create(grid)
938 60 : CALL cc%create(grid)
939 :
940 : ! initialize data
941 60 : CALL pw_zero(ca)
942 60 : CALL pw_zero(cb)
943 60 : CALL pw_zero(cc)
944 60 : nn = SIZE(ca%array)
945 142042 : DO ig = 1, nn
946 141982 : gsq = grid%gsq(ig)
947 142042 : ca%array(ig) = EXP(-gsq)
948 : END DO
949 :
950 420 : flops = PRODUCT(no)*30.0_dp*LOG(REAL(MAXVAL(no), KIND=dp))
951 60 : tstart = m_walltime()
952 596 : DO ip = 1, n_loop
953 536 : CALL para_env%sync()
954 536 : t_start(ip) = m_walltime()
955 536 : CALL pw_transfer(ca, cb, debug)
956 536 : CALL pw_transfer(cb, cc, debug)
957 536 : CALL para_env%sync()
958 596 : t_end(ip) = m_walltime()
959 : END DO
960 60 : tend = m_walltime()
961 60 : t = tend - tstart + threshold
962 60 : IF (t > 0.0_dp) THEN
963 60 : perf = REAL(n_loop, KIND=dp)*2.0_dp*flops*1.e-6_dp/t
964 : ELSE
965 0 : perf = 0.0_dp
966 : END IF
967 :
968 142042 : em = MAXVAL(ABS(ca%array(:) - cc%array(:)))
969 60 : CALL para_env%max(em)
970 142042 : et = SUM(ABS(ca%array(:) - cc%array(:)))
971 60 : CALL para_env%sum(et)
972 596 : t_min = MINVAL(t_end - t_start)
973 596 : t_max = MAXVAL(t_end - t_start)
974 :
975 60 : IF (para_env%is_source()) THEN
976 30 : WRITE (iw, *)
977 30 : WRITE (iw, '(A,T67,E14.6)') " Parallel FFT Tests: Maximal Error ", em
978 30 : WRITE (iw, '(A,T67,E14.6)') " Parallel FFT Tests: Total Error ", et
979 : WRITE (iw, '(A,T67,F14.0)') &
980 30 : " Parallel FFT Tests: Performance [Mflops] ", perf
981 30 : WRITE (iw, '(A,T67,F14.6)') " Best time : ", t_min
982 30 : WRITE (iw, '(A,T67,F14.6)') " Worst time: ", t_max
983 30 : IF (iw > 0) CALL m_flush(iw)
984 : END IF
985 :
986 : ! need debugging ???
987 60 : IF (em > toler .OR. et > toler) THEN
988 0 : CPWARN("The FFT results are not accurate ... starting debug pw_transfer")
989 0 : CALL pw_transfer(ca, cb, .TRUE.)
990 0 : CALL pw_transfer(cb, cc, .TRUE.)
991 : END IF
992 :
993 : ! done with these grids
994 60 : CALL ca%release()
995 60 : CALL cb%release()
996 60 : CALL cc%release()
997 180 : CALL pw_grid_release(grid)
998 :
999 : END DO
1000 :
1001 : ! local arrays
1002 60 : DEALLOCATE (layouts)
1003 60 : DEALLOCATE (t_start)
1004 190 : DEALLOCATE (t_end)
1005 :
1006 : END DO
1007 :
1008 : ! cleanup
1009 10 : CALL cell_release(box)
1010 10 : CALL finalize_fft(globenv%fftw_wisdom_file_name)
1011 :
1012 20 : END SUBROUTINE pw_fft_test
1013 :
1014 : ! **************************************************************************************************
1015 : !> \brief Tests the eigensolver library routines
1016 : !> \param para_env ...
1017 : !> \param iw ...
1018 : !> \param eigensolver_section ...
1019 : !> \par History
1020 : !> JGH 6-Feb-2001 : Test and performance code
1021 : !> \author JGH 1-JAN-2001
1022 : ! **************************************************************************************************
1023 2 : SUBROUTINE eigensolver_test(para_env, iw, eigensolver_section)
1024 :
1025 : TYPE(mp_para_env_type), POINTER :: para_env
1026 : INTEGER :: iw
1027 : TYPE(section_vals_type), POINTER :: eigensolver_section
1028 :
1029 : INTEGER :: diag_method, i, i_loop, i_rep, &
1030 : init_method, j, n, n_loop, n_rep, &
1031 : neig, unit_number
1032 : REAL(KIND=dp) :: t1, t2
1033 2 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: eigenvalues
1034 2 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: buffer
1035 : TYPE(cp_blacs_env_type), POINTER :: blacs_env
1036 : TYPE(cp_fm_struct_type), POINTER :: fmstruct
1037 : TYPE(cp_fm_type) :: eigenvectors, matrix, work
1038 2 : TYPE(rng_stream_type), ALLOCATABLE :: rng_stream
1039 :
1040 2 : IF (iw > 0) THEN
1041 1 : WRITE (UNIT=iw, FMT="(/,/,T2,A,/)") "EIGENSOLVER TEST"
1042 : END IF
1043 :
1044 : ! create blacs env corresponding to para_env
1045 2 : NULLIFY (blacs_env)
1046 : CALL cp_blacs_env_create(blacs_env=blacs_env, &
1047 2 : para_env=para_env)
1048 :
1049 : ! loop over all tests
1050 2 : CALL section_vals_get(eigensolver_section, n_repetition=n_rep)
1051 10 : DO i_rep = 1, n_rep
1052 :
1053 : ! parse section
1054 8 : CALL section_vals_val_get(eigensolver_section, "N", i_rep_section=i_rep, i_val=n)
1055 8 : CALL section_vals_val_get(eigensolver_section, "EIGENVALUES", i_rep_section=i_rep, i_val=neig)
1056 8 : CALL section_vals_val_get(eigensolver_section, "DIAG_METHOD", i_rep_section=i_rep, i_val=diag_method)
1057 8 : CALL section_vals_val_get(eigensolver_section, "INIT_METHOD", i_rep_section=i_rep, i_val=init_method)
1058 8 : CALL section_vals_val_get(eigensolver_section, "N_loop", i_rep_section=i_rep, i_val=n_loop)
1059 :
1060 : ! proper number of eigs
1061 8 : IF (neig < 0) neig = n
1062 8 : neig = MIN(neig, n)
1063 :
1064 : ! report
1065 8 : IF (iw > 0) THEN
1066 4 : WRITE (iw, *) "Matrix size", n
1067 4 : WRITE (iw, *) "Number of eigenvalues", neig
1068 4 : WRITE (iw, *) "Timing loops", n_loop
1069 2 : SELECT CASE (diag_method)
1070 : CASE (do_diag_syevd)
1071 2 : WRITE (iw, *) "Diag using syevd"
1072 : CASE (do_diag_syevx)
1073 4 : WRITE (iw, *) "Diag using syevx"
1074 : CASE DEFAULT
1075 : ! stop
1076 : END SELECT
1077 :
1078 4 : SELECT CASE (init_method)
1079 : CASE (do_mat_random)
1080 4 : WRITE (iw, *) "using random matrix"
1081 : CASE (do_mat_read)
1082 4 : WRITE (iw, *) "reading from file"
1083 : CASE DEFAULT
1084 : ! stop
1085 : END SELECT
1086 : END IF
1087 :
1088 : ! create matrix struct type
1089 8 : NULLIFY (fmstruct)
1090 : CALL cp_fm_struct_create(fmstruct=fmstruct, &
1091 : para_env=para_env, &
1092 : context=blacs_env, &
1093 : nrow_global=n, &
1094 8 : ncol_global=n)
1095 :
1096 : ! create all needed matrices, and buffers for the eigenvalues
1097 : CALL cp_fm_create(matrix=matrix, &
1098 : matrix_struct=fmstruct, &
1099 8 : name="MATRIX")
1100 8 : CALL cp_fm_set_all(matrix, 0.0_dp)
1101 :
1102 : CALL cp_fm_create(matrix=eigenvectors, &
1103 : matrix_struct=fmstruct, &
1104 8 : name="EIGENVECTORS")
1105 8 : CALL cp_fm_set_all(eigenvectors, 0.0_dp)
1106 :
1107 : CALL cp_fm_create(matrix=work, &
1108 : matrix_struct=fmstruct, &
1109 8 : name="WORK")
1110 8 : CALL cp_fm_set_all(matrix, 0.0_dp)
1111 :
1112 24 : ALLOCATE (eigenvalues(n))
1113 8 : eigenvalues = 0.0_dp
1114 16 : ALLOCATE (buffer(1, n))
1115 :
1116 : ! generate initial matrix, either by reading a file, or using random numbers
1117 8 : IF (para_env%is_source()) THEN
1118 4 : SELECT CASE (init_method)
1119 : CASE (do_mat_random)
1120 : rng_stream = rng_stream_type( &
1121 : name="rng_stream", &
1122 : distribution_type=UNIFORM, &
1123 4 : extended_precision=.TRUE.)
1124 : CASE (do_mat_read)
1125 : CALL open_file(file_name="MATRIX", &
1126 : file_action="READ", &
1127 : file_form="FORMATTED", &
1128 : file_status="OLD", &
1129 4 : unit_number=unit_number)
1130 : END SELECT
1131 : END IF
1132 :
1133 100 : DO i = 1, n
1134 92 : IF (para_env%is_source()) THEN
1135 : SELECT CASE (init_method)
1136 : CASE (do_mat_random)
1137 347 : DO j = i, n
1138 347 : buffer(1, j) = rng_stream%next() - 0.5_dp
1139 : END DO
1140 : !MK activate/modify for a diagonal dominant symmetric matrix:
1141 : !MK buffer(1,i) = 10.0_dp*buffer(1,i)
1142 : CASE (do_mat_read)
1143 46 : READ (UNIT=unit_number, FMT=*) buffer(1, 1:n)
1144 : END SELECT
1145 : END IF
1146 92 : CALL para_env%bcast(buffer)
1147 8 : SELECT CASE (init_method)
1148 : CASE (do_mat_random)
1149 : CALL cp_fm_set_submatrix(fm=matrix, &
1150 : new_values=buffer, &
1151 : start_row=i, &
1152 : start_col=i, &
1153 : n_rows=1, &
1154 : n_cols=n - i + 1, &
1155 : alpha=1.0_dp, &
1156 : beta=0.0_dp, &
1157 92 : transpose=.FALSE.)
1158 : CALL cp_fm_set_submatrix(fm=matrix, &
1159 : new_values=buffer, &
1160 : start_row=i, &
1161 : start_col=i, &
1162 : n_rows=n - i + 1, &
1163 : n_cols=1, &
1164 : alpha=1.0_dp, &
1165 : beta=0.0_dp, &
1166 92 : transpose=.TRUE.)
1167 : CASE (do_mat_read)
1168 : CALL cp_fm_set_submatrix(fm=matrix, &
1169 : new_values=buffer, &
1170 : start_row=i, &
1171 : start_col=1, &
1172 : n_rows=1, &
1173 : n_cols=n, &
1174 : alpha=1.0_dp, &
1175 : beta=0.0_dp, &
1176 92 : transpose=.FALSE.)
1177 : END SELECT
1178 : END DO
1179 :
1180 8 : DEALLOCATE (buffer)
1181 :
1182 8 : IF (para_env%is_source()) THEN
1183 0 : SELECT CASE (init_method)
1184 : CASE (do_mat_read)
1185 4 : CALL close_file(unit_number=unit_number)
1186 : END SELECT
1187 : END IF
1188 :
1189 88 : DO i_loop = 1, n_loop
1190 80 : eigenvalues = 0.0_dp
1191 80 : CALL cp_fm_set_all(eigenvectors, 0.0_dp)
1192 : CALL cp_fm_to_fm(source=matrix, &
1193 80 : destination=work)
1194 :
1195 : ! DONE, now testing
1196 80 : t1 = m_walltime()
1197 40 : SELECT CASE (diag_method)
1198 : CASE (do_diag_syevd)
1199 : CALL cp_fm_syevd(matrix=work, &
1200 : eigenvectors=eigenvectors, &
1201 40 : eigenvalues=eigenvalues)
1202 : CASE (do_diag_syevx)
1203 : CALL cp_fm_syevx(matrix=work, &
1204 : eigenvectors=eigenvectors, &
1205 : eigenvalues=eigenvalues, &
1206 : neig=neig, &
1207 80 : work_syevx=1.0_dp)
1208 : END SELECT
1209 80 : t2 = m_walltime()
1210 88 : IF (iw > 0) WRITE (iw, *) "Timing for loop ", i_loop, " : ", t2 - t1
1211 : END DO
1212 :
1213 8 : IF (iw > 0) THEN
1214 4 : WRITE (iw, *) "Eigenvalues: "
1215 4 : WRITE (UNIT=iw, FMT="(T3,5F14.6)") eigenvalues(1:neig)
1216 42 : WRITE (UNIT=iw, FMT="(T3,A4,F16.6)") "Sum:", SUM(eigenvalues(1:neig))
1217 4 : WRITE (iw, *) ""
1218 : END IF
1219 :
1220 : ! Clean up
1221 8 : DEALLOCATE (eigenvalues)
1222 8 : CALL cp_fm_release(matrix=work)
1223 8 : CALL cp_fm_release(matrix=eigenvectors)
1224 8 : CALL cp_fm_release(matrix=matrix)
1225 42 : CALL cp_fm_struct_release(fmstruct=fmstruct)
1226 :
1227 : END DO
1228 :
1229 2 : CALL cp_blacs_env_release(blacs_env=blacs_env)
1230 :
1231 4 : END SUBROUTINE eigensolver_test
1232 :
1233 : ! **************************************************************************************************
1234 : !> \brief Tests the parallel matrix multiply
1235 : !> \param para_env ...
1236 : !> \param iw ...
1237 : !> \param cp_fm_gemm_test_section ...
1238 : ! **************************************************************************************************
1239 4 : SUBROUTINE cp_fm_gemm_test(para_env, iw, cp_fm_gemm_test_section)
1240 :
1241 : TYPE(mp_para_env_type), POINTER :: para_env
1242 : INTEGER :: iw
1243 : TYPE(section_vals_type), POINTER :: cp_fm_gemm_test_section
1244 :
1245 : CHARACTER(LEN=1) :: transa, transb
1246 : INTEGER :: i_loop, i_rep, k, m, n, N_loop, n_rep, ncol_block, ncol_block_actual, &
1247 : ncol_global, np, nrow_block, nrow_block_actual, nrow_global
1248 4 : INTEGER, DIMENSION(:), POINTER :: grid_2d
1249 : LOGICAL :: force_blocksize, row_major, transa_p, &
1250 : transb_p
1251 : REAL(KIND=dp) :: t1, t2, t3, t4
1252 : TYPE(cp_blacs_env_type), POINTER :: blacs_env
1253 : TYPE(cp_fm_struct_type), POINTER :: fmstruct_a, fmstruct_b, fmstruct_c
1254 : TYPE(cp_fm_type) :: matrix_a, matrix_b, matrix_c
1255 :
1256 4 : CALL section_vals_get(cp_fm_gemm_test_section, n_repetition=n_rep)
1257 24 : DO i_rep = 1, n_rep
1258 :
1259 : ! how often should we do the multiply
1260 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "N_loop", i_rep_section=i_rep, i_val=N_loop)
1261 :
1262 : ! matrices def.
1263 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "K", i_rep_section=i_rep, i_val=k)
1264 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "N", i_rep_section=i_rep, i_val=n)
1265 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "M", i_rep_section=i_rep, i_val=m)
1266 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "transa", i_rep_section=i_rep, l_val=transa_p)
1267 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "transb", i_rep_section=i_rep, l_val=transb_p)
1268 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "nrow_block", i_rep_section=i_rep, i_val=nrow_block)
1269 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "ncol_block", i_rep_section=i_rep, i_val=ncol_block)
1270 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "ROW_MAJOR", i_rep_section=i_rep, l_val=row_major)
1271 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "GRID_2D", i_rep_section=i_rep, i_vals=grid_2d)
1272 20 : CALL section_vals_val_get(cp_fm_gemm_test_section, "FORCE_BLOCKSIZE", i_rep_section=i_rep, l_val=force_blocksize)
1273 20 : transa = "N"
1274 20 : transb = "N"
1275 20 : IF (transa_p) transa = "T"
1276 20 : IF (transb_p) transb = "T"
1277 :
1278 20 : IF (iw > 0) THEN
1279 10 : WRITE (iw, '(T2,A)') "----------- TESTING PARALLEL MATRIX MULTIPLY -------------"
1280 10 : WRITE (iw, '(T2,A)', ADVANCE="NO") "C = "
1281 10 : IF (transa_p) THEN
1282 2 : WRITE (iw, '(A)', ADVANCE="NO") "TRANSPOSE(A) x"
1283 : ELSE
1284 8 : WRITE (iw, '(A)', ADVANCE="NO") "A x "
1285 : END IF
1286 10 : IF (transb_p) THEN
1287 2 : WRITE (iw, '(A)') "TRANSPOSE(B) "
1288 : ELSE
1289 8 : WRITE (iw, '(A)') "B "
1290 : END IF
1291 10 : WRITE (iw, '(T2,A,T50,I5,A,I5)') 'requested block size', nrow_block, ' by ', ncol_block
1292 10 : WRITE (iw, '(T2,A,T50,I5)') 'number of repetitions of cp_fm_gemm ', n_loop
1293 10 : WRITE (iw, '(T2,A,T50,L5)') 'Row Major', row_major
1294 30 : WRITE (iw, '(T2,A,T50,2I7)') 'GRID_2D ', grid_2d
1295 10 : WRITE (iw, '(T2,A,T50,L5)') 'Force blocksize ', force_blocksize
1296 : ! check the return value of pilaenv, too small values limit the performance (assuming pdgemm is the vanilla variant)
1297 10 : np = cp_fm_pilaenv(0, 'D')
1298 10 : IF (np > 0) THEN
1299 10 : WRITE (iw, '(T2,A,T50,I5)') 'PILAENV blocksize', np
1300 : END IF
1301 : END IF
1302 :
1303 20 : NULLIFY (blacs_env)
1304 : CALL cp_blacs_env_create(blacs_env=blacs_env, &
1305 : para_env=para_env, &
1306 : row_major=row_major, &
1307 20 : grid_2d=grid_2d)
1308 :
1309 20 : NULLIFY (fmstruct_a)
1310 20 : IF (transa_p) THEN
1311 4 : nrow_global = m; ncol_global = k
1312 : ELSE
1313 16 : nrow_global = k; ncol_global = m
1314 : END IF
1315 : CALL cp_fm_struct_create(fmstruct=fmstruct_a, para_env=para_env, context=blacs_env, &
1316 : nrow_global=nrow_global, ncol_global=ncol_global, &
1317 20 : nrow_block=nrow_block, ncol_block=ncol_block, force_block=force_blocksize)
1318 20 : CALL cp_fm_struct_get(fmstruct_a, nrow_block=nrow_block_actual, ncol_block=ncol_block_actual)
1319 30 : IF (iw > 0) WRITE (iw, '(T2,A,I9,A,I9,A,I5,A,I5)') 'matrix A ', nrow_global, " by ", ncol_global, &
1320 20 : ' using blocks of ', nrow_block_actual, ' by ', ncol_block_actual
1321 :
1322 20 : IF (transb_p) THEN
1323 4 : nrow_global = n; ncol_global = m
1324 : ELSE
1325 16 : nrow_global = m; ncol_global = n
1326 : END IF
1327 20 : NULLIFY (fmstruct_b)
1328 : CALL cp_fm_struct_create(fmstruct=fmstruct_b, para_env=para_env, context=blacs_env, &
1329 : nrow_global=nrow_global, ncol_global=ncol_global, &
1330 20 : nrow_block=nrow_block, ncol_block=ncol_block, force_block=force_blocksize)
1331 20 : CALL cp_fm_struct_get(fmstruct_b, nrow_block=nrow_block_actual, ncol_block=ncol_block_actual)
1332 30 : IF (iw > 0) WRITE (iw, '(T2,A,I9,A,I9,A,I5,A,I5)') 'matrix B ', nrow_global, " by ", ncol_global, &
1333 20 : ' using blocks of ', nrow_block_actual, ' by ', ncol_block_actual
1334 :
1335 20 : NULLIFY (fmstruct_c)
1336 20 : nrow_global = k
1337 20 : ncol_global = n
1338 : CALL cp_fm_struct_create(fmstruct=fmstruct_c, para_env=para_env, context=blacs_env, &
1339 : nrow_global=nrow_global, ncol_global=ncol_global, &
1340 20 : nrow_block=nrow_block, ncol_block=ncol_block, force_block=force_blocksize)
1341 20 : CALL cp_fm_struct_get(fmstruct_c, nrow_block=nrow_block_actual, ncol_block=ncol_block_actual)
1342 30 : IF (iw > 0) WRITE (iw, '(T2,A,I9,A,I9,A,I5,A,I5)') 'matrix C ', nrow_global, " by ", ncol_global, &
1343 20 : ' using blocks of ', nrow_block_actual, ' by ', ncol_block_actual
1344 :
1345 20 : CALL cp_fm_create(matrix=matrix_a, matrix_struct=fmstruct_a, name="MATRIX A")
1346 20 : CALL cp_fm_create(matrix=matrix_b, matrix_struct=fmstruct_b, name="MATRIX B")
1347 20 : CALL cp_fm_create(matrix=matrix_c, matrix_struct=fmstruct_c, name="MATRIX C")
1348 :
1349 20 : CALL RANDOM_NUMBER(matrix_a%local_data)
1350 20 : CALL RANDOM_NUMBER(matrix_b%local_data)
1351 20 : CALL RANDOM_NUMBER(matrix_c%local_data)
1352 :
1353 20 : IF (iw > 0) CALL m_flush(iw)
1354 :
1355 20 : t1 = m_walltime()
1356 932 : DO i_loop = 1, N_loop
1357 912 : t3 = m_walltime()
1358 912 : CALL parallel_gemm(transa, transb, k, n, m, 1.0_dp, matrix_a, matrix_b, 0.0_dp, matrix_c)
1359 912 : t4 = m_walltime()
1360 932 : IF (iw > 0) THEN
1361 456 : WRITE (iw, '(T2,A,T50,F12.6)') "cp_fm_gemm timing: ", (t4 - t3)
1362 456 : CALL m_flush(iw)
1363 : END IF
1364 : END DO
1365 20 : t2 = m_walltime()
1366 :
1367 20 : IF (iw > 0) THEN
1368 10 : WRITE (iw, '(T2,A,T50,F12.6)') "average cp_fm_gemm timing: ", (t2 - t1)/N_loop
1369 10 : IF (t2 > t1) THEN
1370 10 : WRITE (iw, '(T2,A,T50,F12.6)') "cp_fm_gemm Gflops per MPI task: ", &
1371 20 : 2*REAL(m, kind=dp)*REAL(n, kind=dp)*REAL(k, kind=dp)*N_loop/MAX(0.001_dp, t2 - t1)/1.0E9_dp/para_env%num_pe
1372 : END IF
1373 : END IF
1374 :
1375 20 : CALL cp_fm_release(matrix=matrix_a)
1376 20 : CALL cp_fm_release(matrix=matrix_b)
1377 20 : CALL cp_fm_release(matrix=matrix_c)
1378 20 : CALL cp_fm_struct_release(fmstruct=fmstruct_a)
1379 20 : CALL cp_fm_struct_release(fmstruct=fmstruct_b)
1380 20 : CALL cp_fm_struct_release(fmstruct=fmstruct_c)
1381 144 : CALL cp_blacs_env_release(blacs_env=blacs_env)
1382 :
1383 : END DO
1384 :
1385 4 : END SUBROUTINE cp_fm_gemm_test
1386 :
1387 : ! **************************************************************************************************
1388 : !> \brief Tests the DBCSR interface.
1389 : !> \param para_env ...
1390 : !> \param iw ...
1391 : !> \param input_section ...
1392 : ! **************************************************************************************************
1393 32 : SUBROUTINE cp_dbcsr_tests(para_env, iw, input_section)
1394 :
1395 : TYPE(mp_para_env_type), POINTER :: para_env
1396 : INTEGER :: iw
1397 : TYPE(section_vals_type), POINTER :: input_section
1398 :
1399 : CHARACTER, DIMENSION(3) :: types
1400 : INTEGER :: data_type, i_rep, k, m, n, N_loop, &
1401 : n_rep, test_type
1402 32 : INTEGER, DIMENSION(:), POINTER :: bs_k, bs_m, bs_n, nproc
1403 : LOGICAL :: always_checksum, retain_sparsity, &
1404 : transa_p, transb_p
1405 : REAL(KIND=dp) :: alpha, beta, filter_eps, s_a, s_b, s_c
1406 :
1407 : ! ---------------------------------------------------------------------------
1408 :
1409 32 : NULLIFY (bs_m, bs_n, bs_k)
1410 32 : CALL section_vals_get(input_section, n_repetition=n_rep)
1411 32 : CALL dbcsr_reset_randmat_seed()
1412 78 : DO i_rep = 1, n_rep
1413 : ! how often should we do the multiply
1414 46 : CALL section_vals_val_get(input_section, "N_loop", i_rep_section=i_rep, i_val=N_loop)
1415 :
1416 : ! matrices def.
1417 46 : CALL section_vals_val_get(input_section, "TEST_TYPE", i_rep_section=i_rep, i_val=test_type)
1418 46 : CALL section_vals_val_get(input_section, "DATA_TYPE", i_rep_section=i_rep, i_val=data_type)
1419 46 : CALL section_vals_val_get(input_section, "K", i_rep_section=i_rep, i_val=k)
1420 46 : CALL section_vals_val_get(input_section, "N", i_rep_section=i_rep, i_val=n)
1421 46 : CALL section_vals_val_get(input_section, "M", i_rep_section=i_rep, i_val=m)
1422 46 : CALL section_vals_val_get(input_section, "transa", i_rep_section=i_rep, l_val=transa_p)
1423 46 : CALL section_vals_val_get(input_section, "transb", i_rep_section=i_rep, l_val=transb_p)
1424 : CALL section_vals_val_get(input_section, "bs_m", i_rep_section=i_rep, &
1425 46 : i_vals=bs_m)
1426 : CALL section_vals_val_get(input_section, "bs_n", i_rep_section=i_rep, &
1427 46 : i_vals=bs_n)
1428 : CALL section_vals_val_get(input_section, "bs_k", i_rep_section=i_rep, &
1429 46 : i_vals=bs_k)
1430 46 : CALL section_vals_val_get(input_section, "keepsparse", i_rep_section=i_rep, l_val=retain_sparsity)
1431 46 : CALL section_vals_val_get(input_section, "asparsity", i_rep_section=i_rep, r_val=s_a)
1432 46 : CALL section_vals_val_get(input_section, "bsparsity", i_rep_section=i_rep, r_val=s_b)
1433 46 : CALL section_vals_val_get(input_section, "csparsity", i_rep_section=i_rep, r_val=s_c)
1434 46 : CALL section_vals_val_get(input_section, "alpha", i_rep_section=i_rep, r_val=alpha)
1435 46 : CALL section_vals_val_get(input_section, "beta", i_rep_section=i_rep, r_val=beta)
1436 : CALL section_vals_val_get(input_section, "nproc", i_rep_section=i_rep, &
1437 46 : i_vals=nproc)
1438 : CALL section_vals_val_get(input_section, "atype", i_rep_section=i_rep, &
1439 46 : c_val=types(1))
1440 : CALL section_vals_val_get(input_section, "btype", i_rep_section=i_rep, &
1441 46 : c_val=types(2))
1442 : CALL section_vals_val_get(input_section, "ctype", i_rep_section=i_rep, &
1443 46 : c_val=types(3))
1444 : CALL section_vals_val_get(input_section, "filter_eps", &
1445 46 : i_rep_section=i_rep, r_val=filter_eps)
1446 46 : CALL section_vals_val_get(input_section, "ALWAYS_CHECKSUM", i_rep_section=i_rep, l_val=always_checksum)
1447 :
1448 : CALL dbcsr_run_tests(para_env%get_handle(), iw, nproc, &
1449 : [m, n, k], &
1450 : [transa_p, transb_p], &
1451 : bs_m, bs_n, bs_k, &
1452 : [s_a, s_b, s_c], &
1453 : alpha, beta, &
1454 : data_type=data_type, &
1455 : test_type=test_type, &
1456 : n_loops=n_loop, eps=filter_eps, retain_sparsity=retain_sparsity, &
1457 538 : always_checksum=always_checksum)
1458 : END DO
1459 32 : END SUBROUTINE cp_dbcsr_tests
1460 :
1461 : ! **************************************************************************************************
1462 : !> \brief Tests the DBM library.
1463 : !> \param para_env ...
1464 : !> \param iw ...
1465 : !> \param input_section ...
1466 : ! **************************************************************************************************
1467 14 : SUBROUTINE run_dbm_tests(para_env, iw, input_section)
1468 :
1469 : TYPE(mp_para_env_type), POINTER :: para_env
1470 : INTEGER :: iw
1471 : TYPE(section_vals_type), POINTER :: input_section
1472 :
1473 : INTEGER :: i_rep, k, m, n, N_loop, n_rep
1474 14 : INTEGER, DIMENSION(:), POINTER :: bs_k, bs_m, bs_n
1475 : LOGICAL :: always_checksum, retain_sparsity, &
1476 : transa_p, transb_p
1477 : REAL(KIND=dp) :: alpha, beta, filter_eps, s_a, s_b, s_c
1478 :
1479 : ! ---------------------------------------------------------------------------
1480 :
1481 14 : NULLIFY (bs_m, bs_n, bs_k)
1482 14 : CALL section_vals_get(input_section, n_repetition=n_rep)
1483 14 : CALL dbcsr_reset_randmat_seed()
1484 28 : DO i_rep = 1, n_rep
1485 14 : CALL section_vals_val_get(input_section, "N_loop", i_rep_section=i_rep, i_val=N_loop)
1486 14 : CALL section_vals_val_get(input_section, "K", i_rep_section=i_rep, i_val=k)
1487 14 : CALL section_vals_val_get(input_section, "N", i_rep_section=i_rep, i_val=n)
1488 14 : CALL section_vals_val_get(input_section, "M", i_rep_section=i_rep, i_val=m)
1489 14 : CALL section_vals_val_get(input_section, "transa", i_rep_section=i_rep, l_val=transa_p)
1490 14 : CALL section_vals_val_get(input_section, "transb", i_rep_section=i_rep, l_val=transb_p)
1491 14 : CALL section_vals_val_get(input_section, "bs_m", i_rep_section=i_rep, i_vals=bs_m)
1492 14 : CALL section_vals_val_get(input_section, "bs_n", i_rep_section=i_rep, i_vals=bs_n)
1493 14 : CALL section_vals_val_get(input_section, "bs_k", i_rep_section=i_rep, i_vals=bs_k)
1494 14 : CALL section_vals_val_get(input_section, "keepsparse", i_rep_section=i_rep, l_val=retain_sparsity)
1495 14 : CALL section_vals_val_get(input_section, "asparsity", i_rep_section=i_rep, r_val=s_a)
1496 14 : CALL section_vals_val_get(input_section, "bsparsity", i_rep_section=i_rep, r_val=s_b)
1497 14 : CALL section_vals_val_get(input_section, "csparsity", i_rep_section=i_rep, r_val=s_c)
1498 14 : CALL section_vals_val_get(input_section, "alpha", i_rep_section=i_rep, r_val=alpha)
1499 14 : CALL section_vals_val_get(input_section, "beta", i_rep_section=i_rep, r_val=beta)
1500 14 : CALL section_vals_val_get(input_section, "filter_eps", i_rep_section=i_rep, r_val=filter_eps)
1501 14 : CALL section_vals_val_get(input_section, "ALWAYS_CHECKSUM", i_rep_section=i_rep, l_val=always_checksum)
1502 :
1503 : CALL dbm_run_tests(mp_group=para_env, &
1504 : io_unit=iw, &
1505 : matrix_sizes=[m, n, k], &
1506 : trs=[transa_p, transb_p], &
1507 : bs_m=bs_m, &
1508 : bs_n=bs_n, &
1509 : bs_k=bs_k, &
1510 : sparsities=[s_a, s_b, s_c], &
1511 : alpha=alpha, &
1512 : beta=beta, &
1513 : n_loops=n_loop, &
1514 : eps=filter_eps, &
1515 : retain_sparsity=retain_sparsity, &
1516 154 : always_checksum=always_checksum)
1517 : END DO
1518 14 : END SUBROUTINE run_dbm_tests
1519 :
1520 8484 : END MODULE library_tests
|