### "useDynLib" should be MARKED and use ".onLoad" and ".onUnload" in "R/zzz.r".
### Since "libmpi.so" should be load before "pbdMPI.so".
# useDynLib(pbdMPI)

importFrom("stats", "runif", "dist", "as.dist")
importFrom("utils", "write.table", "read.table", "Rprof")

import("methods", "rlecuyer")

# exportPattern("^[\\.]")
exportPattern("^spmd\\.[[:alpha:]]+")
exportPattern("^comm\\.[[:alpha:]]+")
exportPattern("^SPMD\\.[[:alpha:]]+")
exportPattern("^\\.mpiopt_[[:alpha:]]+")

exportMethods(
  "allgather",
  "allreduce",
  "bcast",
  "gather",
  "recv",
  "irecv",
  "reduce",
  "scatter",
  "send",
  "isend",
  "sendrecv",
  "sendrecv.replace"
)

export(
  ### "R/mpi_apts.r"
  "arrange.mpi.apts",

  ### "R/spmd_communicator.r"
  "barrier",
  "init",
  "finalize",
  "is.finalized",
#  "is.master",
#  "get.processor.name",
  "port.open",
  "port.close",
  "serv.lookup",
  "serv.publish",
  "serv.unpublish",
  "intercomm.merge",
  "intercomm.create",

  ### "R/spmd_info.r"
  "info.create",
  "info.set",
  "info.free",
  "info.c2f",

  ### "R/spmd_utility.r"
  "probe",
  "iprobe",
  "anysource",
  "anytag",
  "get.sourcetag",
#  "get.count",
  "is.comm.null",

  ### "R/spmd_wait.r"
  "wait",
  "waitany",
  "waitsome",
  "waitall",

  ### "R/api_*.r"
  "get.jid",
  "pbdApply",
  "pbdLapply",
  "pbdSapply",
  "task.pull.workers",
  "task.pull.master",
  "task.pull"
)

S3method(comm.sort, default)
S3method(comm.sort, integer)
S3method(comm.sort, double)
