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


Python Client.block方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import block [as 别名]
 def __init__(self):
     from ipyparallel import Client
     rc = Client()
     rc.block=True
     self.cpu = rc[:]
     print '{} cores ready'.format(len(self.cpu))
     self.cpu.execute('import numpy as np')
     self.cpu.execute('from sklearn.neighbors import KDTree, BallTree')
开发者ID:chongxi,项目名称:kd_knn_kde,代码行数:10,代码来源:multicore.py

示例2: main

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import block [as 别名]
def main():
    parser = OptionParser()
    parser.set_defaults(n=100)
    parser.set_defaults(tmin=1e-3)
    parser.set_defaults(tmax=1)
    parser.set_defaults(profile='default')

    parser.add_option("-n", type='int', dest='n',
        help='the number of tasks to run')
    parser.add_option("-t", type='float', dest='tmin',
        help='the minimum task length in seconds')
    parser.add_option("-T", type='float', dest='tmax',
        help='the maximum task length in seconds')
    parser.add_option("-p", '--profile', type='str', dest='profile',
        help="the cluster profile [default: 'default']")

    (opts, args) = parser.parse_args()
    assert opts.tmax >= opts.tmin, "tmax must not be smaller than tmin"

    rc = Client()
    view = rc.load_balanced_view()
    print(view)
    rc.block=True
    nengines = len(rc.ids)
    with rc[:].sync_imports():
        from IPython.utils.timing import time

    # the jobs should take a random time within a range
    times = [random.random()*(opts.tmax-opts.tmin)+opts.tmin for i in range(opts.n)]
    stime = sum(times)

    print("executing %i tasks, totalling %.1f secs on %i engines"%(opts.n, stime, nengines))
    time.sleep(1)
    start = time.time()
    amr = view.map(time.sleep, times)
    amr.get()
    stop = time.time()

    ptime = stop-start
    scale = stime/ptime

    print("executed %.1f secs in %.1f secs"%(stime, ptime))
    print("%.3fx parallel performance on %i engines"%(scale, nengines))
    print("%.1f%% of theoretical max"%(100*scale/nengines))
开发者ID:AminJamalzadeh,项目名称:ipyparallel,代码行数:46,代码来源:task_profiler.py

示例3: Client

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import block [as 别名]
potentially its memory buffers if the messages are not consumed in a streamed 
manner.

Note that the AllReduce scheme implemented with the spanning tree strategy 
impose the aggregation function to be commutative and distributive. It might 
not be the case if you implement the naive gather / reduce / broadcast strategy 
where you can reorder the partial data before performing the reduce.
"""
from __future__ import print_function

from ipyparallel import Client, Reference


# connect client and create views
rc = Client()
rc.block = True
ids = rc.ids

root_id = ids[0]
root = rc[root_id]

view = rc[:]

# run bintree.py script defining bintree functions, etc.
exec(compile(open("bintree.py").read(), "bintree.py", "exec"))

# generate binary tree of parents
btree = bintree(ids)

print("setting up binary tree interconnect:")
print_bintree(btree)
开发者ID:Ruk0610,项目名称:ipyparallel,代码行数:33,代码来源:bintree_script.py

示例4: __init__

# 需要导入模块: from ipyparallel import Client [as 别名]
# 或者: from ipyparallel.Client import block [as 别名]
 def __init__(self):
     from ipyparallel import Client
     rc = Client()
     rc.block=True
     self.cpu = rc[:]
开发者ID:chongxi,项目名称:kd_knn_kde,代码行数:7,代码来源:numba_multicore.py


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