示例#1
0
 def __init__(self, input=None, output=None, scan_expr="a+b",
              is_segment=None, dtype=np.float64, neutral='0',
              complex_map=False, backend='opencl'):
     backend = array.get_backend(backend)
     if backend not in ['opencl', 'cython']:
         raise NotImplementedError("Unsupported backend: %s. Supported "
                                   "backends: cython, opencl" %
                                   backend)
     self.tp = Transpiler(backend=backend)
     self.backend = backend
     self.input_func = input
     self.output_func = output
     self.is_segment_func = is_segment
     self.complex_map = complex_map
     if input is not None:
         self.name = 'scan_' + input.__name__
     else:
         self.name = 'scan'
     self.scan_expr = scan_expr
     self.dtype = dtype
     self.type = dtype_to_ctype(dtype)
     self.arg_keys = None
     if backend == 'cython':
         # On Windows, INFINITY is not defined so we use INFTY which we
         # internally define.
         self.neutral = neutral.replace('INFINITY', 'INFTY')
     else:
         self.neutral = neutral
     self._config = get_config()
     self.cython_gen = CythonGenerator()
     self.queue = None
     self._generate()
示例#2
0
 def __init__(self,
              reduce_expr,
              map_func=None,
              dtype_out=np.float64,
              neutral='0',
              backend='cython'):
     backend = array.get_backend(backend)
     self.tp = Transpiler(backend=backend)
     self.backend = backend
     self.func = map_func
     if map_func is not None:
         self.name = 'reduce_' + map_func.__name__
     else:
         self.name = 'reduce'
     self.reduce_expr = reduce_expr
     self.dtype_out = dtype_out
     self.type = dtype_to_ctype(dtype_out)
     if backend == 'cython':
         # On Windows, INFINITY is not defined so we use INFTY which we
         # internally define.
         self.neutral = neutral.replace('INFINITY', 'INFTY')
     else:
         self.neutral = neutral
     self._config = get_config()
     self.cython_gen = CythonGenerator()
     self.queue = None
     self.c_func = self._generate()
示例#3
0
文件: jit.py 项目: rahulgovind/pysph
 def __init__(self, func, backend='cython'):
     backend = array.get_backend(backend)
     self.tp = Transpiler(backend=backend)
     self.backend = backend
     self.name = func.__name__
     self.func = func
     self._config = get_config()
     self.cython_gen = CythonGenerator()
     self.queue = None
示例#4
0
    def __init__(self, particle_array, backend=None):
        self.backend = get_backend(backend)
        self._particle_array = pa = particle_array
        use_double = get_config().use_double
        self._dtype = np.float64 if use_double else np.float32
        self.num_real_particles = pa.num_real_particles
        self._data = {}
        self.properties = []
        self.constants = []

        for prop, ary in pa.properties.items():
            self.add_prop(prop, ary)
        for prop, ary in pa.constants.items():
            self.add_const(prop, ary)
示例#5
0
文件: jit.py 项目: rahulgovind/pysph
 def __init__(self,
              input=None,
              output=None,
              scan_expr="a+b",
              is_segment=None,
              dtype=np.float64,
              neutral='0',
              complex_map=False,
              backend='opencl'):
     backend = array.get_backend(backend)
     self.tp = Transpiler(backend=backend, incl_cluda=False)
     self.backend = backend
     self.input_func = input
     self.output_func = output
     self.is_segment_func = is_segment
     self.complex_map = complex_map
     if input is not None:
         self.name = 'scan_' + input.__name__
     else:
         self.name = 'scan'
     self.scan_expr = scan_expr
     self.dtype = dtype
     self.type = dtype_to_ctype(dtype)
     self.arg_keys = None
     if backend == 'cython':
         # On Windows, INFINITY is not defined so we use INFTY which we
         # internally define.
         self.neutral = neutral.replace('INFINITY', 'INFTY')
     else:
         self.neutral = neutral
     self._config = get_config()
     self.cython_gen = CythonGenerator()
     self.queue = None
     builtin_symbols = ['item', 'prev_item', 'last_item']
     self.builtin_types = {'i': 'int', 'N': 'int'}
     for sym in builtin_symbols:
         self.builtin_types[sym] = dtype_to_knowntype(self.dtype)