def saveVect(v, name):
    import sys
    import pyCombBLAS as pcb

    if pcb.root():
        file = open(name, "w")
    l = len(v)
    if pcb.root():
        file.write(str(l) + "\n")
    for i in range(l):
        val = v[i]
        if pcb.root():
            file.write(str(i) + "\t" + str(val) + "\n")
def checkmat(m, name):
    """If run on one processor it will save m. If run on multiple processors it will load the one-proc m and compare it to the argument and complain if they don't match. """
    import pyCombBLAS as pcb

    if pcb._nprocs() == 1:
        m.save("checkfile_%s" % (name))
    else:
        one = pcb.pySpParMat()
        one.load("checkfile_%s" % (name))
        test = pcb.EWiseApply(m, one, pcb.equal_to())
        if test.Count(pcb.bind2nd(pcb.equal_to(), 1)) != test.getnee():
            if pcb.root():
                print "%s failed." % (name)
def checkvect(v, name):
    """If run on one processor it will save v. If run on multiple processors it will load the one-proc v and compare it to the argument and complain if they don't match. """
    import pyCombBLAS as pcb

    if pcb._nprocs() == 1:
        saveVect(v, "checkfile_%s" % (name))
    else:
        one = loadDenseVect("checkfile_%s" % (name), len(v))
        if len(one) != len(v):
            print "%s failed. length_1 = %d, lengh_p = %d" % (name, len(one), len(v))
            return
        one.EWiseApply(v, pcb.equal_to())
        if one.Count(pcb.bind2nd(pcb.equal_to(), 1)) != v.getnee():
            if pcb.root():
                print "%s failed." % (name)
Beispiel #4
0
	else:
		print "Expecting a path to a matrix file as argument."
		sys.exit();

	print "loading matrix from %s"%(path)
	A.load(path)
	A.Apply(pcb.set(1))
	#print "converting to boolean" # already boolean
	#A = pcb.pySpParMatBool(A)
	n = A.getnrow()
	
	colreducer = pcb.pyDenseParVec(n, 1).sparse();
	degrees = A.SpMV_PlusTimes(colreducer).dense();

else:
	if (pcb.root()):
		print "Generating RMAT with 2**%d nodes" %(scale)
	k1time = A.GenGraph500Edges(scale)
	A.Apply(pcb.set(1))
	degrees = A.Reduce(pcb.pySpParMat.Column(), pcb.plus());
	if (pcb.root()):
		print "Generation took %lf s"%(k1time)
	
#A.save("/home/alugowski-ucsb/matrices/rmat%d.mtx"%(scale))
n = A.getnrow()
m = A.getncol()
nee = A.getnee()
nnz = A.getnnz()
edgefactor = nnz/n;
if (pcb.root()):
	print "A is %d by %d with %d elements (%d nonzeros)." % (n, m, nee, nnz)