Пример #1
0
# In[14]:
try:
    get_ipython().run_line_magic('matplotlib', 'inline')
except:
    pass

# In[15]:
x = np.array(df.theta)
s = np.array(df.sin)
c = np.array(df.cos)

# In[16]:
to_plot = [[x, s, "sin(x)"], [x, c, "cos(x)"]]

# In[17]:
myplot(bl="time",
       sl="out\nVolts",
       topl="two plots",
       width=1,
       sets=to_plot,
       doxkcd=True)


def mytan(s, c):
    return s / c


df['tan'] = df.apply(lambda row: mytan(row['sin'], row['cos']), axis=1)

print(df)
Пример #2
0
    import os
    try:
        get_ipython().run_line_magic('matplotlib', 'inline')
    except:
        pass
    os.getcwd()
    #sys.path.append("/Users/tkaiser2/bin")
    sys.path.append(os.getcwd())
    from plsub import myplot

# In[ ]:

if doplot:
    myplot(bl="Time (seconds) ",
           sl="reward_mean",
           topl="Eagle breakout-dqn",
           sets=[[d0_time, d0_reward, "CPU"], [d1_time, d1_reward, "1 GPU"],
                 [d2_time, d2_reward, "2 GPUs"]])

# In[ ]:

if doplot:
    myplot(bl="Time (seconds) ",
           sl="Interation",
           topl="Eagle breakout-dqn",
           sets=[[d0_time, d0_it, "CPU"], [d1_time, d1_it, "1 GPU"],
                 [d2_time, d2_it, "2 GPUs"]])

# In[ ]:

