stats_add Subroutine

private subroutine stats_add(stats, m, n, k, stacksize_cpu, stacksize_smm, stacksize_acc, nstacks_cpu, nstacks_smm, nstacks_acc, generated_acc_untuned)

Helper-routine used by dbcsr_mm_sched_process to supply statistics.

Arguments

Type IntentOptional Attributes Name
type(stats_type), intent(inout) :: stats
integer, intent(in) :: m
integer, intent(in) :: n
integer, intent(in) :: k
integer(kind=int_8), optional :: stacksize_cpu
integer(kind=int_8), optional :: stacksize_smm
integer(kind=int_8), optional :: stacksize_acc
integer(kind=int_8), optional :: nstacks_cpu
integer(kind=int_8), optional :: nstacks_smm
integer(kind=int_8), optional :: nstacks_acc
logical, optional :: generated_acc_untuned

Source Code

   SUBROUTINE stats_add(stats, m, n, k, stacksize_cpu, stacksize_smm, stacksize_acc, &
                        nstacks_cpu, nstacks_smm, nstacks_acc, generated_acc_untuned)
      !! Helper-routine used by dbcsr_mm_sched_process to supply statistics.

      TYPE(stats_type), INTENT(INOUT)                    :: stats
      INTEGER, INTENT(IN)                                :: m, n, k
      INTEGER(kind=int_8), OPTIONAL                      :: stacksize_cpu, stacksize_smm, &
                                                            stacksize_acc, nstacks_cpu, &
                                                            nstacks_smm, nstacks_acc
      LOGICAL, OPTIONAL                                  :: generated_acc_untuned

      INTEGER                                            :: i, s
      INTEGER(kind=int_8)                                :: my_nstacks_acc, my_nstacks_cpu, &
                                                            my_nstacks_smm, my_stacksize_acc, &
                                                            my_stacksize_cpu, my_stacksize_smm, &
                                                            my_nstacks_acc_default
      INTEGER(kind=int_8), ALLOCATABLE, DIMENSION(:, :)  :: tmp

      my_stacksize_cpu = 0
      my_stacksize_smm = 0
      my_stacksize_acc = 0
      IF (PRESENT(stacksize_cpu)) my_stacksize_cpu = stacksize_cpu
      IF (PRESENT(stacksize_smm)) my_stacksize_smm = stacksize_smm
      IF (PRESENT(stacksize_acc)) my_stacksize_acc = stacksize_acc

      my_nstacks_cpu = MERGE(1, 0, my_stacksize_cpu > 0)
      my_nstacks_smm = MERGE(1, 0, my_stacksize_smm > 0)
      my_nstacks_acc = MERGE(1, 0, my_stacksize_acc > 0)
      my_nstacks_acc_default = 0
      IF (PRESENT(nstacks_cpu)) my_nstacks_cpu = nstacks_cpu
      IF (PRESENT(nstacks_smm)) my_nstacks_smm = nstacks_smm
      IF (PRESENT(nstacks_acc)) my_nstacks_acc = nstacks_acc
      IF (PRESENT(generated_acc_untuned)) THEN
         IF (generated_acc_untuned) my_nstacks_acc_default = 1
      END IF

      DO i = 1, SIZE(stats%num_mnk_stacks, 1)
         IF (stats%num_mnk_stacks(i, 1) == m .AND. &
             stats%num_mnk_stacks(i, 2) == n .AND. &
             stats%num_mnk_stacks(i, 3) == k) THEN
            stats%num_mnk_stacks(i, 4) = stats%num_mnk_stacks(i, 4) + my_stacksize_cpu
            stats%num_mnk_stacks(i, 5) = stats%num_mnk_stacks(i, 5) + my_stacksize_smm
            stats%num_mnk_stacks(i, 6) = stats%num_mnk_stacks(i, 6) + my_stacksize_acc
            stats%num_mnk_stacks(i, 7) = stats%num_mnk_stacks(i, 7) + my_nstacks_cpu
            stats%num_mnk_stacks(i, 8) = stats%num_mnk_stacks(i, 8) + my_nstacks_smm
            stats%num_mnk_stacks(i, 9) = stats%num_mnk_stacks(i, 9) + my_nstacks_acc
            stats%num_mnk_stacks(i, 10) = stats%num_mnk_stacks(i, 10) + my_nstacks_acc_default
            RETURN
         END IF
      END DO

      !not found, ok lets grow the list
      s = SIZE(stats%num_mnk_stacks, 1)
      ALLOCATE (tmp(s, 10))
      tmp(:, :) = stats%num_mnk_stacks(:, :)
      DEALLOCATE (stats%num_mnk_stacks)
      ALLOCATE (stats%num_mnk_stacks(s + 1, 10))
      stats%num_mnk_stacks(1:s, :) = tmp(:, :)
      stats%num_mnk_stacks(s + 1, 1) = m
      stats%num_mnk_stacks(s + 1, 2) = n
      stats%num_mnk_stacks(s + 1, 3) = k
      stats%num_mnk_stacks(s + 1, 4) = my_stacksize_cpu
      stats%num_mnk_stacks(s + 1, 5) = my_stacksize_smm
      stats%num_mnk_stacks(s + 1, 6) = my_stacksize_acc
      stats%num_mnk_stacks(s + 1, 7) = my_nstacks_cpu
      stats%num_mnk_stacks(s + 1, 8) = my_nstacks_smm
      stats%num_mnk_stacks(s + 1, 9) = my_nstacks_acc
      stats%num_mnk_stacks(s + 1, 10) = my_nstacks_acc_default
      DEALLOCATE (tmp)
   END SUBROUTINE stats_add