CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
cmssw_cycle_finder Namespace Reference

Classes

class  Graph
 

Functions

def dfs
 
def dfs_visit
 
def get_files
 
def get_include_packages
 
def get_lib_deps
 
def get_pack_list
 
def run_command
 

Variables

string action = "store_false"
 
tuple args = parser.parse_args()
 
tuple cuda_source_list = get_files(lib,"src",[".cu"])
 
tuple G = Graph([])
 
tuple header_incs_packages = get_include_packages(header_list)
 
tuple header_list = get_files(lib,"interface",[".h",".hpp"])
 
string help = "Ignore cycles due to header only dependencies"
 
tuple iter_lib = tqdm.tqdm(lib_list)
 
tuple lib_list = get_pack_list()
 
 omit_header_only = args.omit_header_only
 
tuple parser = argparse.ArgumentParser(description="CMSSW Cyclic dependency finder")
 
tuple self_headers = list(cpp_self_headers)
 
 show_status_bar = args.status_bar
 
tuple source_incs_packages = list(cpp_incs_packages)
 
tuple source_list = get_files(lib,"src",[".cc",".cpp",".cxx"])
 

Function Documentation

def cmssw_cycle_finder.dfs (   G)

Definition at line 24 of file cmssw_cycle_finder.py.

References dfs_visit().

24 
25 def dfs(G):
26  discovered = set()
27  finished = set()
28  for u in G.adj:
29  if u not in discovered and u not in finished:
30  discovered, finished = dfs_visit(G, u, discovered, finished)
def cmssw_cycle_finder.dfs_visit (   G,
  u,
  discovered,
  finished 
)

Definition at line 31 of file cmssw_cycle_finder.py.

References print().

Referenced by dfs().

31 
32 def dfs_visit(G, u, discovered, finished):
33  if u not in G.adj:
34  finished.add(u)
35  return discovered, finished
36 
37  discovered.add(u)
38 
39  for v in G.adj[u]:
40  # Detect cycles
41  if v in discovered:
42  print(f"Cycle detected: found a back edge from {u} to {v}. It involves")
43  for i,d in enumerate(discovered):
44  if i != len(discovered)-1:
45  print(d,end=', ')
46  else:
47  print(d)
48 
49  # Recurse into DFS tree
50  else:
51  if v not in finished:
52  dfs_visit(G, v, discovered, finished)
53 
54  discovered.remove(u)
55  finished.add(u)
56 
57  return discovered, finished
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def cmssw_cycle_finder.get_files (   pack,
  subdir,
  file_types 
)

Definition at line 83 of file cmssw_cycle_finder.py.

83 
84 def get_files(pack,subdir,file_types):
85  src_base = os.environ.get('CMSSW_RELEASE_BASE')
86  pack_path = os.path.join(src_base,"src",pack,subdir)
87  if not os.path.exists(pack_path): return []
88  ret_val=[]
89  for root, dirs, files in os.walk(pack_path, topdown=False):
90  for name in files:
91  for t in file_types:
92  if name.endswith(t):
93  ret_val.append(os.path.join(root,name))
94 
95  return ret_val
def cmssw_cycle_finder.get_include_packages (   file_list,
  package = None,
  is_cuda = False 
)

Definition at line 106 of file cmssw_cycle_finder.py.

References join(), run_command(), and submitPVValidationJobs.split().

107 def get_include_packages(file_list,package=None,is_cuda=False):
108  incs={}
109  pack_incs={}
110  if is_cuda:
111  comm= "gcc -fpreprocessed -dD -E "
112  else:
113  comm= "nvcc --compiler-options -fpreprocessed -dD -E "
114  for f in file_list:
115  comm=comm+f+" "
116  comm=comm+" | grep \"#include\""
117  c_rt,c_out,c_err = run_command(comm)
118  for l in c_out.split():
119  inc = l.strip().split()[-1][1:-1]
120  if '/' in inc:
121  incs['/'.join(inc.split('/')[0:2])]=1
122  if package is not None and package in inc and "interface" in inc:
123  pack_incs[os.path.join('/'.join(file_list[0].split('/')[0:-4]),inc)]=1
124  if package is None:
125  return list(incs.keys())
126  else:
127  return list(incs.keys()),list(pack_incs.keys())
128 
129 
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def cmssw_cycle_finder.get_lib_deps (   lib_info)