out0 = pd.DataFrame(
Пример #3
0
def doomp(hdir, base, bind):
    nplots = 0
    global results
    global cases
    global thedirs
    thedirs.append(hdir)
    for ver in ["stf_ii", "stf_ig"]:
        import os
        import numpy as np
        from plsub import myplot
        import matplotlib.pyplot as plt
        command = "grep -l " + ver + " " + hdir + "/2*"
        #print("COMMAND",command)
        c = os.popen(command, "r")
        files = c.read()
        cores = np.array(range(0, 64))
        sums = np.zeros(64)
        mins = np.zeros(64) + 1e6
        maxs = np.zeros(64) - 1e6
        icnt = np.zeros(64)
        nf = 0
        files = files.split()
        #print(files)
        nt = len(files)
        heat = np.zeros([nt, 64])

        for f in files:
            #print(f)
            nf = nf + 1
            infile = open(f, "r")
            dat = infile.readlines()
            isums = np.zeros(64)
            imins = np.zeros(64) + 1e6
            imaxs = np.zeros(64) - 1e6
            for d in dat:
                d = d.split()
                l = float(d[4])
                c = int(d[6]) % 64
                #print(c,l)
                isums[c] = isums[c] + l
                heat[nf - 1, c] = heat[nf - 1, c] + l
                icnt[c] = 1
            for c in range(0, 64):
                if isums[c] < imins[c]: imins[c] = isums[c]
                if isums[c] > imaxs[c]: imaxs[c] = isums[c]
            sums = sums + isums
            for c in range(0, 64):
                if imins[c] < 1e5:
                    if imins[c] < mins[c]: mins[c] = imins[c]
                if imaxs[c] > 0.0:
                    if imaxs[c] > maxs[c]: maxs[c] = imaxs[c]

        sums = sums / nf
        #print(sums)
        cores = []
        fmins = []
        faves = []
        fmaxs = []
        for c in range(0, 64):
            if sums[c] > 0.0:
                cores.append(c)
                fmins.append(mins[c])
                faves.append(sums[c])
                fmaxs.append(maxs[c])
                #print(c,mins[c],sums[c],maxs[c])
    # print(len(cores),fmins,faves,fmaxs)
        asets = [[cores, fmins, "min"], [cores, faves, "ave"],
                 [cores, fmaxs, "max"]]
        #myplot(sets=asets,doxkcd=False,width=0,do_sym="y",bl="Physical Core",sl="Load",topl=title,outname=ver+"-"+edir,yr="90,105",xr="0,64")
        command = "grep cpus-per-task " + hdir + "/script* | tail -1"
        print(command)
        c = os.popen(command, "r")
        lines = c.read()
        #print(lines)
        settings = "NONE"
        settings = lines.replace("#SBATCH --", "")
        settings = settings.strip()
        #print(settings)

        if lines.find("rank") > -1: settings = "cpu-bind=rank"
        if lines.find("socket") > -1: settings = "cpu-bind=sockets"
        if lines.find("core") > -1: settings = "cpu-bind=cores"
        #command="grep 'run time' "+hdir+"/slurm-*.out | awk {'print $NF }'"
        #print(settings+"01")
        count = 0
        try:
            lines = lines.split("-n")
            lines = lines[1]
            lines = lines.split()
            ccount = lines[0]
        except:
            #print("count failed")
            ccount = "0"
        #print(settings+"02")
        #print("count=",ccount)
        command = "grep 'run time' " + hdir + "/slurm-*.out"
        #print(command)
        c = os.popen(command, "r")
        times = c.readlines()
        #print(times)
        j = 0
        for t in times:
            t = t.split("=")
            #print("t=",t)
            t = t[1]
            ttt = t.split()
            t = float(ttt[0])
            t = "%5.2f" % (t)
            times[j] = t
            j = j + 1
        #print(times)
        #print(settings+"03")
        cset = "CSET"
        #print("ver",ver)
        if ver.find("ii") > -1:
            cset = "ifort t=" + times[0] + " "
        if ver.find("ig") > -1:
            cset = "gfortran t=" + times[1] + " "
        if ver.find("og") > -1:
            cset = "OpenMPI/GNU t=" + times[2] + " "
        if ver.find("oi") > -1:
            cset = "OpenMPI/Intel t=" + times[3] + " "
        #print(cset,settings,ccount)
        title = cset + settings
        #print(title)
        #settings=settings.replace("cpu-bind=","")
        #print(settings+"04")
        #get OMP_
        command = "grep 'OMP_' " + hdir + "/env*"
        c = os.popen(command, "r")
        omp = c.read()
        #print("bonk",omp)
        if len(omp) > 0:
            omp = omp.replace("\n", " ")
            #print("OMP=",omp)
            title = title + "\n" + omp
        #print(title)
        ofn = base + "/" + ver + "_" + settings + "_" + ccount + "_" + bind
        ofn = nfname(ofn, ".pdf")
        #print(ofn)

        myplot(sets=asets,
               doxkcd=False,
               width=0,
               do_sym="y",
               bl="Physical Core",
               sl="Load",
               topl=title,
               outname=ofn,
               xr="0,64")
        t2 = title.replace("\n", " ")
        cases.append(t2)
        results = pdappend(results, topd(title, ofn))
        nplots = nplots + 1
        fig, ax = plt.subplots(figsize=(12, 6),
                               subplot_kw={
                                   'xticks': [],
                                   'yticks': []
                               })
        fig.subplots_adjust(hspace=100.0, wspace=50)

        zmax = np.max(heat)
        zmin = np.min(heat)
        x = np.array(range(0, nt))
        x = x / (nt - 1)
        cores = np.array(range(0, 64))
        #print(x)
        #print(cores)
        from scipy import interpolate
        #nh= interpolate.interp2d(cores, x, heat)
        #nh= interpolate.RectBivariateSpline(cores, x, heat,kx=1,ky=1)
        #nh= interpolate.RectBivariateSpline(x, cores, heat,kx=1,ky=1,s=0)
        nh = interpolate.RegularGridInterpolator((x, cores),
                                                 heat,
                                                 method="nearest")
        #print(nh)
        newx = np.array(range(0, 64)) / 64.0
        nheat = np.zeros([64, 64])
        for i in range(0, 64):
            for j in range(0, 64):
                yi = cores[i]
                xi = newx[j]
                #print(xi,yi)
                #pts=np.array([xi,yi])
                #print(nh([[4,4]]))
                pts = np.array([[xi, yi]])
                nheat[j][i] = nh(pts)
        #c = ax.pcolormesh(x, cores, heat, cmap='RdBu', vmin=zmin, vmax=zmax)
        #heat[3]=0
        c = ax.pcolormesh(cores,
                          x,
                          heat,
                          cmap='rainbow',
                          vmin=zmin,
                          vmax=zmax,
                          shading='nearest')
        #c = ax.pcolormesh(cores, newx, nheat, cmap='rainbow', vmin=zmin, vmax=zmax,shading='nearest')
        #c=plt.imshow(heat,cmap='rainbow',interpolation="none")
        c = plt.imshow(nheat, cmap='rainbow', interpolation="none")
        ax.set_title(title)
        ax.set_ylabel('Relative Time')
        ax.set_xlabel('Physical Core')
        ax.set_xticks(range(0, 65, 4))
        yticks = range(0, 65, 4)
        yticks = np.array(yticks) / 65
        ax.set_yticks(range(0, 65, 4))
        #ax.set_size=(20,2)

        #ax.axis([x.max(), x.min(), cores.min(), cores.max()])
        fig.colorbar(c, ax=ax)
        #plt.show()
        outname = nfname(outname, ".pdf")
        outname = base + "/" + "h_" + ver + "_" + settings + "_" + ccount + "_" + bind
        plt.savefig(outname + ".pdf")
        nplots = nplots + 1

#        for h in heat[:] :
#            print(h)
    return (nplots)
Пример #4
0
sets = []
for j in range(0, len(xs1[0, :])):
    #print(xs1[0,j])
    x = np.empty(len(cs1))
    y = np.empty(len(cs1))
    for i in range(0, len(cs1)):
        #print(cs1[i],ys1[i,j])
        x[i] = cs1[i]
        y[i] = ys1[i, j]
    #print(x)
    #print(y)
    sub = [x, y, str(xs1[0, j])]
    sets.append(sub)
myplot(sets=sets,
       do_log="y",
       topl="Biband, TPN=" + TPN,
       bl="Nodes",
       sl='Msg/sec')

# cs1

# In[ ]:

TPN = "36"

ys1 = np.array(Biband.loc[Biband.tpn == TPN]['Msg/sec'])
xs1 = np.array(Biband.loc[Biband.tpn == TPN]['size'])
cs1 = np.array(Biband.loc[Biband.tpn == TPN]['cores'])
#print(ys1)
#print(xs1)
#print(cs1)