Guest User

Reduction Hack

a guest
Jun 10th, 2011
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *** reduction.py 2010-10-16 14:30:39.000000000 -0600
  2. --- mymod.py 2011-06-10 13:29:24.609524758 -0600
  3. ***************
  4. *** 144,149 ****
  5. --- 144,150 ----
  6. "name": name,
  7. "preamble": preamble
  8. }
  9. +
  10. return SourceModule(src, options=options, keep=keep)
  11.  
  12.  
  13. ***************
  14. *** 175,182 ****
  15. class ReductionKernel:
  16. def __init__(self, dtype_out,
  17. neutral, reduce_expr, map_expr=None, arguments=None,
  18. ! name="reduce_kernel", keep=False, options=[], preamble=""):
  19. !
  20. self.dtype_out = dtype_out
  21.  
  22. self.block_size = 512
  23. --- 176,183 ----
  24. class ReductionKernel:
  25. def __init__(self, dtype_out,
  26. neutral, reduce_expr, map_expr=None, arguments=None,
  27. ! name="reduce_kernel", keep=False, options=[], preamble="", hack=False):
  28. ! self.hack = hack
  29. self.dtype_out = dtype_out
  30.  
  31. self.block_size = 512
  32. ***************
  33. *** 189,194 ****
  34. --- 190,203 ----
  35. self.stage1_func = s1_func.prepared_async_call
  36.  
  37. # stage 2 has only one input and no map expression
  38. + if hack:
  39. + s2_func, self.stage2_arg_types = get_reduction_kernel_and_types(
  40. + dtype_to_ctype(dtype_out), self.block_size,
  41. + neutral, reduce_expr, arguments="float *in, " + arguments,
  42. + name=name+"_stage2", keep=keep, options=options,
  43. + preamble=preamble)
  44. + self.stage2_func = s2_func.prepared_async_call
  45. + else:
  46. s2_func, self.stage2_arg_types = get_reduction_kernel_and_types(
  47. dtype_to_ctype(dtype_out), self.block_size,
  48. neutral, reduce_expr,
  49. ***************
  50. *** 256,261 ****
  51. --- 265,273 ----
  52. else:
  53. f = s2_func
  54. arg_types = self.stage2_arg_types
  55. + if self.hack:
  56. + args = [result].extend(args)
  57. + else:
  58. args = [result]
RAW Paste Data