Definition at line 96 of file cmssw_cycle_finder.py.

References run_command().

96 
97 def get_lib_deps(lib_info):
98  lib_path = lib_info[1]
99  comm = "ldd "+lib_path+"| grep cms | grep -v \"/external\" | grep -v \"/lcg/\" | awk '{print $3}'"
100  c_rt,c_out,c_err = run_command(comm)
101  ret_val=[]
102  for l in c_out.split():
103  lib = l.strip()
104  ret_val.append( (lib.split('/')[-1],lib))
105  return ret_val
def cmssw_cycle_finder.get_pack_list ( )

Definition at line 70 of file cmssw_cycle_finder.py.

References join(), and run_command().

70 
71 def get_pack_list():
72  src_base = os.environ.get('CMSSW_RELEASE_BASE')
73  src_path = os.path.join(src_base,"src")
74  comm = "ls -d "+src_path+"/*/*/interface"
75  c_rt,c_out,c_err = run_command(comm)
76 
77  ret_val=[]
78  for l in c_out.split():
79  sp=l.split('/')
80  ret_val.append('/'.join(sp[-3:-1]))
81 
82  return ret_val
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def cmssw_cycle_finder.run_command (   comm)

Definition at line 59 of file cmssw_cycle_finder.py.

Referenced by get_include_packages(), get_lib_deps(), and get_pack_list().

59 
60 def run_command(comm):
61  encoding = 'utf-8'
62  proc = subprocess.Popen(comm, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
63  stdout, stderr = proc.communicate()
64  stdout = stdout.decode(encoding)
65  if stderr is not None:
66  stderr= stderr.decode(encoding)
67  return proc.returncode, stdout, stderr
68 

Variable Documentation

string cmssw_cycle_finder.action = "store_false"

Definition at line 138 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.args = parser.parse_args()

Definition at line 146 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.cuda_source_list = get_files(lib,"src",[".cu"])

Definition at line 166 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.G = Graph([])

Definition at line 154 of file cmssw_cycle_finder.py.

Referenced by EcalTPGParamBuilder.analyze(), L1TConfigDumper.analyze(), AlignmentProducerBase.applyDB(), TwoTrackMinimumDistanceHelixHelix.calculate(), funct::RatioP1< A, B, Numerical< n > >.combine(), funct::RatioP2< A, B, ProductStruct< C, D > >.combine(), QGLikelihoodCalculator.computeQGLikelihood(), FlavourHistograms2D< T, G >.fill(), hitfit::Chisq_Constrainer.fit(), MuScleFit.MuScleFit(), fastsim::HelixTrajectory.nextCrossingTimeC(), and smearFunctionType7.smear().

tuple cmssw_cycle_finder.header_incs_packages = get_include_packages(header_list)

Definition at line 177 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.header_list = get_files(lib,"interface",[".h",".hpp"])

Definition at line 164 of file cmssw_cycle_finder.py.

string cmssw_cycle_finder.help = "Ignore cycles due to header only dependencies"

Definition at line 139 of file cmssw_cycle_finder.py.

cmssw_cycle_finder.iter_lib = tqdm.tqdm(lib_list)

Definition at line 160 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.lib_list = get_pack_list()

Definition at line 156 of file cmssw_cycle_finder.py.

cmssw_cycle_finder.omit_header_only = args.omit_header_only

Definition at line 147 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.parser = argparse.ArgumentParser(description="CMSSW Cyclic dependency finder")

Definition at line 136 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.self_headers = list(cpp_self_headers)

Definition at line 173 of file cmssw_cycle_finder.py.

cmssw_cycle_finder.show_status_bar = args.status_bar

Definition at line 148 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.source_incs_packages = list(cpp_incs_packages)

Definition at line 171 of file cmssw_cycle_finder.py.

tuple cmssw_cycle_finder.source_list = get_files(lib,"src",[".cc",".cpp",".cxx"])

Definition at line 165 of file cmssw_cycle_finder.py.