Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion EXAMPLE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ if(enable_double)
set(DEXM3D pddrive3d.c dcreate_matrix.c dcreate_matrix3d.c)
add_executable(pddrive3d ${DEXM3D})
target_link_libraries(pddrive3d ${all_link_libs})
install(TARGETS pddrive3d RUNTIME DESTINATION "${INSTALL_LIB_DIR}/EXAMPLE")
install(TARGETS pddrive3d RUNTIME DESTINATION "${INSTALL_LIB_DIR}/EXAMPLE")

set(DEXM3D pddrive3d_vbatch.c dcreate_matrix.c dcreate_matrix3d.c)
add_executable(pddrive3d_vbatch ${DEXM3D})
target_link_libraries(pddrive3d_vbatch ${all_link_libs})
install(TARGETS pddrive3d_vbatch RUNTIME DESTINATION "${INSTALL_LIB_DIR}/EXAMPLE")

set(DEXM3D pddrive3d_block_diag.c dcreate_matrix.c dcreate_matrix3d.c)
add_executable(pddrive3d_block_diag ${DEXM3D})
Expand Down
102 changes: 102 additions & 0 deletions EXAMPLE/dcreate_matrix3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,3 +710,105 @@ int dcreate_batch_systems(handle_t *SparseMatrix_handles, int batchCount,
#endif
return 0;
} /* end dcreate_batch_systems */

int dcreate_batch_systems_multiple(handle_t *SparseMatrix_handles, int batchCount,
int nrhs, double **RHSptr, int *ldRHS, double **xtrue, int *ldX,
FILE **fp, char * postfix, gridinfo3d_t *grid3d)
{
int_t *rowind_d, *colptr_d; /* metadata for one diagonal block */
double *nzval_d; /* global */
int_t m, n, nnz;
int row, col, i, j, relpos;
int iam;
char trans[1];

iam = grid3d->iam;

#if ( DEBUGlevel>=1 )
CHECK_MALLOC(iam, "Enter dcreate_batch_systems()");
#endif

/* Allocate storage for CSC containing all the matrices */
SuperMatrix **A = SUPERLU_MALLOC( batchCount * sizeof(SuperMatrix *) );
int d = 0;
for (d = 0; d < batchCount; ++d) {
int_t *rowind, *colptr;
double *nzval;

FILE *fpd = fp[d];
if ( !iam )
{
double t = SuperLU_timer_();

if (!strcmp(postfix, "rua"))
{
/* Read the matrix stored on disk in Harwell-Boeing format. */
dreadhb_dist(iam, fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else if (!strcmp(postfix, "mtx"))
{
/* Read the matrix stored on disk in Matrix Market format. */
dreadMM_dist(fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else if (!strcmp(postfix, "rb"))
{
/* Read the matrix stored on disk in Rutherford-Boeing format. */
dreadrb_dist(iam, fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else if (!strcmp(postfix, "dat"))
{
/* Read the matrix stored on disk in triplet format. */
dreadtriple_dist(fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else if (!strcmp(postfix, "datnh"))
{
/* Read the matrix stored on disk in triplet format (without header). */
dreadtriple_noheader(fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else if (!strcmp(postfix, "bin"))
{
/* Read the matrix stored on disk in binary format. */
dread_binary(fpd, &m, &n, &nnz, &nzval, &rowind, &colptr);
}
else
{
ABORT("File format not known");
}

printf("Time to read and distribute matrix %.2f\n",
SuperLU_timer_() - t); fflush(stdout);
}

int_t *rowind_d, *colptr_d; /* each block */

/* Allocate storage for compressed column representation. */
dallocateA_dist(n, nnz, &nzval_d, &rowind_d, &colptr_d);

/* Copy the CSC arrays */
for (j = 0; j < n+1; ++j) colptr_d[j] = colptr[j];
for (i = 0; i < nnz; ++i) {
rowind_d[i] = rowind[i];
nzval_d[i] = nzval[i];
}

/* Create compressed column matrix. */
A[d] = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) );
dCreate_CompCol_Matrix_dist(A[d], m, n, nnz, nzval_d, rowind_d, colptr_d,
SLU_NC, SLU_D, SLU_GE);
SparseMatrix_handles[d] = (handle_t) A[d];

/* Generate the exact solutions and compute the right-hand sides. */
RHSptr[d] = doubleMalloc_dist( m * nrhs );
xtrue[d] = doubleMalloc_dist( n * nrhs );
ldRHS[d] = m;
ldX[d] = n;
*trans = 'N';
dGenXtrue_dist(n, nrhs, xtrue[d], n);
dFillRHS_dist(trans, nrhs, xtrue[d], n, A[d], RHSptr[d], m);
}

#if ( DEBUGlevel>=1 )
CHECK_MALLOC(iam, "Exit dcreate_batch_systems()");
#endif
return 0;
} /* end dcreate_batch_systems_mult */
Loading