Skip to contents

Creates a Beowulf cluster configuration from machine IPs, core counts, and user credentials.

Usage

beowulf_cluster(
  cluster.ips = NULL,
  cluster.cores = NULL,
  cluster.user = Sys.info()[["user"]],
  cluster.port = "11000",
  outfile = NULL
)

Arguments

cluster.ips

Character vector of machine IP addresses in the cluster. The first IP is the main node (typically the machine running this code). Default: NULL.

cluster.cores

Integer vector of core counts for each machine. Must match the length of cluster.ips. Default: NULL.

cluster.user

Character string for the user name across all machines. Default: current system user.

cluster.port

Character string specifying the communication port. Default: "11000".

outfile

Character string or NULL. Path to append worker messages, "" to print to console, or NULL (default) for /dev/null (Linux) or nul: (Windows).

Value

Cluster object created by parallel::makeCluster(), ready for registration with doParallel::registerDoParallel().

Details

Network requirements: Firewalls on all machines must allow traffic on the specified port.

Usage workflow:

  1. Create cluster with this function

  2. Register with doParallel::registerDoParallel()

  3. Run parallelized code (e.g., foreach loops)

  4. Stop cluster with parallel::stopCluster()

Examples

if (FALSE) { # \dontrun{
# Create cluster with 3 machines
beowulf.cluster <- beowulf_cluster(
  cluster.ips = c(
    "192.168.1.10",  # main node
    "192.168.1.11",
    "192.168.1.12"
  ),
  cluster.cores = c(7, 4, 4),
  cluster.user = "username",
  cluster.port = "11000"
)

# Register cluster for parallel processing
doParallel::registerDoParallel(cl = beowulf.cluster)

# Run parallelized code (e.g., foreach loop)
# your_parallel_code_here

# Stop cluster when done
parallel::stopCluster(cl = beowulf.cluster)
} # }