示例#1
0
def main(argv):
    dirA = "."
    dirB = None
    dryrun = False
    labelA = None
    labelB = None
    nbatch = 1
    outdir = "."
    speedup = True
    datatype = "time"
    shortrun = False
    docformat = "pdf"
    devicenum = 0
    doAsy = True
    nsample = 10
    rundims = [1, 2, 3]
    runtype = "benchmark"
    secondtype = "none"

    try:
        opts, args = getopt.getopt(argv, "hA:D:f:B:Tt:a:b:o:S:sg:d:N:R:y:")
    except getopt.GetoptError:
        print("error in parsing arguments.")
        print(usage)
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h"):
            print(usage)
            exit(0)
        elif opt in ("-A"):
            dirA = arg
        elif opt in ("-B"):
            dirB = arg
        elif opt in ("-a"):
            labelA = arg
        elif opt in ("-b"):
            labelB = arg
        elif opt in ("-o"):
            outdir = arg
        elif opt in ("-T"):
            dryrun = True
        elif opt in ("-s"):
            shortrun = True
        elif opt in ("-g"):
            if int(arg) == 0:
                doAsy = False
            if int(arg) == 1:
                doAsy = True
        elif opt in ("-d"):
            devicenum = int(arg)
        elif opt in ("-D"):
            rundims = []
            for val in arg.split(','):
                rundims.append(int(val))
        elif opt in ("-N"):
            nsample = int(arg)
        elif opt in ("-S"):
            if int(arg) == 0:
                speedup = False
            if int(arg) == 1:
                speedup = True
        elif opt in ("-t"):
            if arg not in ["time", "gflops", "roofline"]:
                print("data type must be time or gflops or roofline")
                print(usage)
                sys.exit(1)
            datatype = arg
        elif opt in ("-y"):
            if arg not in ["none", "gflops"]:
                print("data type must be gflops or none")
                print(usage)
                sys.exit(1)
            secondtype = arg
        elif opt in ("-R"):
            if arg not in ["report", "benchmark", "efficiency"]:
                print("data type must be gflops or none")
                print(usage)
                sys.exit(1)
            runtype = arg
        elif opt in ("-f"):
            goodvals = ["pdf", "docx"]
            if arg not in goodvals:
                print("error: format must in " + " ".join(goodvals))
                print(usage)
                sys.exit(1)
            docformat = arg

    if labelA == None:
        labelA = dirA

    print("rundims:")
    print(rundims)

    print("dirA: " + dirA)
    print("labelA: " + labelA)

    if not dryrun and not binaryisok(dirA, "rocfft-rider"):
        print("unable to find " + "rocfft-rider" + " in " + dirA)
        print("please specify with -A")
        sys.exit(1)

    dirlabel = [[dirA, labelA]]
    if not dirB == None:
        if labelB == None:
            labelB = dirB

        print("dirB: " + dirB)
        print("labelB: " + labelB)
        if not dryrun and not binaryisok(dirB, "rocfft-rider"):
            print("unable to find " + "rocfft-rider" + " in " + dirB)
            print("please specify with -B")
            sys.exit(1)

        dirlabel.append([dirB, labelB])
    print("outdir: " + outdir)
    if shortrun:
        print("short run")
    print("output format: " + docformat)
    print("device number: " + str(devicenum))

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    if not dryrun:
        import getspecs
        specs = "Host info:\n"
        specs += "\thostname: " + getspecs.gethostname() + "\n"
        specs += "\tcpu info: " + getspecs.getcpu() + "\n"
        specs += "\tram: " + getspecs.getram() + "\n"
        specs += "\tdistro: " + getspecs.getdistro() + "\n"
        specs += "\tkernel version: " + getspecs.getkernel() + "\n"
        specs += "\trocm version: " + getspecs.getrocmversion() + "\n"
        specs += "Device info:\n"
        specs += "\tdevice: " + getspecs.getdeviceinfo(devicenum) + "\n"
        specs += "\tvbios version: " + getspecs.getvbios(devicenum) + "\n"
        specs += "\tvram: " + getspecs.getvram(devicenum) + "\n"
        specs += "\tperformance level: " + getspecs.getperflevel(
            devicenum) + "\n"
        specs += "\tsystem clock: " + getspecs.getsclk(devicenum) + "\n"
        specs += "\tmemory clock: " + getspecs.getmclk(devicenum) + "\n"

        with open(os.path.join(outdir, "specs.txt"), "w+") as f:
            f.write(specs)

        with open(os.path.join(outdir, "gpuid.txt"), "w") as f:
            f.write(getspecs.getgpuid(devicenum))

    figs = []

    if runtype == "benchmark":
        figs = benchfigs(rundims, shortrun, dirlabel)
    if runtype == "report":
        figs = reportfigs(rundims, shortrun, dirlabel)
    if runtype == "efficiency":
        figs = efficiencyfigs(rundims, shortrun, dirlabel)
    just1dc2crad2 = runtype == "efficiency"

    for idx, fig in enumerate(figs):
        for idx2, fig2 in enumerate(figs):
            if idx != idx2 and fig.name == fig2.name:
                print("figures have the same name!")
                print(fig.name)
                print(fig2.name)
                sys.exit(1)

    for fig in figs:
        print(fig.name)
        for run in fig.runs:
            print(" ".join(run.runcmd(outdir, nsample)))
            if not dryrun:
                run.executerun(outdir, nsample)

        ncompare = len(dirlabel) if speedup else 0
        print(fig.labels())
        #plotgflops = runtype == "submission" and not datatype == "gflops"
        print(
            fig.asycmd(outdir, docformat, datatype, ncompare, secondtype,
                       just1dc2crad2))
        fig.executeasy(outdir, docformat, datatype, ncompare, secondtype,
                       just1dc2crad2)

    if docformat == "pdf":
        maketex(figs, outdir, nsample, secondtype)
    if docformat == "docx":
        makedocx(figs, outdir, nsample, secondtype)

    print("Finished!  Output in " + outdir)
