The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Requirements: R ≥ 4.0, C++17 toolchain.
memApply)library(memshare)
set.seed(1)
n <- 10000; p <- 2000
X <- matrix(rnorm(n * p), n, p) # numeric/double matrix
y <- rnorm(n)
# Correlate each column with y, in parallel, without copying X to workers
res <- memApply(
X = X, MARGIN = 2,
FUN = function(v, y) cor(v, y),
VARS = list(y = y) # shared side data
)
str(res)What happened?
X and y were placed in shared memory; workers
received views (ALTREP) instead of copies. Each worker
extracted the i-th column as v, ran FUN(v, y),
and returned a result. All views were released automatically at the
end.
memLapply)"demo").Unload the package (or release views/variables) to clean up. Memory is freed once no views remain.
FUN’s first argument must be the
vector/list element (v for memApply,
el for memLapply).VARS must use exactly
the same names in FUN’s signature.clusterExport for small copied objects; big ones
belong in VARS.releaseViews() in workers
(handled automatically by memApply/memLapply), and
releaseVariables() in the master when done.X is a numeric matrix (double) or a character name of a
registered object; VARS is either a named list (to
register) or character vector of existing names.viewList() in
workers; any remaining views prevent releaseVariables()
from reclaiming memory.NAMESPACE is missing and FUN is an inline
lambda, the default namespace is "unnamed". Prefer explicit
NAMESPACE in production.registerVariables(namespace, variableList) — put
objects into shared memory.retrieveViews(namespace, variableNames) — get ALTREP
views (workers).releaseViews(namespace, variableNames) — release worker
views.releaseVariables(namespace, variableNames) — free
objects (master).memApply(X, MARGIN, FUN, NAMESPACE = NULL, VARS = NULL, MAX.CORES = NULL)
— matrix apply with shared memory.memLapply(X, FUN, NAMESPACE = NULL, VARS = NULL, MAX.CORES = NULL)
— list apply with shared memory.These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.