CMS 3D CMS Logo

Classes | Functions | Variables
cmssw_cycle_finder Namespace Reference

Classes

class  Graph
 

Functions

def dfs (G)
 
def dfs_visit (G, u, discovered, finished)
 
def get_files (pack, subdir, file_types)
 
def get_include_packages (file_list, package=None, is_cuda=False)
 
def get_lib_deps (lib_info)
 
def get_pack_list ()
 
def run_command (comm)
 

Variables

 action
 
 args
 
 cpp_incs_packages
 
 cpp_self_headers
 
 cuda_incs_packages
 
 cuda_self_headers
 
 cuda_source_list
 
 default
 
 description
 
 dest
 
 G
 
 header_incs_packages
 
 header_list
 
 help
 
 is_cuda
 
 iter_lib
 
 lib
 
 lib_list
 
 omit_header_only
 
 parser
 
 self_headers
 
 show_status_bar
 
 source_incs_packages
 
 source_list
 

Function Documentation

◆ dfs()

def cmssw_cycle_finder.dfs (   G)

Definition at line 24 of file cmssw_cycle_finder.py.

References dfs_visit().

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

◆ dfs_visit()

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

◆ get_files()

def cmssw_cycle_finder.get_files (   pack,
  subdir,
  file_types 
)

Definition at line 83 of file cmssw_cycle_finder.py.

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

◆ get_include_packages()

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().

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

◆ get_lib_deps()

def cmssw_cycle_finder.get_lib_deps (   lib_info)

Definition at line 96 of file cmssw_cycle_finder.py.

References run_command().

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

◆ get_pack_list()

def cmssw_cycle_finder.get_pack_list ( )

Definition at line 70 of file cmssw_cycle_finder.py.

References join(), and run_command().

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

◆ run_command()

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

Variable Documentation

◆ action

cmssw_cycle_finder.action

Definition at line 138 of file cmssw_cycle_finder.py.

◆ args

cmssw_cycle_finder.args

Definition at line 146 of file cmssw_cycle_finder.py.

◆ cpp_incs_packages

cmssw_cycle_finder.cpp_incs_packages

Definition at line 168 of file cmssw_cycle_finder.py.

◆ cpp_self_headers

cmssw_cycle_finder.cpp_self_headers

Definition at line 168 of file cmssw_cycle_finder.py.

◆ cuda_incs_packages

cmssw_cycle_finder.cuda_incs_packages

Definition at line 169 of file cmssw_cycle_finder.py.

◆ cuda_self_headers

cmssw_cycle_finder.cuda_self_headers

Definition at line 169 of file cmssw_cycle_finder.py.

◆ cuda_source_list

cmssw_cycle_finder.cuda_source_list

Definition at line 166 of file cmssw_cycle_finder.py.

◆ default

cmssw_cycle_finder.default

Definition at line 138 of file cmssw_cycle_finder.py.

◆ description

cmssw_cycle_finder.description

Definition at line 136 of file cmssw_cycle_finder.py.

◆ dest

cmssw_cycle_finder.dest

Definition at line 137 of file cmssw_cycle_finder.py.

◆ G

cmssw_cycle_finder.G

◆ header_incs_packages

cmssw_cycle_finder.header_incs_packages

Definition at line 177 of file cmssw_cycle_finder.py.

◆ header_list

cmssw_cycle_finder.header_list

Definition at line 164 of file cmssw_cycle_finder.py.

◆ help

cmssw_cycle_finder.help

Definition at line 139 of file cmssw_cycle_finder.py.

◆ is_cuda

cmssw_cycle_finder.is_cuda

Definition at line 169 of file cmssw_cycle_finder.py.

◆ iter_lib

cmssw_cycle_finder.iter_lib

Definition at line 160 of file cmssw_cycle_finder.py.

◆ lib

cmssw_cycle_finder.lib

Definition at line 169 of file cmssw_cycle_finder.py.

◆ lib_list

cmssw_cycle_finder.lib_list

Definition at line 156 of file cmssw_cycle_finder.py.

◆ omit_header_only

cmssw_cycle_finder.omit_header_only

Definition at line 147 of file cmssw_cycle_finder.py.

◆ parser

cmssw_cycle_finder.parser

Definition at line 136 of file cmssw_cycle_finder.py.

◆ self_headers

cmssw_cycle_finder.self_headers

Definition at line 173 of file cmssw_cycle_finder.py.

◆ show_status_bar

cmssw_cycle_finder.show_status_bar

Definition at line 148 of file cmssw_cycle_finder.py.

◆ source_incs_packages

cmssw_cycle_finder.source_incs_packages

Definition at line 171 of file cmssw_cycle_finder.py.

◆ source_list

cmssw_cycle_finder.source_list

Definition at line 165 of file cmssw_cycle_finder.py.