errors.f90 Source File


This file depends on

sourcefile~~errors.f90~~EfferentGraph sourcefile~errors.f90 errors.f90 sourcefile~logger.f90 logger.f90 sourcefile~errors.f90->sourcefile~logger.f90

Files dependent on this one

sourcefile~~errors.f90~~AfferentGraph sourcefile~errors.f90 errors.f90 sourcefile~backend.f90~4 backend.f90 sourcefile~backend.f90~4->sourcefile~errors.f90 sourcefile~poisson_fft.f90~2 poisson_fft.f90 sourcefile~backend.f90~4->sourcefile~poisson_fft.f90~2 sourcefile~sendrecv.f90~3 sendrecv.f90 sourcefile~backend.f90~4->sourcefile~sendrecv.f90~3 sourcefile~exec_dist.f90~2 exec_dist.f90 sourcefile~backend.f90~4->sourcefile~exec_dist.f90~2 sourcefile~poisson_fft.f90~2->sourcefile~errors.f90 sourcefile~poisson_fft.f90~2->sourcefile~sendrecv.f90~3 sourcefile~sendrecv.f90~3->sourcefile~errors.f90 sourcefile~setup.f90 setup.f90 sourcefile~setup.f90->sourcefile~errors.f90 sourcefile~setup.f90->sourcefile~backend.f90~4 sourcefile~build.f90 build.f90 sourcefile~build.f90->sourcefile~setup.f90 sourcefile~estimate.f90 estimate.f90 sourcefile~build.f90->sourcefile~estimate.f90 sourcefile~context.f90 context.f90 sourcefile~build.f90->sourcefile~context.f90 sourcefile~report.f90 report.f90 sourcefile~build.f90->sourcefile~report.f90 sourcefile~estimate.f90->sourcefile~poisson_fft.f90~2 sourcefile~estimate.f90->sourcefile~context.f90 sourcefile~exec_dist.f90~2->sourcefile~sendrecv.f90~3 sourcefile~memcheck_device.f90 memcheck_device.f90 sourcefile~memcheck_device.f90->sourcefile~poisson_fft.f90~2 sourcefile~poisson_solver.f90 poisson_solver.f90 sourcefile~poisson_solver.f90->sourcefile~setup.f90 sourcefile~xcompact.f90 xcompact.f90 sourcefile~xcompact.f90->sourcefile~setup.f90 sourcefile~context.f90->sourcefile~memcheck_device.f90 sourcefile~memcheck.f90 memcheck.f90 sourcefile~memcheck.f90->sourcefile~build.f90 sourcefile~memcheck.f90->sourcefile~estimate.f90 sourcefile~memcheck.f90->sourcefile~context.f90 sourcefile~memcheck.f90->sourcefile~report.f90 sourcefile~report.f90->sourcefile~estimate.f90 sourcefile~report.f90->sourcefile~memcheck_device.f90 sourcefile~report.f90->sourcefile~context.f90

Source Code

module m_cuda_errors
  !! CUDA and cuFFT counterparts of m_logger's check_mpi: turn a failed
  !! return code into a report naming the operation, the rank and the error,
  !! followed by an abort of the whole run.
  !!
  !! A CUDA failure is local to the rank that sees it, while its partners
  !! carry on into MPI and would wait for it forever, so these always abort
  !! the job rather than stopping the one rank.
  use cudafor, only: cudaSuccess, cudaGetErrorString

  use m_logger, only: abort_run, str

  implicit none

  private
  public :: check_cuda, check_cufft

contains

  subroutine check_cuda(ierr, operation)
    !! Abort the run if a CUDA runtime call did not return cudaSuccess.
    integer, intent(in) :: ierr
    character(len=*), intent(in) :: operation

    if (ierr == cudaSuccess) return

    call abort_run(operation//' failed: '//trim(cudaGetErrorString(ierr)) &
                   //' (CUDA error code '//str(ierr)//')')
  end subroutine check_cuda

  subroutine check_cufft(ierr, operation)
    !! Abort the run if a cuFFT call did not return CUFFT_SUCCESS (0).
    !! cuFFT has no error-string function, so only the code is reported.
    integer, intent(in) :: ierr
    character(len=*), intent(in) :: operation

    if (ierr == 0) return

    call abort_run(operation//' failed (cuFFT error code '//str(ierr)//')')
  end subroutine check_cufft

end module m_cuda_errors