libminni Commit: [libminni][0] Shifted some stuff around

1 view
Skip to first unread message

Erik Zawadzki

unread,
Apr 26, 2011, 4:19:39 PM4/26/11
to libm...@googlegroups.com
Message: Shifted some stuff around
Commit: f811f6988d54d4b6ad26eff01ede5144ea20d2ef
Date: Tue Apr 26 13:20:54 2011 -0400
Author: Erik Zawadzki <e...@cs.cmu.edu>

Added file src/tools/workload/XMLWrap.py

1  import xml.dom.minidom as xml
2  
3  def findNode(dom,path_list):
4      current = dom
5      for n in path_list:
6          current = current.getElementsByTagName(n).item(0)
7      return current
8  
9  def getNodeText(node):
10      if node.firstChild.nodeType == node.TEXT_NODE:
11          return str(node.firstChild.data)
12      return ''
13  
14  def getText(dom, path):
15      node = findNode(dom,path)
16      return getNodeText(node)
17  
18  def getNumber(dom, path):
19      node = findNode(dom,path)
20      return int(getNodeText(node))
21  
22  def getNumberList(dom, path):
23      node = findNode(dom,path)
24      list_text = getNodeText(node)
25      return map(float, list_text.split(','))
26  
27  def getChildren(dom, path):
28      curr = findNode(dom,path)
29      return curr.childNodes
30  
31  def getAttrList(dom, path):
32      curr = findNode(dom,path)
33      Attr={}
34      for c in curr.childNodes:
35          if c.hasChildNodes():
36              Attr[c.nodeName] = getText(dom, path + [c.nodeName])
37      return Attr
38  
39  def getFunction(dom,path):
40      node = findNode(dom,path)
41      (module_name, sep, function_name) = getNodeText(node).rpartition('.')
42      module = __import__(module_name)
43      func = getattr(module, function_name)
44      return func

Changed file src/tools/workload/generator.py

1 1  import xml.dom.minidom as xml
2  from xmlz import *
2  from XMLWrap import *
3 3  import random
4 4  import subprocess, os, sys
5 5  

Changed file src/tools/workload/sample_config.xml

23 23    <pao_h>templates/pao_h.tmpl</pao_h>
24 24    <pao_cpp>templates/pao_cpp.tmpl</pao_cpp>
25 25    <pao_args>
26      <pao_header_file>gen_pao.h</pao_header_file>
27      <pao_body_file>gen_pao.h</pao_body_file>
26 28      <pao_class>TestPaoClass</pao_class>
27 29      <pao_state_datatype>int i;</pao_state_datatype>
28 30      <pao_add_func>this->i++;</pao_add_func>

Changed file src/tools/workload/so_builder.py

1 1  import xml.dom.minidom as xml
2  from xmlz import *
2  from XMLWrap import *
3 3  import sys
4 4  import MicroTemplate as mt
5 5  
8 8      print 'Usage: python generator.py <XML config file>'
9 9      quit()
10 10  
11  # Parse the XML file
11 12  dom = xml.parse(sys.argv[1])
12 13  
14  # Generate the PAO file
13 15  pao_h_template = getText(dom, ['pao_h'])
14 16  pao_cpp_template = getText(dom, ['pao_cpp'])
15 17  pao_sub = getAttrList(dom, ['pao_args'])
17 19  mt.rewrite(pao_sub, pao_h_template, 'gen_pao.h')
18 20  mt.rewrite(pao_sub, pao_cpp_template, 'gen_pao.cpp')
19 21  
22  # Generate the Mapper file
20 23  mapper_h_template = getText(dom, ['mapper_h'])
21 24  mapper_cpp_template = getText(dom, ['mapper_cpp'])
22 25  mapper_sub = getAttrList(dom, ['mapper_args'])

Deleted file src/tools/workload/xmlz.py

1  import xml.dom.minidom as xml
2  
3  def findNode(dom,path_list):
4      current = dom
5      for n in path_list:
6          current = current.getElementsByTagName(n).item(0)
7      return current
8  
9  def getNodeText(node):
10      if node.firstChild.nodeType == node.TEXT_NODE:
11          return str(node.firstChild.data)
12      return ''
13  
14  def getText(dom, path):
15      node = findNode(dom,path)
16      return getNodeText(node)
17  
18  def getNumber(dom, path):
19      node = findNode(dom,path)
20      return int(getNodeText(node))
21  
22  def getNumberList(dom, path):
23      node = findNode(dom,path)
24      list_text = getNodeText(node)
25      return map(float, list_text.split(','))
26  
27  def getChildren(dom, path):
28      curr = findNode(dom,path)
29      return curr.childNodes
30  
31  def getAttrList(dom, path):
32      curr = findNode(dom,path)
33      Attr={}
34      for c in curr.childNodes:
35          if c.hasChildNodes():
36              Attr[c.nodeName] = getText(dom, path + [c.nodeName])
37      return Attr
38  
39  def getFunction(dom,path):
40      node = findNode(dom,path)
41      (module_name, sep, function_name) = getNodeText(node).rpartition('.')
42      module = __import__(module_name)
43      func = getattr(module, function_name)
44      return func


Reply all
Reply to author
Forward
0 new messages