Esempio n. 1
0
 def multiplyVectorBuff(self, vector, buffer, testing=False):
     result = vec.ValueVector(self.address.nrows)
     PTI.ptiOmpSparseMatrixMulVectorCSR_Reduce(result.address,
                                               buffer.address, self.address,
                                               vector.address)
     if not testing: return result
     else: PTI.ptiFreeValueVector(result.address)
Esempio n. 2
0
 def multiplyVector(self, vector, type="default", testing=False):
     result = vec.ValueVector(self.address.nrows)
     size = self.address.nnz
     sp = size / self.address.ncols
     if (type == "default"):
         if (size < 6198):
             PTI.ptiSparseMatrixMulVectorCSR(result.address, self.address,
                                             vector.address)
         elif (sp < 444.3):
             PTI.ptiOmpSparseMatrixMulVectorCSR(result.address,
                                                self.address,
                                                vector.address)
         else:
             PTI.ptiOmpSparseMatrixMulVectorCSRReduce(
                 result.address, self.address, vector.address)
     elif (type == "serial"):
         PTI.ptiSparseMatrixMulVectorCSR(result.address, self.address,
                                         vector.address)
     elif (type == "CPU"):
         PTI.ptiOmpSparseMatrixMulVectorCSR(result.address, self.address,
                                            vector.address)
     elif (type == "CPU_Buff"):
         PTI.ptiOmpSparseMatrixMulVectorCSRReduce(result.address,
                                                  self.address,
                                                  vector.address)
     if not testing: return result
     else: PTI.ptiFreeValueVector(result.address)
Esempio n. 3
0
 def multiplyVector(self, vector, type="default", testing=False):
     result = vec.ValueVector(self.address.nrows)
     size = self.address.nnz
     sp = size / self.address.ncols
     if type == "default":
         if size < 1246221: type = "serial"
         elif sp < 28.8: type = "CPU"
         else: type = "CPU_Buff"
     if (type == "serial"):
         PTI.ptiSparseMatrixMulVector(result.address, self.address,
                                      vector.address)
     elif (type == "CPU"):
         PTI.ptiOmpSparseMatrixMulVector(result.address, self.address,
                                         vector.address)
     elif (type == "CPU_Buff"):
         PTI.ptiOmpSparseMatrixMulVectorReduce(result.address, self.address,
                                               vector.address)
     if not testing: return result
     else: PTI.ptiFreeValueVector(result.address)
Esempio n. 4
0
import HiParTIPy.Matrix as mat
import HiParTIPy.Vector as vec
import HiParTIPy.Buffers as buff

coo = mat.COOMatrix()
coo.loadMatrix("data/matrices/tiny.mtx")
hicoo = coo.convertToHiCOO()
print(coo.ncols())

vec = vec.ValueVector(coo.ncols())
vec.makeRandom()

buf = buff.VecBuff(coo.ncols())

print("HERE")
coo.multiplyVector(vec)
print("HREE")
hicoo.multiplyVectorBuff(vec,buf)
print("HERE")
buf.free()
print("HERE")
Esempio n. 5
0
import HiParTIPy.Vector as vec
import sys
from time import time

name = sys.argv[1]

coo = ten.COOTensor()
coo.load(name)

print("File Name: {}".format(name))

niters = int(sys.argv[2])
equ = int(niters / 100)
mode = int(sys.argv[3])

vector = vec.ValueVector(coo.address.ndims[mode])

for i in range(equ):
    coo.mulVector(vector, mode, testing=True)
start = time()
for i in range(niters):
    coo.mulVector(vector, mode, testing=True)
end = time()
print("MulVector: Time = {},\n Time per Cycles = {}".format(
    end - start, (end - start) / niters))

var = sys.argv[4]

matrix = mat.DenseMatrix(coo.address.ndims[mode], var)

for i in range(equ):
Esempio n. 6
0
niters = int(sys.argv[2])  # Specify number of iterations

coo = ptiMat.COOMatrix()

coo.loadMatrix(mtxname)  # Specify what matrix to use.
sb_bits = 7
hicoo = coo.convert(
    type="hicoo", blockbits=sb_bits,
    superblockbits=sb_bits)  # Specify blocking for hicoo matricies
csr = coo.convert(type="csr")

ncols = coo.ncols()
nrows = coo.nrows()
nnz = coo.nnz()

input_vector = ptiVec.ValueVector(ncols)
input_vector.makeRandom()

######## COO-SpMV #########
# warm-up
coo.multiplyVector(input_vector, testing=True)

start = time.time()
for i in range(niters):
    coo.multiplyVector(input_vector, testing=True)
end = time.time()

coo.statusMatrix()
print("Time: {} sec\nniters: {}\nTime per Call: {} sec/cycle\n".format(
    (end - start), niters, (end - start) / niters))