示例#1
0
def flat_main(pool, SEQ, mask, num_procs):
    """Using multiproccessing to see if it is faster
    :returns: The sum over SEQ

    """
    arrays  = parutils.partition(SEQ, num_procs)
    masks   = parutils.partition(mask, num_procs)
    result  = parutils.inner_product(pool, arrays, masks, num_procs)
    return result
示例#2
0
def flat_main(pool, SEQ, num_procs):
    """Using multiproccessing to see if it is faster
    :returns: The sum over SEQ

    """
    arrays  = parutils.partition(SEQ, num_procs)
    count   = parutils.packed_scan(pool, parutils.serial_scan, arrays, num_procs)
    return count
示例#3
0
def flat_main(pool, num_procs):
    """Using multiproccessing to see if it is faster
    :returns: The sum over SEQ

    """
    timer.tic("map_flat")
    bools = pool.map(is_prime, SEQ, scale)
    timer.toc("map_flat")
    timer.tic("list_flat")
    answers = list(bools)
    timer.toc("list_flat")
    timer.tic("partition")
    arrays  = parutils.partition(answers, num_procs)
    timer.toc("partition")
    timer.tic("reduce_flat")
    count   = parutils.packed_reduction(pool, sum, arrays, num_procs)
    timer.toc("reduce_flat")
    return count