stats_collect_from_threads Subroutine

private subroutine stats_collect_from_threads(report)

Collects statistics from all OpenMP-threads into report

Arguments

Type IntentOptional Attributes Name
type(stats_type), intent(inout) :: report

Source Code

   SUBROUTINE stats_collect_from_threads(report)
      !! Collects statistics from all OpenMP-threads into report
      TYPE(stats_type), INTENT(INOUT)                    :: report

      INTEGER                                            :: i, j, nthreads
      TYPE(stats_type), POINTER                          :: istats

!$OMP PARALLEL DEFAULT(NONE) SHARED(nthreads)
!$OMP MASTER
      nthreads = 1
!$    nthreads = OMP_GET_NUM_THREADS()
!$OMP END MASTER
!$OMP END PARALLEL

      DO i = 0, nthreads - 1
         istats => stats_per_thread(i)
         report%cpu_num_stacks = report%cpu_num_stacks + istats%cpu_num_stacks
         report%smm_num_stacks = report%smm_num_stacks + istats%smm_num_stacks
         report%acc_num_stacks = report%acc_num_stacks + istats%acc_num_stacks
         report%acc_flop = report%acc_flop + istats%acc_flop
         report%smm_flop = report%smm_flop + istats%smm_flop
         report%cpu_flop = report%cpu_flop + istats%cpu_flop

         DO j = 1, SIZE(istats%num_mnk_stacks, 1)
            CALL stats_add(report, &
                           m=INT(istats%num_mnk_stacks(j, 1), kind=int_4), &
                           n=INT(istats%num_mnk_stacks(j, 2), kind=int_4), &
                           k=INT(istats%num_mnk_stacks(j, 3), kind=int_4), &
                           stacksize_cpu=istats%num_mnk_stacks(j, 4), &
                           stacksize_smm=istats%num_mnk_stacks(j, 5), &
                           stacksize_acc=istats%num_mnk_stacks(j, 6), &
                           nstacks_cpu=istats%num_mnk_stacks(j, 7), &
                           nstacks_smm=istats%num_mnk_stacks(j, 8), &
                           nstacks_acc=istats%num_mnk_stacks(j, 9), &
                           generated_acc_untuned=istats%num_mnk_stacks(j, 10) .GT. 0)
         END DO
      END DO

   END SUBROUTINE stats_collect_from_threads