Exemple #1
0
def get_elwise_kernel(kernel_name, args, src, preamble=""):
    ctx = get_context()
    knl = ElementwiseKernel(
        ctx, args, src,
        kernel_name, preamble=preamble
    )
    return profile_kernel(knl, kernel_name)
Exemple #2
0
 def __init__(self, dtype, n=0):
     self.queue = get_queue()
     self.ctx = get_context()
     self.dtype = dtype
     length = n
     if n == 0:
         n = 16
     data = cl.array.empty(self.queue, n, dtype)
     self.minimum = 0
     self.maximum = 0
     self.set_data(data)
     self.length = length
     self._update_array_ref()
Exemple #3
0
    def __init__(self, particle_array):
        self._particle_array = pa = particle_array
        self._queue = get_queue()
        self._ctx = get_context()
        use_double = get_config().use_double
        self._dtype = np.float64 if use_double else np.float32
        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)
Exemple #4
0
 def __init__(self, acceleration_eval):
     self.object = acceleration_eval
     self.all_array_names = get_all_array_names(self.object.particle_arrays)
     self.known_types = get_known_types_for_arrays(self.all_array_names)
     add_address_space(self.known_types)
     predefined = dict(get_predefined_types(self.object.all_group.pre_comp))
     self.known_types.update(predefined)
     self.known_types['NBRS'] = KnownType('__global unsigned int*')
     self.data = []
     self._ctx = get_context()
     self._queue = get_queue()
     self._array_map = None
     self._array_index = None
     self._equations = {}
     self._cpu_structs = {}
     self._gpu_structs = {}
     self.calls = []
     self.program = None
Exemple #5
0
def get_elwise_kernel(kernel_name, args, src, preamble=""):
    ctx = get_context()
    from pyopencl.elementwise import ElementwiseKernel
    knl = ElementwiseKernel(ctx, args, src, kernel_name, preamble=preamble)
    return profile_kernel(knl, kernel_name)