示例#2
0
def main(argv):
    dirA = "."
    dirB = None
    dryrun = False
    labelA = None
    labelB = None
    inputYaml = ""
    outdir = "."
    speedup = False
    datatype = "gflops"
    # shortrun = False
    docformat = "pdf"
    devicenum = 0
    doAsy = False
    nsample = 10

    try:
        opts, args = getopt.getopt(argv,"hA:f:B:Tt:a:b:o:S:sg:d:N:i:")
    except getopt.GetoptError:
        print("error in parsing arguments.")
        print(usage)
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h"):
            print(usage)
            exit(0)
        elif opt in ("-A"):
            dirA = arg
        elif opt in ("-B"):
            dirB = arg
        elif opt in ("-a"):
            labelA = arg
        elif opt in ("-b"):
            labelB = arg
        elif opt in ("-i"):
            inputYaml = arg
        elif opt in ("-o"):
            outdir = arg
        elif opt in ("-T"):
            dryrun = True
        # elif opt in ("-s"):
        #     shortrun = True
        elif opt in ("-g"):
            if int(arg) == 0:
                doAsy = False
            if int(arg) == 1:
                doAsy = True
        elif opt in ("-d"):
            devicenum = int(arg)
        elif opt in ("-N"):
            nsample = int(arg)
        elif opt in ("-S"):
            if int(arg) == 0:
                speedup = False
            if int(arg) == 1:
                speedup = True
        elif opt in ("-t"):
            if arg not in ["time", "gflops"]:
                print("data type must be time or gflops")
                print(usage)
                sys.exit(1)
            datatype = arg
        elif opt in ("-f"):
            goodvals = ["pdf", "docx"]
            if arg not in goodvals:
                print("error: format must in " + " ".join(goodvals))
                print(usage)
                sys.exit(1)
            docformat = arg

    if os.path.isfile(inputYaml)==False:
        print("unable to find input yaml file: " + inputYaml)
        sys.exit(1)

    if labelA == None:
        labelA = dirA


    print("dirA: "+ dirA)
    print("labelA: "+ labelA)

    if not dryrun and not binaryisok(dirA, "rocblas-bench"):
        print("unable to find " + "rocblas-bench" + " in " + dirA)
        print("please specify with -A")
        sys.exit(1)

    dirlist = [[dirA, labelA]]
    if not dirB == None:
        if labelB == None:
            labelB = dirB

        print("dirB: "+ dirB)
        print("labelB: "+ labelB)
        if not dryrun and not binaryisok(dirB, "rocblas-bench"):
            print("unable to find " + "rocblas-bench" + " in " + dirB)
            print("please specify with -B")
            sys.exit(1)

        dirlist.append([dirB, labelB])
    print("outdir: " + outdir)
    # if shortrun:
    #     print("short run")
    print("output format: " + docformat)
    print("device number: " + str(devicenum))

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    rocBlasVersion = getVersion(dirA)
    sclk = getspecs.getsclk(devicenum)
    device = getspecs.getdeviceinfo(devicenum)

    if not dryrun:
        specs = "Host info:\n"
        specs += "\thostname: " + getspecs.gethostname() + "\n"
        specs += "\tcpu info: " + getspecs.getcpu() + "\n"
        specs += "\tram: " + getspecs.getram() + "\n"
        specs += "\tdistro: " + getspecs.getdistro() + "\n"
        specs += "\tkernel version: " + getspecs.getkernel() + "\n"
        specs += "\trocm version: " + getspecs.getrocmversion() + "\n"
        specs += "\t" + rocBlasVersion.version + "\n"
        specs += "Device info:\n"
        specs += "\tdevice: " + device + "\n"
        specs += "\tvbios version: " + getspecs.getvbios(devicenum) + "\n"
        specs += "\tvram: " + getspecs.getvram(devicenum) + "\n"
        specs += "\tperformance level: " + getspecs.getperflevel(devicenum) + "\n"
        specs += "\tsystem clock: " + sclk + "\n"
        specs += "\tmemory clock: " + getspecs.getmclk(devicenum) + "\n"

        with open(os.path.join(outdir, "specs.txt"), "w+") as f:
            f.write(specs)

    hwinfo = getDeviceSpecs(device, sclk)

    figs = []

    #load yaml then create fig for every test
    f = open(inputYaml, 'r')
    data = yamldata(f)
    f.close()

    #setup tests sorted by their respectice figures
    for tests in data.testcases:
        name = getFunctionPreFix(tests[0]['compute_type']) + tests[0]['function'].split('_')[0] + " Performance"
        fig = figure(name , name.replace('_', '\_'))
        for test in tests:
            for idx, lwdir in enumerate(dirlist):
                wdir = lwdir[0]
                label = getLabel(test) + ' run ' + chr(idx+65) if len(dirlist) > 1 else getLabel(test) #labelling runs A and B for now (can swap with rocblas version)
                fig.runs.append( rundata(wdir, idx, label,
                                            test, hwinfo) )
        figs.append(fig)

    #print and launch blas functions
    for fig in figs:
        print(fig.name)
        for run in fig.runs:
            print(" ".join(run.runcmd(outdir, nsample)))
            if not dryrun:
                run.executerun(outdir, nsample)

    #generate plots
    if doAsy:
        print("")
        for fig in figs:
            ncompare = len(dirlist) if speedup else 0
            print(fig.labels())
            print(fig.asycmd(outdir, docformat, datatype, ncompare))
            fig.executeasy(outdir, docformat, datatype, ncompare)

        if docformat == "pdf":
            maketex(figs, outdir, nsample)
        if docformat == "docx":
            makedocx(figs, outdir, nsample)
