get_group_id = RuntimeFunction('get_group_id', cl.cl_uint, cl.cl_uint) get_local_id = RuntimeFunction('get_local_id', cl.cl_uint, cl.cl_uint) get_num_groups = RuntimeFunction('get_num_groups', cl.cl_uint, cl.cl_uint) get_global_size = RuntimeFunction('get_global_size', cl.cl_uint, cl.cl_uint, doc='''Returns the number of global work-items specified for dimension identified by dimindx. This value is given by the global_work_size argument to ''') cl_mem_fence_flags = RuntimeType('cl_mem_fence_flags') CLK_LOCAL_MEM_FENCE = cl_mem_fence_flags('CLK_LOCAL_MEM_FENCE') CLK_GLOBAL_MEM_FENCE = cl_mem_fence_flags('CLK_GLOBAL_MEM_FENCE') barrier = RuntimeFunction('barrier', None, cl_mem_fence_flags) native_sin = RuntimeFunction('native_sin', cl.cl_float, cl.cl_float) #=============================================================================== # Math builtin functions #=============================================================================== import math sin = RuntimeFunction('sin', lambda argtype: argtype, gentype(cl.cl_float), builtin=math.sin) cos = RuntimeFunction('cos', lambda argtype: argtype, gentype(cl.cl_float), builtin=math.cos)
G = 100000.0 #Q = 0.1 a[fx_ind,gid] = 0.0 a[fy_ind,gid] = 0.0 for i in range(n): if not(i==gid): diff_x = a[px_ind,gid] - a[px_ind,i] diff_y = a[py_ind,gid] - a[py_ind,i] distance = clrt.math.sqrt(diff_x*diff_x + diff_y*diff_y) forceNorm = G*a[m_ind,gid]*a[m_ind,i]/ pow((distance*distance) + 200.0**2,3/2.0) a[fx_ind,gid] -= forceNorm*diff_x/distance a[fy_ind,gid] -= forceNorm*diff_y/distance from clyther.rttt import RuntimeFunction, RuntimeType, gentype, sgentype, ugentype import math sqrt = RuntimeFunction('sqrt', lambda argtype: float, gentype(), doc='Returns sqrt()', builtin=math.sqrt ) pow = RuntimeFunction('pow', lambda argtype1,argtype2: float, gentype(), doc='Returns pow()', builtin=math.pow )
cl.cl_uint, cl.cl_uint, doc='''Returns the number of global work-items specified for dimension identified by dimindx. This value is given by the global_work_size argument to ''') cl_mem_fence_flags = RuntimeType('cl_mem_fence_flags') CLK_LOCAL_MEM_FENCE = cl_mem_fence_flags('CLK_LOCAL_MEM_FENCE') CLK_GLOBAL_MEM_FENCE = cl_mem_fence_flags('CLK_GLOBAL_MEM_FENCE') barrier = RuntimeFunction('barrier', None, cl_mem_fence_flags) native_sin = RuntimeFunction('native_sin', cl.cl_float, cl.cl_float) #=============================================================================== # Math builtin functions #=============================================================================== import math sin = RuntimeFunction('sin', lambda argtype: argtype, gentype(cl.cl_float), builtin=math.sin) cos = RuntimeFunction('cos', lambda argtype: argtype, gentype(cl.cl_float), builtin=math.cos)