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

Pinned Memory for Parallel SpMV #553

Merged

Conversation

PaulMullowney
Copy link
Contributor

@PaulMullowney PaulMullowney commented Jan 7, 2022

This PR adds pinned memory for data transfer during a parallel SpMV. I think this would be a good time to make a par_csr_matvec_device.c and include device code there. It would make this easier to work with rather than all the #defs.

  1. Pinned pointers are added to par_csr_matrix class. These pointers are allocated on demand in par_csr_matvec.c. They are sized according to a maximum in order to be reusable in both the standard matvec and matvecT. To me, they belong in the matrix class because the data is sized according to a particular matrix's parallel SpMV layout.

  2. The pinned memory buffers are allocated in memory.c with cudaHostAlloc with cudaHostAllocMapped. This enables one to write directly into pinned memory from the cuda kernels (either gather (matvec) or spmv (matvecT)). One has to do cudaHostGetDevicePointer and pass that into the kernel execution (done in par_csr_matvec.c). This is a little wonky and needs to be cleaned up.

  3. par_csr_communication has 2 new methods : hypre_ParCSRCommHandleCreate_v3, hypre_ParCSRCommHandleDestroy_v3

In the first method, we have the pinned buffers passed as input. Rather than execute a memcpyDtoH, I simply device synchronize to ensure the pinned data is ready on the host for MPI communication.

In the second method, I execute a cudaMemcpyAsync in order to allow data transfer execute in parallel overlapped kernel execution. cudaMemcpyAsync is called via hypre_TMemcpyAsync. This is a new method and is only implemented for Nvidia and AMD architectures. Tested on Summit and Crusher.

@liruipeng liruipeng changed the base branch from master to matvec_pinned_comm June 24, 2022 17:49
@liruipeng liruipeng merged commit 5d8f6af into hypre-space:matvec_pinned_comm Jun 24, 2022
@liruipeng liruipeng mentioned this pull request Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants