  Increasing heterogeneity in HPC architectures and compiler advancements have
led to OpenMP being frequently used to enable computations on heterogeneous
devices. However, the efficient movement of data on heterogeneous computing
platforms is crucial for achieving high utilization. The implicit OpenMP
data-mapping rules often result in redundant data transfer, which can be a
bottleneck for program performance. Programmers must explicitly map data
between the host and connected accelerator devices to achieve efficient data
movement. For this, OpenMP offers the target data and target update constructs.
Ensuring efficient data transfer requires programmers to reason about complex
data flow. This can be a laborious and error-prone process since the programmer
must keep a mental model of data validity and lifetime spanning multiple data
environments. Any automated analysis should maximize data reuse, minimize data
transfer, and must consider control flow and context from function call sites,
making the analysis interprocedural and context sensitive. In this paper, we
present a static analysis tool, OMPDart (OpenMP DAta Reduction Tool), for
OpenMP programs that models data dependencies between host and device regions
and applies source code transformations to achieve efficient data transfer. The
analysis is based on a hybrid data structure that joins an Abstract Syntax Tree
(AST) with a Control Flow Graph (CFG). Our evaluations on nine HPC benchmarks
demonstrate that OMPDart is capable of generating effective data mapping
constructs that substantially reduce data transfer between host and device.
OMPDart helps reduce data transfers by 85% and improves runtime performance by
1.6x over an expert-defined implementation of LULESH 2.0.
