当前位置: 首页>>代码示例>>Python>>正文


Python cuda.grid方法代码示例

本文整理汇总了Python中numba.cuda.grid方法的典型用法代码示例。如果您正苦于以下问题:Python cuda.grid方法的具体用法?Python cuda.grid怎么用?Python cuda.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numba.cuda的用法示例。


在下文中一共展示了cuda.grid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: iterSearch

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def iterSearch(padu, padv, paddistorted, resultImg, maxIter, precision, resultMsk):
    
    H = padu.shape[0] - 1
    W = padu.shape[1] - 1
    
    start_x, start_y = cuda.grid(2)
    stride_x, stride_y = cuda.gridsize(2)
    
    for xr in range(start_x, W, stride_x):
        for yr in range(start_y, H, stride_y):

            i,j = iterSearchShader(padu, padv, xr, yr, maxIter, precision)

            if(i != -1) and (j != -1):
                resultImg[yr, xr,0] = biInterpolation(paddistorted[:,:,0], i, j)
                resultImg[yr, xr,1] = biInterpolation(paddistorted[:,:,1], i, j)
                resultImg[yr, xr,2] = biInterpolation(paddistorted[:,:,2], i, j)
            else:
                resultMsk[yr, xr] = 255 
开发者ID:xiaoyu258,项目名称:GeoProj,代码行数:21,代码来源:resampling.py

示例2: iterSearchGrey

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def iterSearchGrey(padu, padv, paddistorted, resultImg, maxIter, precision, resultMsk):
    
    H = padu.shape[0] - 1
    W = padu.shape[1] - 1
  
    start_x, start_y = cuda.grid(2)
    stride_x, stride_y = cuda.gridsize(2)
    
    for xr in range(start_x, W, stride_x):
        for yr in range(start_y, H, stride_y):

            i,j = iterSearchShader(padu, padv, xr, yr, maxIter, precision)

            if(i != -1) and (j != -1):
                resultImg[yr, xr] = biInterpolation(paddistorted[:,:], i, j)
            else:
                resultMsk[yr, xr] = 255 
开发者ID:xiaoyu258,项目名称:GeoProj,代码行数:19,代码来源:resampling.py

示例3: _cu_arange

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def _cu_arange(ary, count):
    i = cuda.grid(1)
    if i < count:
        ary[i] = i 
开发者ID:numba,项目名称:pyculib,代码行数:6,代码来源:radixsort.py

示例4: mat3_mul_kernel

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def mat3_mul_kernel(m0, m1, out):
    i, j = cuda.grid(2)
    m0_mat = m0[i, j, :, :]
    m1_mat = m1[i, j, :, :]
    out_mat = out[i, j, :, :]
    mat3_mul(m0_mat, m1_mat, out_mat)
    # cuda.syncthreads() 
开发者ID:sfu-gruvi-3dv,项目名称:sanet_relocal_demo,代码行数:9,代码来源:numba_mat_opt.py

示例5: mat3_mul_vec_kernel

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def mat3_mul_vec_kernel(m, v, out):
    i, j = cuda.grid(2)
    m_mat = m[i, j, :, :]
    v_vec = v[i, j, :]
    out_vec = out[i, j, :]
    mat3_vec3_mul(m_mat, v_vec, out_vec)


# TEST 
开发者ID:sfu-gruvi-3dv,项目名称:sanet_relocal_demo,代码行数:11,代码来源:numba_mat_opt.py

示例6: calc_nrst_dist_gpu

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import grid [as 别名]
def calc_nrst_dist_gpu(gids,xs,ys,densities):   
    from numba import cuda, float64,float32
    @cuda.jit
    def calc_nrst_dist_cuda(gids,xs,ys,densities,nrst_dists,parent_gids,n):
        '''
        Numba Cuda code for calculate nearest point with higher density.
        gids: identifier of geometry
        xs: lons' array
        ys: lats' array
        densities: densities' array
        nrst_dists: results of the nearest distance
        parent_gids: results of gid of the nearest point with higher density
        n: array size
        '''
        i=cuda.grid(1)
        if i<n:
            xi=xs[i]
            yi=ys[i]
            density=densities[i]
            nrst_dist=float32(1e100)
            parent_gid=np.int(-1)
            for j in range(n):
                xd=xs[j]-xi
                yd=ys[j]-yi
                gidd=gids[j]
                distpow2=xd**2+yd**2
                if densities[j]>density and distpow2<nrst_dist:
                    nrst_dist=distpow2
                    parent_gid=gidd
            nrst_dists[i]=math.sqrt(float64(nrst_dist))
            parent_gids[i]=parent_gid
    
    n=xs.shape[0]
    xs=np.ascontiguousarray((xs-xs.min()).astype(np.float32))
    ys=np.ascontiguousarray((ys-ys.min()).astype(np.float32))
    threadsperblock = 1024
    blockspergrid = np.int((n + (threadsperblock - 1)) / threadsperblock)
    dev_nrst_dists=cuda.device_array(n)
    dev_parent_gids=cuda.device_array_like(gids)
    calc_nrst_dist_cuda[blockspergrid,threadsperblock](cuda.to_device(np.ascontiguousarray(gids))\
                       ,cuda.to_device(xs),cuda.to_device(ys),cuda.to_device(np.ascontiguousarray(densities))\
                       ,dev_nrst_dists,dev_parent_gids,n)
    return (dev_nrst_dists.copy_to_host(),dev_parent_gids.copy_to_host()) 
开发者ID:lopp2005,项目名称:HiSpatialCluster,代码行数:45,代码来源:section_gpu.py


注:本文中的numba.cuda.grid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。