コード例 #1
0
ファイル: pypar.py プロジェクト: uniomni/pypar
def gather(s, nums, source, vanilla=0):
    """Wrapper for easy MPI Gather receive.
     Receive data from source with tag.
     
     Create appropriate buffer and receive data.
  """

    control_info = get_control_info(s)

    protocol = control_info[0]
    typecode = control_info[1]
    s_size = nums

    if protocol == 'array':
        import Numeric
        x = Numeric.zeros(s_size * size(), typecode)
        gather_array(s, s_size, x, source)
    elif protocol == 'string':
        x = ' ' * s_size * size()
        gather_string(s, s_size, x, source)
    elif protocol == 'vanilla':
        raise "Protocol: %s unsupported for gather" % protocol
    else:
        raise "Unknown values for protocol: %s" % protocol

    return x
コード例 #2
0
ファイル: pypar.py プロジェクト: uniomni/pypar
def raw_gather(s, nums, d, source, vanilla=0):
    """Wrapper for MPI gather.
     Gather s in nums element to d (of the same nums size) from source.
     
     Automatically determine appropriate protocol
     and call corresponding send function.
     
     The variable s can be any (picklable) type, but
     Numeric variables and text strings will most efficient.
     Setting vanilla = 1 forces vanilla mode for any type.

  """

    protocol = get_control_info(s, vanilla)[0]
    if protocol == 'array':
        gather_array(s, nums, d, source)
    elif protocol == 'string':
        gather_string(s, nums, d, source)
    elif protocol == 'vanilla':
        raise "Protocol: %s unsupported for gather" % protocol
    else:
        raise "Unknown values for protocol: %s" % protocol

    return d
コード例 #3
0
                    # Plot the results of the correlation
                    Pgplot.plotxy(respow, labx='Frequency',
                                  laby='Relative Power')
                    a = raw_input("Press enter to continue...")
                    Pgplot.nextplotpage(1)
            # A very rough adaptive stepsize
            if abs(vals[-3][1] - vals[-1][1]) < 0.04:
                ddelta = ddelta * 2.0            
            delta = delta + ddelta
        # Fit a quadratic to the width values
        fit = leastSquaresFit(quadratic, (-1.0, 0.0, 1.0), vals)
        if debugout:
            print '\n   %sfit = %fx^2 + %fx + %f\n' % (myjob, fit[0][0],
                                                       fit[0][1],
                                                       fit[0][2])
        width = 2.0*math.sqrt(-0.5/fit[0][0])
        if parallel:
            newwidths = mpi.gather_string(str(width), 0)
            if myid==0:
                for proc in range(numprocs):
                    psrlist.append(string.atof(newwidths[proc]))
        else:
            psrlist.append(width)
    widths.append(psrlist)
    if debugout:
        print 'Widths are', widths[i]
    # Save our most recent orbit and width information
    cPickle.dump(widths[i], file, 1)
file.close()

コード例 #4
0
ファイル: montebinopt.py プロジェクト: MilesCranmer/presto
                    # Plot the results of the correlation
                    Pgplot.plotxy(respow, labx='Frequency',
                                  laby='Relative Power')
                    a = raw_input("Press enter to continue...")
                    Pgplot.nextplotpage(1)
            # A very rough adaptive stepsize
            if abs(vals[-3][1] - vals[-1][1]) < 0.04:
                ddelta = ddelta * 2.0            
            delta = delta + ddelta
        # Fit a quadratic to the width values
        fit = leastSquaresFit(quadratic, (-1.0, 0.0, 1.0), vals)
        if debugout:
            print '\n   %sfit = %fx^2 + %fx + %f\n' % (myjob, fit[0][0],
                                                       fit[0][1],
                                                       fit[0][2])
        width = 2.0*math.sqrt(-0.5/fit[0][0])
        if parallel:
            newwidths = mpi.gather_string(str(width), 0)
            if myid==0:
                for proc in range(numprocs):
                    psrlist.append(string.atof(newwidths[proc]))
        else:
            psrlist.append(width)
    widths.append(psrlist)
    if debugout:
        print 'Widths are', widths[i]
    # Save our most recent orbit and width information
    cPickle.dump(widths[i], file, 1)
file.close()