diff --git a/DESCRIPTION b/DESCRIPTION index fa37677..d3c4374 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,3 +35,4 @@ NeedsCompilation: yes Maintainer: Wei-Chen Chen Repository: CRAN Date/Publication: 2018-08-01 15:20:14 UTC +RoxygenNote: 6.1.1 diff --git a/R/spmd_send.r b/R/spmd_send.r index b2361c3..414cfff 100644 --- a/R/spmd_send.r +++ b/R/spmd_send.r @@ -4,6 +4,17 @@ ### Note: send/recv divides data in segments for data are too long. ### probe/count may not get the correct length if data are too long. +spmd.check.send <- function(obj, + obj.type, + rank.dest, + comm, + tag) +{ + ct <- c(obj.type, length(obj)) + .Call("spmd_send_double", as.numeric(ct), as.integer(rank.dest), + as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") +} + ### Default method. spmd.send.default <- function(x, rank.dest = .pbd_env$SPMD.CT$rank.dest, tag = .pbd_env$SPMD.CT$tag, @@ -12,10 +23,13 @@ spmd.send.default <- function(x, ### TODO: implement array/matrix as the way done in allreduce. xx <- serialize(x, NULL) ### Serialize everything who calls default. if(check.type){ - ct <- c(.pbd_env$SPMD.DT$raw.object, length(xx)) - .Call("spmd_send_integer", ct, as.integer(rank.dest), - as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") + spmd.check.send(xx, + obj.type = .pbd_env$SPMD.DT$raw.object, + rank.dest = rank.dest, + comm = comm, + tag = tag) } + .Call("spmd_send_raw", xx, as.integer(rank.dest), as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") invisible() @@ -28,9 +42,11 @@ spmd.send.integer <- function(x, comm = .pbd_env$SPMD.CT$comm, check.type = .pbd_env$SPMD.CT$check.type){ if(check.type){ - ct <- as.double(c(.pbd_env$SPMD.DT$integer, length(x))) - .Call("spmd_send_double", ct, as.integer(rank.dest), - as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") + spmd.check.send(x, + obj.type = .pbd_env$SPMD.DT$integer, + rank.dest = rank.dest, + comm = comm, + tag = tag) } .Call("spmd_send_integer", x, as.integer(rank.dest), as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") @@ -42,9 +58,11 @@ spmd.send.double <- function(x, comm = .pbd_env$SPMD.CT$comm, check.type = .pbd_env$SPMD.CT$check.type){ if(check.type){ - ct <- as.double(c(.pbd_env$SPMD.DT$double, length(x))) - .Call("spmd_send_double", ct, as.integer(rank.dest), - as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") + spmd.check.send(x, + obj.type = .pbd_env$SPMD.DT$double, + rank.dest = rank.dest, + comm = comm, + tag = tag) } .Call("spmd_send_double", x, as.integer(rank.dest), as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") @@ -56,9 +74,11 @@ spmd.send.raw <- function(x, comm = .pbd_env$SPMD.CT$comm, check.type = .pbd_env$SPMD.CT$check.type){ if(check.type){ - ct <- as.double(c(.pbd_env$SPMD.DT$raw, length(x))) - .Call("spmd_send_double", ct, as.integer(rank.dest), - as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") + spmd.check.send(x, + obj.type = .pbd_env$SPMD.DT$raw, + rank.dest = rank.dest, + comm = comm, + tag = tag) } .Call("spmd_send_raw", x, as.integer(rank.dest), as.integer(tag), as.integer(comm), PACKAGE = "pbdMPI") diff --git a/inst/examples/test_long_vector/00_test_all.sh b/inst/examples/test_long_vector/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_long_vector/00_test_all.win b/inst/examples/test_long_vector/00_test_all.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_parallel/00_test_all.sh b/inst/examples/test_parallel/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_parallel/00_test_all.win b/inst/examples/test_parallel/00_test_all.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_performance/00_test_all.sh b/inst/examples/test_performance/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_performance/00_test_all.win b/inst/examples/test_performance/00_test_all.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_rmpi/00_test_all.sh b/inst/examples/test_rmpi/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_rmpi/00_test_spmd.win b/inst/examples/test_rmpi/00_test_spmd.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_s4/00_test_all.sh b/inst/examples/test_s4/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_s4/00_test_all.win b/inst/examples/test_s4/00_test_all.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_send_recv/00_test_all.sh b/inst/examples/test_send_recv/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_send_recv/00_test_all.win b/inst/examples/test_send_recv/00_test_all.win old mode 100644 new mode 100755 diff --git a/inst/examples/test_spmd/00_test_all.sh b/inst/examples/test_spmd/00_test_all.sh old mode 100644 new mode 100755 diff --git a/inst/examples/test_spmd/00_test_all.win b/inst/examples/test_spmd/00_test_all.win old mode 100644 new mode 100755