コード例 #1
0
def main():
    checkEnvironment()
    input_schedule = sys.argv[1]
    output_schedule = sys.argv[2]
    binary_file = sys.argv[3]
    thrille_root = os.environ.get('THRILLE_ROOT')
    sched, enabled, addrlist, condlist = \
            blockremoval.readInNewSchedule(sys.argv[1])
    error = blockremoval.recordFailure(sys.argv[1])

    assert blockremoval.testSchedule(sched, error, addrlist, binary_file, \
            thrille_root)

    start_blocks = blockremoval.getTotalBlocks(sched)
    start_context = \
            preemptremoval.countContextSwitches(sched, enabled, condlist)
    start_npcs = \
            preemptremoval.countNonpreemptiveCS(sched, enabled, condlist)
    start_preemptions = \
            preemptremoval.countPreemptions(sched, enabled, condlist)

    assert (start_npcs + start_preemptions) == start_context, "sanity fail"

    simpsched = noniterativeAA(output_schedule, binary_file,\
            thrille_root, sched,\
            enabled, addrlist, error)

    blockremoval.outputResult(simpsched, error, addrlist,\
            binary_file, thrille_root, output_schedule)

    sched, enabled, addrlist, condlist = \
            blockremoval.readInNewSchedule(output_schedule)
    end_blocks = blockremoval.getTotalBlocks(sched)
    end_context = \
            preemptremoval.countContextSwitches(sched, enabled, condlist)
    end_npcs = \
            preemptremoval.countNonpreemptiveCS(sched, enabled, condlist)
    end_preemptions = \
            preemptremoval.countPreemptions(sched, enabled, condlist)
    assert (end_npcs + end_preemptions) == end_context, "sanity fail"

    print "Start:\n\tblocks:", start_blocks, 
    print "\n\tcontext switches:", start_context, "\n\t\tpreemptions:",
    print start_preemptions, "\n\t\tnon-preemptive switches:", start_npcs

    print
    print "End:\n\tblocks:", end_blocks,
    print "\n\tcontext switches:", end_context, "\n\t\tpreemptions:",
    print end_preemptions, "\n\t\tnon-preemptive switches:", end_npcs
コード例 #2
0
ファイル: noniterativeBB.py プロジェクト: qingkaishi/Thrille
def main():
    checkEnvironment()
    input_schedule = sys.argv[1]
    output_schedule = sys.argv[2]
    binary_file = sys.argv[3]
    thrille_root = os.environ.get('THRILLE_ROOT')
    sched, enabled, addrlist, condlist = \
            blockremoval.readInNewSchedule(sys.argv[1])
    error = blockremoval.recordFailure(sys.argv[1])

    assert blockremoval.testSchedule(sched, error, addrlist, \
            binary_file, thrille_root)

    start_blocks = blockremoval.getTotalBlocks(sched)
    start_context = \
            preemptremoval.countContextSwitches(sched, enabled, condlist)
    start_npcs = \
            preemptremoval.countNonpreemptiveCS(sched, enabled, condlist)
    start_preemptions = \
            preemptremoval.countPreemptions(sched, enabled, condlist)

    assert (start_npcs + start_preemptions) == start_context, "sanity fail"
    
    simpsched = noniterativeBB(output_schedule, binary_file,\
            thrille_root, sched,\
            enabled, addrlist, error)
    
    blockremoval.outputResult(simpsched, error, addrlist, \
            binary_file, thrille_root, output_schedule)

    sched, enabled, addrlist, condlist = \
            blockremoval.readInNewSchedule(output_schedule)
    end_blocks = blockremoval.getTotalBlocks(sched)
    end_context = \
            preemptremoval.countContextSwitches(sched, enabled, condlist)
    end_npcs = \
            preemptremoval.countNonpreemptiveCS(sched, enabled, condlist)
    end_preemptions = \
            preemptremoval.countPreemptions(sched, enabled, condlist)
    assert (end_npcs + end_preemptions) == end_context, "sanity fail"

    print "Start:\n\tblocks:", start_blocks, 
    print "\n\tcontext switches:", start_context, "\n\t\tpreemptions:",
    print start_preemptions, "\n\t\tnon-preemptive switches:", start_npcs

    print
    print "End:\n\tblocks:", end_blocks,
    print "\n\tcontext switches:", end_context, "\n\t\tpreemptions:",
    print end_preemptions, "\n\t\tnon-preemptive switches:", end_npcs
