Beispiel #1
0
 def multiplyMatrix(self, mat, type="default", testing=False):
     result = DenseMatrix(self.address.nrows, mat.address.ncols)
     if type == "default":
         nnz = self.address.nnz
         r = mat.address.ncols
         s = self.address.nrows
         a = 0.1780 + 1.189E-8 * nnz / r / r / r - 11.58 / sqrt(
             r * s) + 3.363 / sqrt(r)
         b = sqrt(s * nnz) * r
         if a < 1 or nnz < 1000:
             PTI.ptiSparseMatrixMulMatrix(result.address, self.address,
                                          mat.address)
         elif b < 300000000:
             PTI.ptiOmpSparseMatrixMulMatrix(result.address, self.address,
                                             mat.address)
         else:
             PTI.ptiOmpSparseMatrixMulMatrixReduce(result.address,
                                                   self.address,
                                                   mat.address)
     elif type == "serial":
         PTI.ptiSparseMatrixMulMatrix(result.address, self.address,
                                      mat.address)
     elif type == "CPU":
         PTI.pitOmpSparseMatrixMulMatrix(result.address, self.address,
                                         mat.address)
     elif type == "CPU_Buff":
         PTI.ptiOmpSparseMatrixMulMatrixReduce(result.address, self.address,
                                               mat.address)
     PTI.ptiSparseMatrixMulMatrix(result.address, self.address, mat.address)
     if not testing: return result
     else: PTI.ptiFreeMatrix(result.address)
Beispiel #2
0
 def multiplyMatrix(self, mat, type="default", testing=False):
     result = DenseMatrix(self.address.nrows, mat.address.ncols)
     if type == "default":
         n = self.address.nnz
         r = mat.address.ncols
         s = self.address.nrows
         a = -0.2676 + 7.343E-5 * n / r / r / r - 17.91 / sqrt(
             r * s) + 5.729 / sqrt(r)
         b = sqrt(s * n) * r
         if a < 1 or n < 1000:
             PTI.ptiSparseMatrixMulMatrixHiCOO(result.address, self.address,
                                               mat.address)
         elif b < 200000000:
             PTI.ptiOmpSparseMatrixMulMatrixHiCOO(result.address,
                                                  self.address, mat.address)
         else:
             PTI.ptiOmpSparseMatrixMulMatrixHiCOOReduce(
                 result.address, self.address, mat.address)
     elif type == "serial":
         PTI.ptiSparseMatrixMulMatrixHiCOO(result.address, self.address,
                                           mat.address)
     elif type == "CPU":
         PTI.ptiOmpSparseMatrixMulMatrixHiCOO(result.address, self.address,
                                              mat.address)
     elif type == "CPU_Buff":
         PTI.ptiOmpSparseMatrixMulMatrixHiCOOReduce(result.address,
                                                    self.address,
                                                    mat.address)
     if not testing: return result
     else: PTI.ptiFreeMatrix(result.address)
Beispiel #3
0
 def multiplyMatrix(self, mat, type="default", testing=False):
     result = DenseMatrix(self.address.nrows, mat.address.ncols)
     n = self.address.nnz
     if type == "default":
         if n < 1000:
             PTI.ptiSparseMatrixMulMatrixCSR(result.address, self.address,
                                             mat.address)
         else:
             PTI.ptiOmpSparseMatrixMulMatrixCSR(result.address,
                                                self.address, mat.address)
     elif type == "serial":
         PTI.ptiSparseMatrixMulMatrixCSR(result.address, self.address,
                                         mat.address)
     elif type == "CPU":
         PTI.ptiOmpSparseMatrixMulMatrixCSR(result.address, self.address,
                                            mat.address)
     elif type == "CPU_Buff":
         PTI.ptiOmpSparseMatrixMulMatrixCSRReduce(result.address,
                                                  self.address, mat.address)
     if not testing: return result
     else: PTI.ptiFreeMatrix(result.address)