Files
linux-nvgpu/arch/understand_deps_analyze.py
Alex Waterman 6efe02f776 gpu: nvgpu: Add YAML arch to linux-nvgpu
Add the YAML arch to the linux-nvgpu repo so that the arch and source
code can be kept entirely in sync.

When the YAML was in a separate repo it was too difficult to keep things
in sync. Based on this work the next steps are:

  1. Gate compilation on no sources issues (missing or orphan source
     files.
  2. Perhaps use the arch to generate the Makefile.sources files.

JIRA NVGPU-3074
JIRA NVGPU-3075
Bug 2587555

Change-Id: Ic62be3e5e7ea1fb61ea50a2d611f905fa574988f
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2113154
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-05-13 10:47:44 -07:00

59 lines
2.0 KiB
Python
Executable File

#!/usr/bin/python3
#
# Python script to parse dependency export CSV from Understand. It detects
# these common architectural problems:
# * Common code depends on hardware headers
# * HAL unit depends directly on another HAL unit. The dependency should
# always be via HAL interface.
# * Two units have a circular dependency.
#
# Usage:
#
# understand_deps_analyze.py <deps_export.csv
#
# Notice that the CSV export has to be made by:
# * Create architecture XML with nvgpu_arch.py (command understand)
# * Create nvgpu project in Understand and add nvgpu code, both common and qnx
# directories
# * Import architecture XML to Understand
# * View Graphs->Dependency graphs->By nvgpu (nvgpu probably comes from the
# name of the architecture .xml file
# * Create arch dependendency report:
# * Reports->Dependency->Architecture Dependencies->Export CSV
# * Choose nvgpu as "Select an architecture to analyze"
import sys
import re
def checkMatch(fromUnit, toUnit):
ret = None
if (not fromUnit.startswith("common/hal") and toUnit.startswith("gpu_hw")):
ret = "Common depends on HW"
if (fromUnit.startswith("common/hal") and toUnit.startswith("common/hal")):
ret = "HAL depends on HAL"
# We have still too many of these problems, and it's not clear if we want
# to fix them all. Comment out for now.
# if (fromUnit.startswith("interface") and not toUnit.startswith("interface")):
# ret = "Interface depends on non-interface"
return ret
stream = sys.stdin
deps = set()
depRe = re.compile("(.+),(.+),\d+,\d+,\d+,\d+,\d+")
for line in stream.readlines():
match = depRe.match(line)
if match:
ret = checkMatch(match.group(1), match.group(2))
if (ret):
print("%s,%s,%s" % (ret, match.group(1), match.group(2)))
if "%s,%s" % (match.group(2), match.group(1)) in deps:
print("Circular dependency,%s,%s" % (match.group(1), match.group(2)))
deps.add("%s,%s" % (match.group(1), match.group(2)))