コード例 #3
0
ファイル: multiexp.py プロジェクト: nicholasjalbert/Thrille
def getNewErrorSchedule(binary_file, thrille_root):
    assert os.path.exists(os.path.join(thrille_root, "bin/liblockrace.so"))
    assert os.path.exists(os.path.join(thrille_root, "bin/librandact.so"))
    binarydir, bin = os.path.split(binary_file)
    curr_dir = os.getcwd()
    if binarydir != "":
        os.chdir(binarydir)
    binflags = blockremoval.getBinaryFlags()
    binflags.insert(0, bin)
    print "NOTE: automatic race detection is disabled"
    # doRaceDetect(binary_file, binflags, thrille_root)
    assert os.path.exists("./thrille-randomactive")
    exit_status = 0
    sched = []
    enabled = []
    error = ""
    count = 0
    while True:
        clearOldThrilleSchedule()
        count += 1
        if count > 1000:
            raw_input("100 iterations with no error--continue?")
            count = 0
        exit_status = executePreload(thrille_root, "librandact.so", binary_file, binflags)
        print "Thrille Random Active Exit Status:", exit_status
        sched, enabled, addrlist, condlist = blockremoval.readInNewSchedule(thrille_output_schedule)
        error = blockremoval.recordFailure(thrille_output_schedule)
        if error != None:
            if blockremoval.testSchedule(sched, error, addrlist, binary_file, thrille_root):
                os.chdir(curr_dir)
                return sched, enabled, addrlist, condlist, error
            else:
                assert False, "Error in Thrille makes replay impossible"
コード例 #4
0
ファイル: multiexp.py プロジェクト: nicholasjalbert/Thrille
def runAlgoNBB(save, bin, thrille, sched, en, addrlist, err):
    # NBB
    simpsched_NBB = noniterativeBB.noniterativeBB(save, bin, thrille, sched, en, addrlist, err)

    blockremoval.outputResult(simpsched_NBB, err, addrlist, bin, thrille, save)

    NBBsched, NBBenabled, NBBaddrlist, NBBcondlist = blockremoval.readInNewSchedule(save)

    assert simpsched_NBB == NBBsched
    return NBBsched, NBBenabled, NBBaddrlist, NBBcondlist
コード例 #5
0
ファイル: multiexp.py プロジェクト: nicholasjalbert/Thrille
def runAlgoNAA(save, bin, thrille, sched, en, addrlist, err):
    # NAA
    simpsched_NAA = noniterativeAA.noniterativeAA(save, bin, thrille, sched, en, addrlist, err)

    blockremoval.outputResult(simpsched_NAA, err, addrlist, bin, thrille, save)

    NAAsched, NAAenabled, NAAaddrlist, NAAcondlist = blockremoval.readInNewSchedule(save)

    assert simpsched_NAA == NAAsched
    return NAAsched, NAAenabled, NAAaddrlist, NAAcondlist
コード例 #6
0
ファイル: noniterativeBB.py プロジェクト: qingkaishi/Thrille
def noniterativeBB(output_schedule, binary_file, thrille_root,\
        sched, enabled, addrlist, error):
    brsched = blockremoval.blockRemovalAlgorithmB( \
            binary_file, thrille_root, sched, enabled, addrlist, error)
    
    outdir, out = os.path.split(output_schedule)
    tmpout = os.path.join(outdir, "block-sched")

    blockremoval.outputResult(brsched, error, addrlist, binary_file,\
            thrille_root, tmpout) 
    newsched, newenabled, newaddrlist, newcondlist  = \
            blockremoval.readInNewSchedule(tmpout)

    assert blockremoval.recordFailure(tmpout) == error, "err fail"

    simpsched = preemptremoval.preemptRemovalAlgorithmB(binary_file, \
            output_schedule, thrille_root, newsched, newenabled, \
            newaddrlist, newcondlist, error)
    return simpsched
コード例 #7
0
ファイル: multiexp.py プロジェクト: nicholasjalbert/Thrille
def runAlgoIBB(save, bin, thrille, sched, en, addrlist, err):
    prev_IBBsched = sched
    prev_IBBenabled = en
    IBBsched = []
    IBBenabled = []
    IBBaddrlist = []
    IBBcondlist = []
    while True:
        simpsched_IBB = noniterativeBB.noniterativeBB(save, bin, thrille, prev_IBBsched, prev_IBBenabled, addrlist, err)

        blockremoval.outputResult(simpsched_IBB, err, addrlist, bin, thrille, save)

        IBBsched, IBBenabled, IBBaddrlist, IBBcondlist = blockremoval.readInNewSchedule(save)

        assert simpsched_IBB == IBBsched
        assert IBBaddrlist == addrlist

        if IBBsched == prev_IBBsched:
            break
        else:
            prev_IBBsched = IBBsched
            prev_IBBenabled = IBBenabled

    return IBBsched, IBBenabled, IBBaddrlist, IBBcondlist
コード例 #8
0
ファイル: multiexp.py プロジェクト: nicholasjalbert/Thrille
def runAlgoIAA(save, bin, thrille, sched, en, addrlist, err):
    prev_IAAsched = sched
    prev_IAAenabled = en
    IAAsched = []
    IAAenabled = []
    IAAaddrlist = []
    IAAcondlist = []
    while True:
        simpsched_IAA = noniterativeAA.noniterativeAA(save, bin, thrille, prev_IAAsched, prev_IAAenabled, addrlist, err)

        blockremoval.outputResult(simpsched_IAA, err, addrlist, bin, thrille, save)

        IAAsched, IAAenabled, IAAaddrlist, IAAcondlist = blockremoval.readInNewSchedule(save)

        assert simpsched_IAA == IAAsched
        assert IAAaddrlist == addrlist

        if IAAsched == prev_IAAsched:
            break
        else:
            prev_IAAsched = IAAsched
            prev_IAAenabled = IAAenabled

    return IAAsched, IAAenabled, IAAaddrlist, IAAcondlist
