• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pypar.rank函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypar.rank函数的典型用法代码示例。如果您正苦于以下问题:Python rank函数的具体用法?Python rank怎么用?Python rank使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: run

def run():
    """
    Run the process, handling any parallelisation.
    """
    
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--config",
                        help="Configuration file",
                        type=str)
    parser.add_argument("-i", "--inputfile",
                        help="Input DEM file (ascii format)",
                        type=str)
    parser.add_argument("-o", "--output", 
                        help="Output path",
                        type=str)
    parser.add_argument("-v", "--verbose", 
                        help=("Verbose output (not available when invoking"
                                "parallel run)") )
                                
    args = parser.parse_args() 
                          
    logfile = 'topomult.log'
    loglevel = 'INFO'
    
    if args.verbose:
        verbose = args.verbose
    else:
        verbose = False

    if args.config:
        cfg = ConfigParser.ConfigParser()
        cfg.read(args.config)

        input_file = cfg.get('Input', 'Filename')
        output_path = cfg.get('Output', 'Path')
        logfile = cfg.get('Logging', 'LogFile')
        loglevel = cfg.get('Logging', 'LogLevel')
        verbose = cfg.get('Logging', 'Verbose')
        
    if args.inputfile:
        input_file = args.inputfile

    if args.output:
        output_path = args.output
    
    attemptParallel()
    if pp.size() > 1 and pp.rank() > 0:
        logfile += '-' + str(pp.rank())
        verbose = False  # to stop output to console

    flStartLog(logfile, loglevel, verbose)
    
    pp.barrier()
    work(input_file, output_path,
             ['n','s','e','w','ne','nw','se','sw'])
    pp.barrier()
    
    pp.finalize()
开发者ID:wcarthur,项目名称:topomultipliers,代码行数:59,代码来源:topomult.py


示例2: mprint

def mprint(txt):
    """
    Print message txt
    with indentation following the node's rank
    """
    import pypar
    
    pre = " " * 8 * pypar.rank()
    if type(txt) != type('dummy'):
        txt = txt.__str__()
    pat = "-%d-"
    print pre + (pat % pypar.rank()) + txt
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:12,代码来源:pypar_balancer.py


示例3: distributed_generator

def distributed_generator(iterable):
    """
    Distribute the values from a generator across workers.
    """
    RUN, DIE = range(2)
    P = pp.size()
    if P == 1:
        for el in iterable:
            yield el
    else:
        if pp.rank() == 0:
            it = iter(iterable)
            while True:
                try:
                    first = next(it)
                    for p in range(1, P):
                        pp.send(next(it), p, tag=RUN)
                    yield first
                except StopIteration:
                    for p in range(1, P):
                        pp.send(666, p, tag=DIE)
                    break
        else:
            while True:
                el, status = pp.receive(0, tag=pp.any_tag, return_status=True)
                if status.tag == DIE:
                    break
                yield el
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:28,代码来源:functional.py


示例4: __init__

   def __init__(self, LookPos, LookDir, LookYaw, WindowRows = 40, WindowCols = 40):
      self.LookPos = np.array(LookPos)
      self.LookDir = np.array(LookDir)
      self.Yaw = LookYaw
      self.WindowRows = WindowRows
      self.WindowCols = WindowCols
      rhop = np.linalg.norm(np.array([LookDir[0],LookDir[1]]))
      self.__Lon = math.atan2(LookDir[1], LookDir[0])
      self.__Lat = math.atan2(LookDir[2],rhop)
      self.start = time.time()
      
      # initialize the MPI
      self.numproc = pypar.size()
      self.myid =    pypar.rank()
      self.node =    pypar.get_processor_name()
      
      if self.myid != self.numproc - 1:
         self.Rows = self.WindowRows/self.numproc
         self.RowEnd = self.WindowRows/self.numproc * (self.myid+1) - 1
      else:
         self.Rows = self.WindowRows/self.numproc + self.WindowRows%self.numproc
         self.RowEnd = self.WindowRows

      self.RowStart = self.WindowRows/self.numproc * self.myid
      self.Window = np.zeros(shape = (self.Rows, self.WindowCols))
开发者ID:asdfvar,项目名称:ray-trace,代码行数:25,代码来源:RayTrace.py


