Guess the size of the product matrix from the A and B sparsities
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dbcsr_type), | intent(in) | :: | matrix_left | |||
type(dbcsr_type), | intent(in) | :: | matrix_right | |||
type(dbcsr_type), | intent(in) | :: | product_matrix | |||
integer, | intent(in) | :: | left_data_size | |||
integer, | intent(in) | :: | right_data_size | |||
integer, | intent(in) | :: | left_col_nimages | |||
integer, | intent(in) | :: | right_row_nimages | |||
integer, | intent(in) | :: | nthreads |
FUNCTION product_matrix_size_guess(matrix_left, matrix_right, product_matrix, & !! Guess the size of the product matrix from the A and B sparsities left_data_size, right_data_size, & left_col_nimages, right_row_nimages, & nthreads) RESULT(size_guess) TYPE(dbcsr_type), INTENT(IN) :: matrix_left, matrix_right, product_matrix INTEGER, INTENT(IN) :: left_data_size, right_data_size, & left_col_nimages, right_row_nimages, & nthreads INTEGER :: size_guess INTEGER(KIND=int_8) :: size8 REAL(kind=real_8) :: factor, fill_guess, left_fill, right_fill ! First we calculate the sparsities size8 = INT(dbcsr_nfullrows_local(matrix_left), KIND=int_8)* & INT(dbcsr_nfullcols_local(matrix_left), KIND=int_8) size8 = MAX(1_int_8, size8) left_fill = (REAL(left_data_size, KIND=real_8)*REAL(left_col_nimages, KIND=real_8))/REAL(size8, KIND=real_8) size8 = INT(dbcsr_nfullrows_local(matrix_right), KIND=int_8)* & INT(dbcsr_nfullcols_local(matrix_right), KIND=int_8) size8 = MAX(1_int_8, size8) right_fill = (REAL(right_data_size, KIND=real_8)*REAL(right_row_nimages, KIND=real_8))/REAL(size8, KIND=real_8) size8 = INT(dbcsr_nfullrows_local(product_matrix), KIND=int_8)* & INT(dbcsr_nfullcols_local(product_matrix), KIND=int_8) size8 = MAX(1_int_8, size8) ! factor = 7.0 ! Old guess factor = 2.4 ! New guess fill_guess = factor*MAX(left_fill, right_fill) fill_guess = MIN(1.0_real_8, MAX(0.0_real_8, fill_guess)) IF (nthreads .GT. 1) THEN fill_guess = fill_guess*3.0_real_8/REAL(2*nthreads, KIND=real_8) END IF size_guess = INT(REAL(size8, KIND=real_8)*fill_guess, KIND=int_4) END FUNCTION product_matrix_size_guess