Skip to content

Commit 43fe59c

Browse files
committed
Add documentation for platform coverage
- Mention "platform coverage" in README and home page. - Add a description of "platform coverage" to the specialization page. Signed-off-by: John Pennycook <[email protected]>
1 parent bc7a7c2 commit 43fe59c

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
Code Base Investigator (CBI) is an analysis tool that provides insight into the
77
portability and maintainability of an application's source code.
88

9-
- Measure [code divergence](http://doi.org/10.1109/P3HPC.2018.00006) to
10-
understand how much code is specialized for different compilers, operating
11-
systems, hardware micro-architectures and more.
9+
- Measure [code divergence](http://doi.org/10.1109/P3HPC.2018.00006) and
10+
platform coverage to understand how much code is specialized for different
11+
compilers, operating systems, hardware micro-architectures and more.
1212

1313
- Visualize the distance between the code paths used to support different
1414
compilation targets.

docs/source/features.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ are shared between different platform sets.
4242
{FPGA, CPU 1, GPU 2, GPU 1, CPU 2} 9 21.95
4343
---------------------------------------------
4444
Code Divergence: 0.55
45-
Unused Code (%): 4.88
45+
Coverage (%): 95.12
46+
Avg. Coverage (%): 42.44
4647
Total SLOC: 41
4748
4849
Future releases of CBI will provide additional ways to visualize the results of

docs/source/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ Code Base Investigator
4141
Code Base Investigator (CBI) is an analysis tool that provides insight into the
4242
portability and maintainability of an application's source code.
4343

44-
- Measure ":doc:`code divergence <specialization>`" to understand how much code
45-
is *specialized* for different compilers, operating systems, hardware
46-
micro-architectures and more.
44+
- Measure "code divergence" and "platform coverage" to understand how much code
45+
is :doc:`specialized <specialization>` for different compilers, operating
46+
systems, hardware micro-architectures and more.
4747

4848
- Visualize the distance between the code paths used to support different
4949
compilation targets.

docs/source/specialization.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,56 @@ two platforms, whereas a distance of 1 means that no code is shared.
8181

8282
.. _Effective Performance Portability:
8383
https://doi.org/10.1109/P3HPC.2018.00006
84+
85+
Platform Coverage
86+
#################
87+
88+
Platform coverage builds on the well-established concept of "test coverage",
89+
and measures the amount of code in a code base that is utilized by a set of
90+
platforms. Computing platform coverage is straightforward: it is simply the
91+
number of lines of code used by one or more platforms expressed as a percentage
92+
of the number of lines of code in the code base.
93+
94+
.. important::
95+
CBI often uses "coverage" as a shorthand for "platform coverage"!
96+
97+
Formally, for a given set of platforms, :math:`H`, the coverage for an
98+
application :math:`a` solving problem :math:`p` is:
99+
100+
.. math::
101+
\textrm{Coverage}(a, p, H) = \frac{\left|\bigcup_{i \in H} c_i(a,p)\right|}
102+
{\left|\bigcup_{i \in H} c_i(a,p)\right| + \left|\bigcap_{i \in H} c_i'(a,p)\right|} \times 100
103+
104+
where :math:`c_i` is the set of lines of code required to compile application
105+
:math:`a` and solve problem :math:`p` using platform :math:`i`, and
106+
:math:`c_i'` is the complement of that set (i.e., the set of lines of code
107+
*not* required). A coverage of 0% means that none of the code is used by any
108+
platform, whereas a coverage of 100% means that all of the code is used by at
109+
least one platform.
110+
111+
Measuring coverage can also help us to reason about differences between
112+
platforms. The *average* coverage (over platforms) allows us to reason about
113+
the amount of code covered by *all* platforms.
114+
115+
Formally, the average coverage is:
116+
117+
.. math::
118+
\textrm{Average Coverage}(a, p, H) = \frac{\sum_{h \in H} \textrm{Coverage}(a, p, h)}
119+
{\left|H\right|}
120+
121+
An average coverage of 0% means that none of the code is used by any platform,
122+
whereas an average coverage of 100% means that all of the code is used by all
123+
platforms.
124+
125+
.. tip::
126+
Low average coverage does not always mean the platforms in :math:`H` share
127+
little code; low average coverage can result from a high amount of unused
128+
code. Presenting coverage alongside average coverage provides the most insight.
129+
130+
The straightforward nature of coverage and average coverage has several
131+
advantages. First, it is very easy to intuit the impact of a code change upon
132+
coverage. Second, it is simple to use and understand in hierarchical contexts
133+
(e.g., the number of used lines for a directory is the sum of the used lines
134+
over all files in the directory). For these reasons, CBI functionality focused
135+
on understanding potential improvements to code structure tend to use coverage
136+
instead of divergence.

0 commit comments

Comments
 (0)