示例5: __init__

    def __init__(self,
                 coordinates,
                 vertices,
                 boundary = None,
                 full_send_dict = None,
                 ghost_recv_dict = None,
                 velocity = None):

        Domain.__init__(self,
                        coordinates,
                        vertices,
                        boundary,
                        velocity = velocity,
                        full_send_dict=full_send_dict,
                        ghost_recv_dict=ghost_recv_dict,
                        processor=pypar.rank(),
                        numproc=pypar.size()
                        )

        N = self.number_of_elements


        self.communication_time = 0.0
        self.communication_reduce_time = 0.0


        print 'processor',self.processor
        print 'numproc',self.numproc
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:28,代码来源:parallel_advection.py


示例6: __init__

	def __init__( s, dataform, global_pt1, global_pt2, spatial_step=(1,1,1) ):
		s.myrank = mpi.rank()
		s.dataform = dataform 
		s.global_pt1 = global_pt1
		s.global_pt2 = global_pt2
		s.spatial_step = spatial_step
		s.step = spatial_step[0]
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:7,代码来源:output_mpi.py


示例7: __init__

    def __init__(self, is_parallel=True):
        """
        Use is_parallel = False to stop parallelism, eg when running
        several scenarios.
        """

        if is_parallel is True:
            try:
                import pypar
            except ImportError:
                self._not_parallel()
            else:
                if pypar.size() >= 2:
                    self.rank = pypar.rank()
                    self.size = pypar.size()
                    self.node = pypar.get_processor_name()
                    self.is_parallel = True
                    self.file_tag = FILE_TAG_DELIMITER + str(self.rank)
                    self.log_file_tag = FILE_TAG_DELIMITER + str(self.rank)
                else:
                    self._not_parallel()
        else:
            self._not_parallel()

        # Some constants to identify messages
        self.load_event_set = 0
开发者ID:dynaryu,项目名称:eqrm,代码行数:26,代码来源:parallel.py


示例8: __init__

    def __init__(self):

        self.proc = pypar.size()
        self.myid = pypar.rank()
        self.node = pypar.get_processor_name()

        return
开发者ID:yongwangCPH,项目名称:peat,代码行数:7,代码来源:ProteinComplexTool_parallel.py


示例9: rec_submesh

def rec_submesh(p, verbose=True):

    import pypar
    
    numproc = pypar.size()
    myid = pypar.rank()

    [submesh_cell, triangles_per_proc,\
     number_of_full_nodes, number_of_full_triangles] = rec_submesh_flat(p,verbose)
    
    # find the full triangles assigned to this processor

    lower_t = 0
    for i in range(myid):
        lower_t = lower_t+triangles_per_proc[i]
    upper_t = lower_t+triangles_per_proc[myid]

    # convert the information into a form needed by the GA
    # datastructure

    [GAnodes, GAtriangles, boundary, quantities, \
     ghost_rec, full_send, \
     tri_map, node_map, tri_l2g, node_l2g, \
     ghost_layer_width] = \
     build_local_mesh(submesh_cell, lower_t, upper_t, numproc)
    
    return GAnodes, GAtriangles, boundary, quantities,\
           ghost_rec, full_send,\
           number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\
           tri_l2g, node_l2g, ghost_layer_width
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:30,代码来源:distribute_mesh.py


示例10: broadcast_vec

def broadcast_vec( vec, i ):
	myid = p.rank()
	if myid == i:
		for j in xrange(p.size()):
			if j != myid:
				p.send(vec[i],j)
	else:
		vec[i] = p.receive(i)
开发者ID:lelou6666,项目名称:PySOL,代码行数:8,代码来源:mpi.py


示例11: all_gather

def all_gather( obj ):
	myid = p.rank()
	nproc = p.size()
	result = [ None for i in xrange(nproc) ]
	result[myid] = obj
	for i in xrange(nproc):
		broadcast_vec(result,i)
	return result
开发者ID:lelou6666,项目名称:PySOL,代码行数:8,代码来源:mpi.py


示例12: __init__

	def __init__( s, global_pt1, global_pt2, apply_direction, wavelength, propagation_direction, polarization_angle ):
		s.myrank = mpi.rank()
		s.global_pt1, s.global_pt2 = global_pt1, global_pt2
		s.apply_direction = apply_direction
		s.wavelength = wavelength
		s.propagation_direction = propagation_direction
		s.p_angle = polarization_angle

		s.gi1 = global_pt1[0]
		s.gi2 = global_pt2[0]
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:10,代码来源:tfsf_mpi.py


