JNIEXPORT jint JNICALL Java_edu_berkeley_bid_SPBLAS_dcsrmm (JNIEnv * env, jobject calling_obj, jstring j_transa, jint m, jint n, jint k, jdouble alpha, jstring j_matdescra, jdoubleArray j_vals, jintArray j_ir, jintArray j_jc, jdoubleArray j_b, jint ldb, jdouble beta, jdoubleArray j_c, jint ldc) { char * transa = (char *)(*env)->GetStringUTFChars(env, j_transa, 0); char * matdescra = (char *)(*env)->GetStringUTFChars(env, j_matdescra, 0); jdouble * vals = (*env)->GetPrimitiveArrayCritical(env, j_vals, 0); jint * ir = (*env)->GetPrimitiveArrayCritical(env, j_ir, 0); jint * jc = (*env)->GetPrimitiveArrayCritical(env, j_jc, 0); jdouble * b = (*env)->GetPrimitiveArrayCritical(env, j_b, 0); jdouble * c = (*env)->GetPrimitiveArrayCritical(env, j_c, 0); jint returnValue = 0; if (transa != NULL && matdescra != NULL && vals != NULL && ir != NULL && jc != NULL && b != NULL && c != NULL) { mkl_dcsrmm(transa, &m, &n, &k, &alpha, matdescra, vals, ir, jc, jc+1, b, &ldb, &beta, c, &ldc); } else { returnValue = 1; } (*env)->ReleasePrimitiveArrayCritical(env, j_c, c, 0); (*env)->ReleasePrimitiveArrayCritical(env, j_b, b, 0); (*env)->ReleasePrimitiveArrayCritical(env, j_jc, jc, 0); (*env)->ReleasePrimitiveArrayCritical(env, j_ir, ir, 0); (*env)->ReleasePrimitiveArrayCritical(env, j_vals, vals, 0); (*env)->ReleaseStringUTFChars(env, j_matdescra, matdescra); (*env)->ReleaseStringUTFChars(env, j_transa, transa); return returnValue; };
void multiply(const CrsMatrix< double , Kokkos::OpenMP >& A, const std::vector< Kokkos::View< double* , Kokkos::OpenMP > >& x, std::vector< Kokkos::View< double* , Kokkos::OpenMP > >& y, MKLMultiply tag) { typedef Kokkos::OpenMP device_type ; typedef double value_type ; typedef Kokkos::View< double** , Kokkos::LayoutLeft, device_type > trans_multi_vector_type ; MKL_INT n = A.graph.row_map.dimension_0() - 1 ; double *A_values = A.values.ptr_on_device() ; MKL_INT *col_indices = A.graph.entries.ptr_on_device() ; MKL_INT *row_beg = const_cast<MKL_INT*>(A.graph.row_map.ptr_on_device()) ; MKL_INT *row_end = row_beg+1; char matdescra[6] = { 'G', 'x', 'N', 'C', 'x', 'x' }; char trans = 'N'; double alpha = 1.0; double beta = 0.0; // Copy columns of x into a contiguous vector MKL_INT ncol = x.size(); trans_multi_vector_type xx( "xx" , ncol , n ); trans_multi_vector_type yy( "yy" , ncol , n ); Impl::GatherVecTranspose<value_type,device_type>::apply(x,xx); double *x_values = xx.ptr_on_device() ; double *y_values = yy.ptr_on_device() ; // Call MKLs CSR x multi-vector (row-based) multiply mkl_dcsrmm(&trans, &n, &ncol, &n, &alpha, matdescra, A_values, col_indices, row_beg, row_end, x_values, &ncol, &beta, y_values, &ncol); // Copy columns out of continguous multivector Impl::ScatterVecTranspose<value_type,device_type>::apply(y,yy); }
void ReducedMassSpringSystemForceModel::GetTangentStiffnessMatrixHelper( double * tangentStiffnessMatrix) { // evaluate stiffness matrix //PerformanceCounter counter; massSpringSystem->ComputeStiffnessMatrix(u, sparseMatrix); //counter.StopCounter(); //printf("counter: %G\n", counter.GetElapsedTime()); // project matrix #if USE_MKL_SPARSE_BLAS mkl_set_num_threads(8); //PerformanceCounter counter; int upperTriangleOnly=1; int oneIndexed=1; sparseMatrix->GenerateCompressedRowMajorFormat_four_array(csr_values, csr_columns, csr_pointerB, csr_pointerE, upperTriangleOnly, oneIndexed); char transa = 'N'; int m = sparseMatrix->GetNumRows(); int n = r; int k = m; double alpha = 1.0; char matdescra[7] = "SUNFXX"; double * val = csr_values; int * indx = csr_columns; int * pntrb = csr_pointerB; int * pntre = csr_pointerE; double * b = U; int ldb = m; double beta = 0.0; double * c = bufferMatrix; int ldc = m; mkl_dcsrmm(&transa, &m, &n, &k, &alpha, matdescra, val, indx, pntrb, pntre, b, &ldb, &beta, c, &ldc); //counter.StopCounter(); //printf("counter: %G\n", counter.GetElapsedTime()); #else for(int i=0; i<r; i++) sparseMatrix->MultiplyVector(&U[ELT(3*n,0,i)], &bufferMatrix[ELT(3*n,0,i)]); #endif modalMatrix->ProjectMatrix(r, bufferMatrix, tangentStiffnessMatrix); int r2 = r*r; for(int i=0; i<r2; i++) tangentStiffnessMatrix[i] *= -1; }