Ejemplo n.º 1
0
def mpimain(IMGDIR):
    t1 = time.time()
    comm = MPI.COMM_WORLD
    nprocs = comm.Get_size()
    rank = comm.Get_rank()

    print "Process %i has launched sucessfully" % rank

    if rank == 0:
        FileNames = filter_file_names()
        DataChunks = libutil.get_data_chunks(FileNames,nprocs)
        NDataChunks = len(DataChunks)
        print "Data divided into %i chunks" % NDataChunks
    else:
        FileNames = None
        DataChunks = None

    comm.Barrier()
    
    FileNames = comm.bcast(FileNames,root=0)   
    DataChunks = comm.bcast(DataChunks,root=0)
     
    for r in xrange(0,len(DataChunks)):
        if r == rank:
            process_jpgs(DataChunks[r])
            t2 = time.time()
            nlocalimages = len(DataChunks[r])
            print "Rank %i Processed %i images in %4.2f seconds" % (rank,nlocalimages,t2-t1)
Ejemplo n.º 2
0
def main(STARTFRAME,ENDFRAME):

    t0 = time.time()

    if STARTFRAME <= FRAMEDELTA:    # handle case where no prior frames exist to compare
        STARTFRAME = FRAMEDELTA + 1

    cstartframe = STARTFRAME - FRAMEDELTA
    cendframe =     ENDFRAME - FRAMEDELTA

    FileNames = libutil.get_file_names_for_framerange(STARTFRAME,ENDFRAME,IMGDIR,filter='.jpg')
    CompareFileNames = libutil.get_file_names_for_framerange(cstartframe,cendframe,IMGDIR,filter='.jpg')

    RefAndCompareFileNames = zip(FileNames,CompareFileNames)

    if STEPSIZE >1:
        RefAndCompareFileNames = RefAndCompareFileNames[::STEPSIZE]

    ChunksOfRefAndCompareFileNames = libutil.get_data_chunks(RefAndCompareFileNames,NPROCS)

    p = Pool(NPROCS)
    x = p.map(do_pixel_change_on_batch,ChunksOfRefAndCompareFileNames)

    aggregate_output()

    t1 = time.time()
    print "Time to run on %i cores: %5.2f" % (NPROCS,t1-t0)
Ejemplo n.º 3
0
def localmain(IMGDIR,NPROCS):
#  Run the local version without MPI.  Limited to one node.
    FileNames = filter_file_names()
    t1 = time.time()
    
    if NPROCS == 1:
        process_jpgs(FileNames)
    else:
        DataChunks = libutil.get_data_chunks(FileNames,NPROCS)
#        print "LEN: ",len(DataChunks)
        p = Pool(NPROCS)
        x = p.map(process_jpgs,DataChunks)
    t2 = time.time()
    print "Processed images in %4.2f seconds" % (t2-t1)