GCC Code Coverage Report


Directory: ./
File: tests/unit/05_api/fortran_api_talp_00.f90
Date: 2026-12-01 10:07:21
Exec Total Coverage
Lines: 56 56 100.0%
Functions: 2 2 100.0%
Branches: 28 54 51.9%

Line Branch Exec Source
1 !-------------------------------------------------------------------------------!
2 ! Copyright 2009-2021 Barcelona Supercomputing Center !
3 ! !
4 ! This file is part of the DLB library. !
5 ! !
6 ! DLB is free software: you can redistribute it and/or modify !
7 ! it under the terms of the GNU Lesser General Public License as published by !
8 ! the Free Software Foundation, either version 3 of the License, or !
9 ! (at your option) any later version. !
10 ! !
11 ! DLB is distributed in the hope that it will be useful, !
12 ! but WITHOUT ANY WARRANTY; without even the implied warranty of !
13 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !
14 ! GNU Lesser General Public License for more details. !
15 ! !
16 ! You should have received a copy of the GNU Lesser General Public License !
17 ! along with DLB. If not, see <https://www.gnu.org/licenses/>. !
18 !-------------------------------------------------------------------------------!
19
20 1 program test
21 use iso_c_binding
22 implicit none
23 include 'dlbf.h'
24 include 'dlbf_talp.h'
25 integer, parameter :: N = 100
26 integer :: i, err
27 type(dlb_monitor_t), pointer :: dlb_monitor
28 type(c_ptr) :: dlb_handle_1, dlb_handle_2, dlb_handle_3
29 character(9), pointer :: monitor_name
30
31 1 err = DLB_Init(0, C_NULL_PTR, "--talp")
32
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_init failed"
33
34 ! initialize global region with 1 measurement
35 1 dlb_handle_1 = DLB_MonitoringRegionGetGlobal()
36 1 err = DLB_MonitoringRegionStart(dlb_handle_1)
37
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_NOUPDT) error stop "dlb_monitoringregionstart failed"
38 1 err = DLB_MonitoringRegionStop(dlb_handle_1)
39
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstop failed"
40 1 call c_f_pointer(dlb_handle_1, dlb_monitor)
41
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%num_measurements /= 1) error stop "num_measurements not 1"
42
43 ! check that DLB_GLOBAL_REGION and DLB_GLOBAL_REGION_INT identify the global region
44 1 err = DLB_MonitoringRegionStart(DLB_GLOBAL_REGION)
45 1 err = DLB_MonitoringRegionStop(transfer(DLB_GLOBAL_REGION_INT, c_null_ptr))
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%num_measurements /= 2) error stop "num_measurements not 2"
47
48 ! register custom regions
49 1 dlb_handle_1 = DLB_MonitoringRegionRegister("region 1")
50
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (.not. c_associated(dlb_handle_1)) error stop "handle 1 not associated"
51 1 dlb_handle_2 = DLB_MonitoringRegionRegister("region 2")
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (.not. c_associated(dlb_handle_2)) error stop "handle 2 not associated"
53 1 dlb_handle_3 = DLB_MonitoringRegionRegister("")
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (.not. c_associated(dlb_handle_3)) error stop "handle 3 not associated"
55
56
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1 times.
101 do i=1, N
57 ! monitorized region
58 100 err = DLB_MonitoringRegionStart(dlb_handle_1)
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstart failed"
60
61 ! nested monitoring region
62 100 err = DLB_MonitoringRegionStart(dlb_handle_2)
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstart (nested) failed"
64 100 err = DLB_MonitoringRegionStop(dlb_handle_2)
65
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstop (nested) failed"
66
67 ! nested anonymous monitoring region
68 100 err = DLB_MonitoringRegionStart(dlb_handle_3)
69
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstart (anonymous) failed"
70 100 err = DLB_MonitoringRegionStop(transfer(DLB_LAST_OPEN_REGION_INT, c_null_ptr))
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstop (anonymous) failed"
72 100 err = DLB_MonitoringRegionStop(dlb_handle_3)
73
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if (err /= DLB_NOUPDT) error stop "dlb_monitoringregionstop (anonymous) should be NOUPDT"
74
75 ! end monitoring region
76 100 err = DLB_MonitoringRegionStop(dlb_handle_1)
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
101 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionstop failed"
78 enddo
79
80 1 call c_f_pointer(dlb_handle_1, dlb_monitor)
81 1 call c_f_pointer(dlb_monitor%name_, monitor_name)
82
83 1 print *, monitor_name
84 1 print *, dlb_monitor%num_measurements
85 1 print *, dlb_monitor%num_resets
86 1 print *, dlb_monitor%elapsed_time
87
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%num_measurements /= N) error stop "num_measurements not N"
89
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%elapsed_time <= 0) error stop "elapsed_time not > 0"
90
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%useful_time <= 0) error stop "useful_time not > 0"
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%mpi_time /= 0) error stop "mpi_time not 0"
92
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%omp_load_imbalance_time /= 0) error stop "omp_load_imbalance_time not 0"
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%omp_scheduling_time /= 0) error stop "omp_scheduling_time not 0"
94
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dlb_monitor%omp_outside_parallel_time /= 0) error stop "omp_outside_parallel_time not 0"
95
96 1 err = DLB_MonitoringRegionReport(dlb_handle_1)
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionreport failed"
98 1 err = DLB_MonitoringRegionReport(dlb_handle_2)
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionreport failed"
100 1 err = DLB_MonitoringRegionReport(dlb_handle_3)
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_monitoringregionreport failed"
102
103 1 err = DLB_Finalize()
104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_finalize failed"
105 1 end program test
106