コード例 #9
0
def preemptRemovalAlgorithmB(binary_file, output_schedule, thrille_root, \
        sched, enabled, addrlist, condlist, error):
    start_preemptions = countPreemptions(sched, enabled, condlist)
    minimal_frontier = 0
    number_success = 0
    while minimal_frontier < len(sched):
        curr_thread = sched[minimal_frontier]
        target = minimal_frontier + 1
        if target < len(sched):
            if curr_thread == sched[target]:
                minimal_frontier += 1
                continue
            if curr_thread not in enabled[target]:
                minimal_frontier += 1
                continue
        while target < len(sched):
            if sched[target] == curr_thread:
                newsched = moveSwitchAfterFrontier(sched, \
                        minimal_frontier, target)
                success = blockremoval.testSchedule(newsched, error, addrlist,\
                        binary_file, thrille_root)
                if (success):
                    old_sched_len = len(sched)
                    binpath, binfile = os.path.split(binary_file)
                    fin = os.path.join(binpath, thrille_output_schedule)
                    sched, enabled, addrlist, condlist = \
                            blockremoval.readInNewSchedule(fin)
                    if ("segfault" not in error):
                        assert old_sched_len == len(sched)
                    else:
                        if len(sched) != old_sched_len:
                            print "Segfault weirdness"
                            print "old schedule length:", old_sched_len
                            print "new schedule length:", len(sched)

                    print "Preemptions at start:", start_preemptions
                    print "Preemptions now:", countPreemptions(sched, \
                            enabled, condlist)
                    print "Frontier at", minimal_frontier, "out of", 
                    print len(sched)
                    print "Number of swaps:", number_success
                    number_success += 1
                    if number_success % 50 == 0:
                        print "***OUTPUT***"
                        blockremoval.outputResult(sched, error, addrlist, \
                                binary_file, thrille_root, output_schedule)
                    break
                else:
                    print "Preemptions at start:", start_preemptions
                    print "Preemptions now:", countPreemptions(sched, \
                            enabled, condlist)
                    print "Frontier at", minimal_frontier, "out of",
                    print len(sched)
                    print "Number of swaps:", number_success
                    break
            else:
                target += 1
        minimal_frontier += 1
    assert blockremoval.testSchedule(sched, error, addrlist, binary_file, \
            thrille_root), "sanity fail"
    return sched
コード例 #10
0
def preemptRemovalAlgorithmB(binary_file, output_schedule, thrille_root, \
        sched, enabled, addrlist, condlist, error):
    start_preemptions = countPreemptions(sched, enabled, condlist)
    minimal_frontier = 0
    number_success = 0
    while minimal_frontier < len(sched):
        curr_thread = sched[minimal_frontier]
        target = minimal_frontier + 1
        if target < len(sched):
            if curr_thread == sched[target]:
                minimal_frontier += 1
                continue
            if curr_thread not in enabled[target]:
                minimal_frontier += 1
                continue
        while target < len(sched):
            if sched[target] == curr_thread:
                newsched = moveSwitchAfterFrontier(sched, \
                        minimal_frontier, target)
                success = blockremoval.testSchedule(newsched, error, addrlist,\
                        binary_file, thrille_root)
                if (success):
                    old_sched_len = len(sched)
                    binpath, binfile = os.path.split(binary_file)
                    fin = os.path.join(binpath, thrille_output_schedule)
                    sched, enabled, addrlist, condlist = \
                            blockremoval.readInNewSchedule(fin)
                    if ("segfault" not in error):
                        assert old_sched_len == len(sched)
                    else:
                        if len(sched) != old_sched_len:
                            print "Segfault weirdness"
                            print "old schedule length:", old_sched_len
                            print "new schedule length:", len(sched)

                    print "Preemptions at start:", start_preemptions
                    print "Preemptions now:", countPreemptions(sched, \
                            enabled, condlist)
                    print "Frontier at", minimal_frontier, "out of",
                    print len(sched)
                    print "Number of swaps:", number_success
                    number_success += 1
                    if number_success % 50 == 0:
                        print "***OUTPUT***"
                        blockremoval.outputResult(sched, error, addrlist, \
                                binary_file, thrille_root, output_schedule)
                    break
                else:
                    print "Preemptions at start:", start_preemptions
                    print "Preemptions now:", countPreemptions(sched, \
                            enabled, condlist)
                    print "Frontier at", minimal_frontier, "out of",
                    print len(sched)
                    print "Number of swaps:", number_success
                    break
            else:
                target += 1
        minimal_frontier += 1
    assert blockremoval.testSchedule(sched, error, addrlist, binary_file, \
            thrille_root), "sanity fail"
    return sched