|
11 | 11 | *-----------------------------------------------------*/ |
12 | 12 |
|
13 | 13 | #include "_hypre_parcsr_mv.h" |
| 14 | +#ifdef HYPRE_USING_NODE_AWARE_MPI |
| 15 | +#include <mpi.h> |
| 16 | +#endif |
14 | 17 |
|
15 | 18 | /* some debugging tools*/ |
16 | 19 | #define mydebug 0 |
@@ -750,3 +753,58 @@ hypre_FillResponseIJDetermineSendProcs(void *p_recv_contact_buf, |
750 | 753 |
|
751 | 754 | return hypre_error_flag; |
752 | 755 | } |
| 756 | + |
| 757 | +/*-------------------------------------------------------------------- |
| 758 | + * hypre_ParCSRCreateCommGraph |
| 759 | + * |
| 760 | + * Create communication topology graph for MPI neighborhood |
| 761 | + * collectives |
| 762 | + *--------------------------------------------------------------------*/ |
| 763 | + |
| 764 | +#ifdef HYPRE_USING_NODE_AWARE_MPI |
| 765 | +void |
| 766 | +hypre_ParCSRCreateCommGraph(HYPRE_BigInt first_col_diag, |
| 767 | + HYPRE_BigInt *col_map_offd, |
| 768 | + MPI_Comm comm, |
| 769 | + hypre_ParCSRCommPkg *comm_pkg) { |
| 770 | + HYPRE_Int num_sends = hypre_ParCSRCommPkgNumSends(comm_pkg); |
| 771 | + HYPRE_Int num_recvs = hypre_ParCSRCommPkgNumRecvs(comm_pkg); |
| 772 | + HYPRE_Int *send_map_starts = hypre_ParCSRCommPkgSendMapStarts(comm_pkg); |
| 773 | + HYPRE_Int *recv_vec_starts = hypre_ParCSRCommPkgRecvVecStarts(comm_pkg); |
| 774 | + HYPRE_Int *send_map_elmts = hypre_ParCSRCommPkgSendMapElmts(comm_pkg); |
| 775 | + |
| 776 | + int *sendcounts = (int *)malloc(num_sends * sizeof(int)); |
| 777 | + int *recvcounts = (int *)malloc(num_recvs * sizeof(int)); |
| 778 | + for (int i = 0; i < num_sends; i++) { |
| 779 | + sendcounts[i] = send_map_starts[i+1] - send_map_starts[i]; |
| 780 | + } |
| 781 | + for (int i = 0; i < num_recvs; i++) { |
| 782 | + recvcounts[i] = recv_vec_starts[i+1] - recv_vec_starts[i]; |
| 783 | + } |
| 784 | + MPIX_Dist_graph_create_adjacent( comm, num_recvs, hypre_ParCSRCommPkgRecvProcs(comm_pkg), |
| 785 | + recvcounts, |
| 786 | + num_sends, hypre_ParCSRCommPkgSendProcs(comm_pkg), |
| 787 | + sendcounts, |
| 788 | + MPI_INFO_NULL, 0, &(comm_pkg->neighbor_comm)); |
| 789 | + MPIX_Dist_graph_create_adjacent( comm, num_sends, hypre_ParCSRCommPkgSendProcs(comm_pkg), |
| 790 | + sendcounts, |
| 791 | + num_recvs, hypre_ParCSRCommPkgRecvProcs(comm_pkg), |
| 792 | + recvcounts, |
| 793 | + MPI_INFO_NULL, 0, &(comm_pkg->neighborT_comm)); |
| 794 | + |
| 795 | + HYPRE_Int num_send_elmts = send_map_starts[num_sends]; |
| 796 | + comm_pkg->global_send_indices = hypre_CTAlloc(long, num_send_elmts, HYPRE_MEMORY_HOST); |
| 797 | + for (int i = 0; i < num_sends; i++) { |
| 798 | + for (int j = send_map_starts[i]; j < send_map_starts[i+1]; j++) { |
| 799 | + comm_pkg->global_send_indices[j] = send_map_elmts[j] + first_col_diag; |
| 800 | + } |
| 801 | + } |
| 802 | + HYPRE_Int num_recv_elmts = recv_vec_starts[num_recvs]; |
| 803 | + comm_pkg->global_recv_indices = hypre_CTAlloc(long, num_recv_elmts, HYPRE_MEMORY_HOST); |
| 804 | + for (int i = 0; i < num_recvs; i++) { |
| 805 | + for (int j = recv_vec_starts[i]; j < recv_vec_starts[i+1]; j++) { |
| 806 | + comm_pkg->global_recv_indices[j] = col_map_offd[j]; |
| 807 | + } |
| 808 | + } |
| 809 | +} |
| 810 | +#endif |
0 commit comments