mpi_last: Properly end "mpi" workers before quitting R (e.g., at a...

Description Usage Arguments Notes Details

View source: R/Parallel.R

Description

Properly end “mpi” workers before quitting R (e.g., at a crash)

Usage

1

Arguments

gv

A list with at least one named element p_has. p_has is a logical value and indicates whether call is from a parallel run.

Notes

Code is based on http://acmmac.acadiau.ca/tl_files/sites/acmmac/resources/examples/task_pull.R.txt.

Ideally, we use Rmpi::mpi.exit() on exit, but we cannot as of Rmpi v0.6.6. Because rSFSW2 does not attach Rmpi, the function mpi.exit throws an error when it executes detach(package:Rmpi) which results in "Error in detach(package:Rmpi) : invalid 'name' argument".

Rmpi::mpi.comm.size(1) crashes with a segfault if there are no workers running because of the call .Call("mpi_comm_is_null", as.integer(comm), PACKAGE = "Rmpi").

Ideally, we would use Rmpi::mpi.close.Rslaves(). However, this function hangs our R session because of its call to Rmpi::mpi.comm.disconnect(); even wrapping this in try doesn't prevent it from hanging.

Details

gv will usually be the package-level global variable environment SFSW2_glovars. This is because this function is registered as finalizer to the object SFSW2_glovars.


Burke-Lauenroth-Lab/SoilWat_R_Wrapper documentation built on Aug. 14, 2020, 5:17 p.m.