libminni Commit: [libminni] Small changes to the config file

1 view
Skip to first unread message

Erik Zawadzki

unread,
Apr 26, 2011, 4:34:16 PM4/26/11
to libm...@googlegroups.com
Message: Small changes to the config file
Commit: 7196f7bbe1150a34b8b952ac2cea2ec802311a70
Date: Tue Apr 26 16:33:46 2011 -0400
Author: Erik Zawadzki <e...@cs.cmu.edu>

Changed file src/tools/workload/XMLWrap.py

41 41  
42 42  def getFunction(dom,path):
43 43      node = findNode(dom,path)
44      (module_name, sep, function_name) = getNodeText(node).rpartition('.')
45      module = __import__(module_name)
46      func = getattr(module, function_name)
44      text = getNodeText(node)
45      try:
46          (module_name, sep, function_name) = text.rpartition('.')
47          module = __import__(module_name)
48          func = getattr(module, function_name)
49      except ValueError:
50          func = eval(text)
47 51      return func

Changed file src/tools/workload/generator.py

23 23          return self.F(*self.args)
24 24      def __str__(self):
25 25          return '{0}({1})'.format(self.F, str(self.args))
26  
26 27  class KeyDistro(Distro):
27 28      def __init__(self, func, *args):
28 29          self.F = func
29 30          self.args = args
30 31      def sample(self,v):
31 32          return Key(self.F(*self.args))
33  
34  class ValueDistro(Distro):
35      def __init__(self, func, *args):
36          self.F = func
37          self.args = args
38      def sample(self,k,v):
39          return Key(self.F(k,*self.args))
40  
32 41  class TimeDistro(Distro):
33 42      pass
34 43      
45 54      def __str__(self):
46 55          return self.on_disk_str()
47 56      
48  def generate(filename, key_dist, time_dist, V, sort=None):
57  def generate(filename, key_dist, value_dist, time_dist, N, sort=None):
49 58      FH = open(filename, 'w')
50      for v_id in xrange(V):
59      for d_id in xrange(N):
51 60          value = Value(v_id)
52 61          sampled_key = key_dist.sample(value)
53 62          sampled_time = time_dist.sample(value)
62 71  def getOutputFile(dom):
63 72      return getText(dom, ['generator', 'output'])
64 73  
65  def getKeyNumber(dom):
66      return getNumber(dom, ['generator', 'key', 'number'])
67  
68  def getValueNumber(dom):
69      return getNumber(dom, ['generator','value','number'])
74  def getDataNumber(dom):
75      return getNumber(dom, ['generator','datapoints','number'])
70 76  
71 77  def getKeyDistro(dom):
72      function = getFunction(dom,['generator','key', 'distribution', 'function'])
78      function = getFunction(dom,\
79                                 ['generator','key',\
80                                      'distribution', 'function'])
73 81      args = getNumberList(dom,['generator','key', 'distribution', 'args'])
74 82      return KeyDistro(function, *args)
75 83  
84  def getValueDistro(dom):
85      function = getFunction(dom,['generator','value', 'distribution', 'function'])
86      args = getNumberList(dom,['generator','value', 'distribution', 'args'])
87      return ValueDistro(function, *args)
88  
89  
76 90  def getTimeDistro(dom):
77 91      function = getFunction(dom,['generator','time', 'distribution', 'function'])
78 92      args = getNumberList(dom,['generator','time', 'distribution', 'args'])
84 98      quit()
85 99  dom = xml.parse(sys.argv[1])
86 100  filename = getOutputFile(dom)
87  K = getKeyNumber(dom)
88  V = getValueNumber(dom)
101  N = getDataNumber(dom)
89 102  KD = getKeyDistro(dom)
103  VD = getValueDistro(dom)
90 104  TD = getTimeDistro(dom)
91  generate(filename, KD, TD, V, True)
105  generate(filename, KD, VD, TD, N, True)

Changed file src/tools/workload/sample_config.xml

1 1  <document>
2  <!-- Parameters for Data generation -->\
2 3  <generator>
3 4    <output>test2.dat</output>
4    <value>
5    <!-- Datapoints -->\
6    <datapoints>
5 7      <number>400</number>
6    </value>
8    </datapoints>
9  
10    <!-- Key Distro -->\
7 11    <key>
8 12      <number>4</number>
9 13      <distribution>
10        <function>random.uniform</function>
11        <args>0,4</args>
14        <function>random.randint</function>
15        <args>0,400</args>
12 16      </distribution>
13 17    </key>
18    <!-- Value Distro -->\
19    <value>
20      <number>4</number>
21      <distribution>
22        <function>lambda x: x[0]</function>
23        <args>0,400</args>
24      </distribution>
25    </value>
26    <!-- Time Distro -->\
14 27    <time>
15 28      <distribution>
16 29        <function>random.gauss</function>
19 32    </time>
20 33  </generator>
21 34  
35  <!-- Parameters for the Shared Object -->\
22 36  <so>
37    <!-- PAO specification -->\
23 38    <pao_h_tmpl>templates/pao_h.tmpl</pao_h_tmpl>
24 39    <pao_cpp_tmpl>templates/pao_cpp.tmpl</pao_cpp_tmpl>
25    <pao_h_gen>gen/gen_pao.h</pao_h_gen>
26    <pao_cpp_gen>gen/gen_pao.cpp</pao_cpp_gen>
40    <pao_h_gen>gen_pao.h</pao_h_gen>
41    <pao_cpp_gen>gen_pao.cpp</pao_cpp_gen>
27 42    <pao_args>
28 43      <pao_class>TestPaoClass</pao_class>
29 44      <pao_state_datatype>int i;</pao_state_datatype>
30 45      <pao_add_func>this->i++;</pao_add_func>
31 46      <pao_merge_func>this->i += add_agg->i;</pao_merge_func>
32 47    </pao_args>
48  
49    <!-- Mapper specification -->\
33 50    <mapper_h_tmpl>templates/mapper_h.tmpl</mapper_h_tmpl>
34 51    <mapper_cpp_tmpl>templates/mapper_cpp.tmpl</mapper_cpp_tmpl>
35    <mapper_h_gen>gen/gen_mapper.h</mapper_h_gen>
36    <mapper_cpp_gen>gen/gen_mapper.cpp</mapper_cpp_gen>
52    <mapper_h_gen>gen_mapper.h</mapper_h_gen>
53    <mapper_cpp_gen>gen_mapper.cpp</mapper_cpp_gen>
37 54    <mapper_args>
38 55      <mapper_class>TestMapperClass</mapper_class>
39 56      <mapper_state_datatype> </mapper_state_datatype>


Reply all
Reply to author
Forward
0 new messages