示例13: one_example

def one_example():
    txt = ["yes", "no", "when", "what the", "a", "5ive!"]

    rank = pypar.rank()
    size = pypar.size()

    print "I am processor %d of %d. " % (rank, size)
    for i, ele in enumerate(txt):
        if i % size == rank:
            print "i" + str(i) + " P" + str(rank) + " len " + str(len(ele)) + " for " + ele
开发者ID:vipkolon,项目名称:eqrm,代码行数:10,代码来源:just_a_parallel_spike.py


示例14: run_client

def run_client():
    '''
    Runs
    '''
    # Identification
    myid = pypar.rank() # id of this process
    nproc = pypar.size() # number of processors

    print "I am client", myid
    pypar.finalize()
开发者ID:JoErNanO,项目名称:brian,代码行数:10,代码来源:cluster_client.py


示例15: _send_event

    def _send_event(self, event, test, err=None):
        rank = pp.rank()
        if rank > 0:
            return

        data = pickle.dumps((rank, str(event), err))
        data = data.encode("latin1")
        header = struct.pack("!I", len(data))

        self.stream.write(header + data)
        self.stream.flush()
开发者ID:deepakkarki,项目名称:pypar,代码行数:11,代码来源:test.py


示例16: rank

	def rank(self):
	
		'''Returns the rank of the process in the environment
		
		This is 0 if there is only one process and for the root processor'''
	
		if Environment.isParallel:
			import pypar
			return pypar.rank()
		else:
			return 0
开发者ID:shambo001,项目名称:peat,代码行数:11,代码来源:Environment.py


示例17: print_test_stats

def print_test_stats(domain, tri_full_flag):

    myid = pypar.rank()

    for k in domain.quantities.keys():
        TestStage = domain.quantities[k]
        if myid == 0:
            print " ===== ", k, " ===== "
        full_edge = take(TestStage.edge_values, nonzero(tri_full_flag))
        print_l1_stats(full_edge)
        print_l2_stats(full_edge)
        print_linf_stats(full_edge)
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:12,代码来源:print_stats.py


示例18: test_string

    def test_string(self):
        myid, ncpu = pp.rank(), pp.size()
        data = 'ABCDEFGHIJKLMNOP'  # Length = 16
        NP = len(data) / ncpu
        X = ' ' * NP

        pp.scatter(data, 0, buffer=X)  # With buffer
        Y = pp.scatter(data, 0)  # With buffer automatically created

        self.assertEqual(X, Y)
        self.assertEqual(Y, data[myid * NP:(myid + 1) * NP])
        self.assertEqual(X, data[myid * NP:(myid + 1) * NP])
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:12,代码来源:test_scatter.py


示例19: test_without_root

    def test_without_root(self):
        myid, ncpu = pp.rank(), pp.size()
        N = 16
        NP = N / ncpu
        data = np.array(range(N)).astype('i')
        X = np.zeros(NP).astype('i')

        pp.scatter(data, buffer=X)  # With buffer
        Y = pp.scatter(data)  # With buffer automatically created

        self.assertTrue(np.allclose(X, Y))
        self.assertTrue(np.allclose(X, data[myid * NP:(myid + 1) * NP]))
        self.assertTrue(np.allclose(Y, data[myid * NP:(myid + 1) * NP]))
开发者ID:Mahdisadjadi,项目名称:pypar,代码行数:13,代码来源:test_scatter.py


示例20: collect_arr

def collect_arr(arr):
    """
    A useful collection routine for pypar.
    If you are using pypar to parallelize the set of nested loops and fill
    the resulting array, you usually need to combine the resulting array
    from several mpi threads. In that case you just can execute
    res=collect_arr(res)
    And it will add the arrays from all the threads and store them in
    the thread number 0
    """
    if pypar.rank() > 0:
        pypar.send(arr, 0)
    else:
        for i in range(1, pypar.size()):
            arr = arr + pypar.receive(i)
    return arr
开发者ID:erfanxyz,项目名称:astrolibpy,代码行数:16,代码来源:collect_arr.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pypar.receive函数代码示例发布时间:2022-05-27
下一篇:
Python pypar.finalize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap