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


Python cuda.jit方法代码示例

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


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

示例1: rasterio_windows

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import jit [as 别名]
def rasterio_windows(totalWidth,totalHeight,subWidth,subHeight):
    w_n=list(divide_chunks(list(range(totalWidth)), subWidth))
    h_n=list(divide_chunks(list(range(totalHeight)), subHeight))
    wins=[Window(w[0],h[0],len(w),len(h)) for h in h_n for w in w_n]
    # print(wins)
    print("raster windows amount:",len(wins))
    return wins


# @njit(parallel=True)
# @cuda.jit(debug=True) 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:13,代码来源:SVF_array_Final_bigRaster.py

示例2: ArrayCoordi

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import jit [as 别名]
def ArrayCoordi(rasterArray):
    relativeCellCoords=np.indices(rasterArray.shape)
    relativeCellCoords2D=np.stack(relativeCellCoords,axis=2).reshape(-1,2)
    del relativeCellCoords
    # print(relativeCellCoords2D_O)                              
    return relativeCellCoords2D


#计算首尾坐标,用到三角函数
# @profile #内存监测所标识的函数
# @cuda.jit(debug=True)
# @njit(parallel=True)
#计算首尾坐标,用到三角函数
# @profile #内存监测所标识的函数 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:16,代码来源:SVF_array_Final_bigRaster.py

示例3: equalCircleDivide

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import jit [as 别名]
def equalCircleDivide(originalCoordiArray,radious,lineProfileAmount):
    # print(originalCoordiArray.shape)
    angle_s=360/lineProfileAmount
    angle_array=np.array([i*angle_s for i in range(lineProfileAmount)],dtype=np.float32)
    #.astype(np.float16)
    opposite=np.sin(np.radians(angle_array),dtype=np.float16)*radious
    opposite=opposite.astype(np.float32)
    # print(opposite.dtype)
    yCoordi=np.add(opposite,originalCoordiArray[:,1].reshape(-1,1),dtype=np.float32)
    del opposite
    # print(yCoordi.dtype)
    
    adjacent=np.cos(np.radians(angle_array),dtype=np.float16)*radious
    xCoordi=np.add(adjacent,originalCoordiArray[:,0].reshape(-1,1),dtype=np.float32)
    del adjacent,angle_array
    # print(xCoordi.dtype)
    
    CoordiArray=np.stack((xCoordi,yCoordi),axis=-1)
    # print(CoordiArray.dtype)
    # del xCoordi,yCoordi
    return CoordiArray

#计算障碍角度和高度,以及SVF值。参考文献:城区复杂下垫面天空视域因子参数化方法——以北京鸟巢周边地区为例
# @profile #内存监测所标识的函数
# @cuda.jit(debug=True)
# @njit(parallel=True) 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:28,代码来源:SVF_array_Final_bigRaster.py

示例4: SVF

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import jit [as 别名]
def SVF(radious,equalDistance,ziList,j):
    segment=radious/equalDistance
    distanceList=np.array([i*segment for i in range(equalDistance+1)],dtype=np.float32)
    distanceList=distanceList[1:]

    ziListSub=ziList[:,:,1:]
    ziListOrigin=ziList[:,:,0]
    
    sinValues=np.true_divide(np.subtract(ziListSub,np.expand_dims(ziListOrigin, axis=2)),np.sqrt(np.add(np.power(distanceList,2),np.power(np.subtract(ziListSub,np.expand_dims(ziListOrigin, axis=2)),2))))
    
    sinMaxValue=np.amax(sinValues,axis=2)
    del sinValues
    SVFValue=1-np.true_divide(np.sum(sinMaxValue, axis=1),sinMaxValue.shape[-1])
    
    # SVFValueFn=os.path.join(saveFp,"SVFValue_%d"%(j))            
    # np.save(SVFValueFn, SVFValue)    
    # del SVFValue
    # print("SVF Value saved:%d"%i)    
    # with open(os.path.join(saveFp,"SVFValue_filenames.txt"), "a") as text_file:
    #     text_file.write("%s\n"%SVFValueFn)
        
    return SVFValue.astype(np.float32)


#数组延直线截面提取单元值
# @profile #内存监测所标识的函数
# @cuda.jit(debug=True)
# @njit(parallel=True) 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:30,代码来源:SVF_array_Final_bigRaster.py

示例5: calc_nrst_dist_gpu

# 需要导入模块: from numba import cuda [as 别名]
# 或者: from numba.cuda import jit [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.jit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。