示例#3
0
文件: alltime.py 项目: acxz/rocFFT
def main(argv):
    dloadexe = None

    indirlist = []
    outdirlist = []
    labellist = []

    docdir = "doc"

    dryrun = False
    nbatch = 1
    speedup = True
    datatype = "time"
    shortrun = False
    docformat = "pdf"
    devicenum = 0
    doAsy = True
    nsample = 10
    rundims = [1, 2, 3]
    runtype = "benchmark"
    secondtype = "none"

    try:
        opts, args = getopt.getopt(argv, "hb:D:f:Tt:i:o:l:S:sg:d:N:R:w:y:")
    except getopt.GetoptError:
        print("error in parsing arguments.")
        print(usage)
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h"):
            print(usage)
            exit(0)
        elif opt in ("-b"):
            dloadexe = os.path.abspath(arg)
        elif opt in ("-i"):
            indirlist.append(arg)
        elif opt in ("-i"):
            indirlist.append(arg)
        elif opt in ("-o"):
            outdirlist.append(arg)
        elif opt in ("-l"):
            labellist.append(arg)
        elif opt in ("-w"):
            docdir = arg
        elif opt in ("-T"):
            dryrun = True
        elif opt in ("-s"):
            shortrun = True
        elif opt in ("-g"):
            if int(arg) == 0:
                doAsy = False
            if int(arg) == 1:
                doAsy = True
        elif opt in ("-d"):
            devicenum = int(arg)
        elif opt in ("-D"):
            rundims = []
            for val in arg.split(','):
                rundims.append(int(val))
        elif opt in ("-N"):
            nsample = int(arg)
        elif opt in ("-S"):
            if int(arg) == 0:
                speedup = False
            if int(arg) == 1:
                speedup = True
        elif opt in ("-t"):
            if arg not in ["time", "gflops", "roofline"]:
                print("data type must be time or gflops or roofline")
                print(usage)
                sys.exit(1)
            datatype = arg
        elif opt in ("-y"):
            if arg not in ["none", "gflops"]:
                print("data type must be gflops or none")
                print(usage)
                sys.exit(1)
            secondtype = arg
        elif opt in ("-R"):
            if arg not in ["report", "benchmark", "efficiency"]:
                print("data type must be gflops or none")
                print(usage)
                sys.exit(1)
            runtype = arg
            if runtype == "efficiency":
                datatype = "roofline"
        elif opt in ("-f"):
            goodvals = ["pdf", "docx"]
            if arg not in goodvals:
                print("error: format must in " + " ".join(goodvals))
                print(usage)
                sys.exit(1)
            docformat = arg

    print("rundims:")
    print(rundims)

    if not dryrun:
        if dloadexe == None:
            for indir in indirlist:
                if not binaryisok(indir, "rocfft-rider"):
                    print("unable to find " + "rocfft-rider" + " in " + indir)
                    print("please specify with -i")
                    sys.exit(1)
        else:
            if not binaryisok(dloadexe, "dyna-rocfft-rider"):
                print("unable to find " + "dyna-rocfft-rider" + " in " +
                      dloadexe)

                for indir in indirlist:
                    if not binaryisok(indir, "librocfft.so"):
                        print("unable to find " + "librocfft.so" + " in " +
                              indir)
                        print("please specify with -i")
                        sys.exit(1)

    print("input directories:", indirlist)

    if len(indirlist) > len(labellist):
        for i in range(len(labellist), len(indirlist)):
            labellist.append("dir" + str(i))
    print("run labels:", labellist)

    for idx in range(len(indirlist)):
        indirlist[idx] = os.path.abspath(indirlist[idx])

    if len(indirlist) > len(outdirlist):
        for i in range(len(outdirlist), len(indirlist)):
            outdirlist.append(os.path.abspath("dir" + str(i)))

    for idx in range(len(outdirlist)):
        outdirlist[idx] = os.path.abspath(outdirlist[idx])
    print("data output directories:", outdirlist)

    if shortrun:
        print("short run")
    print("output format: " + docformat)
    print("device number: " + str(devicenum))

    docdir = os.path.abspath(docdir)

    print("document output in", docdir)
    if not os.path.exists(docdir):
        os.makedirs(docdir)

    for outdir in outdirlist:
        if not os.path.exists(outdir):
            os.makedirs(outdir)

    if not dryrun:
        import getspecs
        specs = "Host info:\n"
        specs += "\thostname: " + getspecs.gethostname() + "\n"
        specs += "\tcpu info: " + getspecs.getcpu() + "\n"
        specs += "\tram: " + getspecs.getram() + "\n"
        specs += "\tdistro: " + getspecs.getdistro() + "\n"
        specs += "\tkernel version: " + getspecs.getkernel() + "\n"
        specs += "\trocm version: " + getspecs.getrocmversion() + "\n"
        specs += "Device info:\n"
        specs += "\tdevice: " + getspecs.getdeviceinfo(devicenum) + "\n"
        specs += "\tvbios version: " + getspecs.getvbios(devicenum) + "\n"
        specs += "\tvram: " + getspecs.getvram(devicenum) + "\n"
        specs += "\tperformance level: " + getspecs.getperflevel(
            devicenum) + "\n"
        specs += "\tsystem clock: " + getspecs.getsclk(devicenum) + "\n"
        specs += "\tmemory clock: " + getspecs.getmclk(devicenum) + "\n"

        for outdir in outdirlist:
            with open(os.path.join(outdir, "specs.txt"), "w+") as f:
                f.write(specs)

            with open(os.path.join(outdir, "gpuid.txt"), "w") as f:
                f.write(getspecs.getgpuid(devicenum))

    figs = []

    if runtype == "benchmark":
        figs = benchfigs(rundims, shortrun)
    if runtype == "report":
        figs = reportfigs(rundims, shortrun)
    if runtype == "efficiency":
        figs = efficiencyfigs(rundims, shortrun)
    just1dc2crad2 = runtype == "efficiency"

    for idx, fig in enumerate(figs):
        for idx2, fig2 in enumerate(figs):
            if idx != idx2 and fig.name == fig2.name:
                print("figures have the same name!")
                print(fig.name)
                print(fig2.name)
                sys.exit(1)

    for fig in figs:
        print(fig.name)
        # Run the tests and put output in the outdirs:
        for run in fig.runs:
            if not dryrun:
                run.executerun(nsample, indirlist, outdirlist, dloadexe)

        # Compile the data in the outdirs into figures in docdir:
        ncompare = len(indirlist) if speedup else 0
        print(fig.labels(labellist))
        #plotgflops = runtype == "submission" and not datatype == "gflops"
        print(
            fig.asycmd(docdir, outdirlist, labellist, docformat, datatype,
                       ncompare, secondtype, just1dc2crad2))
        fig.executeasy(docdir, outdirlist, labellist, docformat, datatype,
                       ncompare, secondtype, just1dc2crad2)

    # Make the document in docdir:
    if docformat == "pdf":
        maketex(figs, docdir, outdirlist, labellist, nsample, secondtype)
    if docformat == "docx":
        makedocx(figs, docdir, nsample, secondtype)

    print("Finished!  Output in " + docdir)