Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create large array for broadcast #157

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
1 change: 1 addition & 0 deletions SRC/include/superlu_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@ extern SupernodeToGridMap_t* createSuperGridMap(int_t nsuper,int_t maxLvl, int_t
int_t *myZeroTrIdxs, int_t* gNodeCount, int_t** gNodeLists);
extern int_t *createSupernode2TreeMap(int_t nsupers, int_t maxLvl, int_t *gNodeCount, int_t **gNodeLists);
extern void allocBcastArray(void **array, int_t size, int root, MPI_Comm comm);
extern void allocBcastLargeArray(void **array, int64_t size, int root, MPI_Comm comm);
extern int_t* create_iperm_c_supno(int_t nsupers, superlu_dist_options_t *options, Glu_persist_t *Glu_persist, int_t *etree, int_t** Lrowind_bc_ptr, int_t** Ufstnz_br_ptr, gridinfo3d_t *grid3d);
extern gEtreeInfo_t fillEtreeInfo( int_t nsupers, int_t* setree, treeList_t *treeList);
extern sForest_t **compute_sForests(int_t nsupers, Glu_persist_t *Glu_persist, int_t *etree, gridinfo3d_t *grid3d);
Expand Down
38 changes: 38 additions & 0 deletions SRC/prec-independent/trfAux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,44 @@ void allocBcastArray(void **array, int_t size, int root, MPI_Comm comm)
MPI_Bcast(*array, size, MPI_BYTE, root, comm);
}

void allocBcastLargeArray(void **array, int64_t size, int root, MPI_Comm comm)
{
int rank;
MPI_Comm_rank(comm, &rank); // Get the rank of the current process

// Check if the size is valid
if (rank == root)
{
if (size <= 0)
{
fprintf(stderr, "Entered large array allocation. Error: Size should be a positive integer.\n");
MPI_Abort(comm, EXIT_FAILURE);
}

}

// Send the size from root to all other processes in the communicator
MPI_Bcast(&size, 1, MPI_INT64_T, root, comm);

// If I am not the root, receive the size from the root and allocate the array
if (rank != root)
{
*array = SUPERLU_MALLOC(size);
if (*array == NULL)
{
fprintf(stderr, "Error: Failed to allocate memory.\n");
MPI_Abort(comm, EXIT_FAILURE);
}
}

// Then broadcast the array from the root to all other processes
int chunk = size / INT_MAX;
for (int i = 0; i < chunk; i++) {
MPI_Bcast(&((*array)[i*INT_MAX]), INT_MAX, MPI_BYTE, root, comm);
}
MPI_Bcast(&((*array)[chunk*INT_MAX]), size-chunk*INT_MAX, MPI_BYTE, root, comm);
}

sForest_t **compute_sForests(int_t nsupers, Glu_persist_t *Glu_persist, int_t *etree, gridinfo3d_t *grid3d)
{
// Calculation of supernodal etree
Expand Down
Loading