From fa9123514ecec6e28324bbdd2c9bf97f37e95438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien?= Date: Tue, 30 Apr 2019 18:57:06 +0200 Subject: [PATCH] Replaced integer handchecks with double handchecks --- DESCRIPTION | 1 + R/spmd_recv.r | 4 +- R/spmd_send.r | 45 ++++++++++++++----- inst/examples/test_long_vector/00_test_all.sh | 0 .../examples/test_long_vector/00_test_all.win | 0 inst/examples/test_parallel/00_test_all.sh | 0 inst/examples/test_parallel/00_test_all.win | 0 inst/examples/test_performance/00_test_all.sh | 0 .../examples/test_performance/00_test_all.win | 0 inst/examples/test_rmpi/00_test_all.sh | 0 inst/examples/test_rmpi/00_test_spmd.win | 0 inst/examples/test_s4/00_test_all.sh | 0 inst/examples/test_s4/00_test_all.win | 0 inst/examples/test_send_recv/00_test_all.sh | 0 inst/examples/test_send_recv/00_test_all.win | 0 inst/examples/test_spmd/00_test_all.sh | 0 inst/examples/test_spmd/00_test_all.win | 0 17 files changed, 36 insertions(+), 14 deletions(-) mode change 100644 => 100755 inst/examples/test_long_vector/00_test_all.sh mode change 100644 => 100755 inst/examples/test_long_vector/00_test_all.win mode change 100644 => 100755 inst/examples/test_parallel/00_test_all.sh mode change 100644 => 100755 inst/examples/test_parallel/00_test_all.win mode change 100644 => 100755 inst/examples/test_performance/00_test_all.sh mode change 100644 => 100755 inst/examples/test_performance/00_test_all.win mode change 100644 => 100755 inst/examples/test_rmpi/00_test_all.sh mode change 100644 => 100755 inst/examples/test_rmpi/00_test_spmd.win mode change 100644 => 100755 inst/examples/test_s4/00_test_all.sh mode change 100644 => 100755 inst/examples/test_s4/00_test_all.win mode change 100644 => 100755 inst/examples/test_send_recv/00_test_all.sh mode change 100644 => 100755 inst/examples/test_send_recv/00_test_all.win mode change 100644 => 100755 inst/examples/test_spmd/00_test_all.sh mode change 100644 => 100755 inst/examples/test_spmd/00_test_all.win diff --git a/DESCRIPTION b/DESCRIPTION index 1d38407..3a2f634 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_recv.r b/R/spmd_recv.r index 631cf76..d9d4ecd 100644 --- a/R/spmd_recv.r +++ b/R/spmd_recv.r @@ -54,8 +54,8 @@ spmd.recv.default <- function(x.buffer = NULL, spmd.check.type <- function(x.buffer = NULL, type = NA, rank.source = .pbd_env$SPMD.CT$rank.source, tag = .pbd_env$SPMD.CT$tag, comm = .pbd_env$SPMD.CT$comm, status = .pbd_env$SPMD.CT$status){ - ct.buffer <- c(0L, 0L) - ct.buffer <- .Call("spmd_recv_integer", ct.buffer, as.integer(rank.source), + ct.buffer <- c(0, 0) + ct.buffer <- .Call("spmd_recv_double", ct.buffer, as.integer(rank.source), as.integer(tag), as.integer(comm), as.integer(status), PACKAGE = "pbdMPI") diff --git a/R/spmd_send.r b/R/spmd_send.r index 6f14c61..32a53fc 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 <- c(.pbd_env$SPMD.DT$integer, length(x)) - .Call("spmd_send_integer", 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,12 @@ spmd.send.double <- function(x, comm = .pbd_env$SPMD.CT$comm, check.type = .pbd_env$SPMD.CT$check.type){ if(check.type){ - ct <- c(.pbd_env$SPMD.DT$double, length(x)) - .Call("spmd_send_integer", 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 +75,11 @@ spmd.send.raw <- function(x, comm = .pbd_env$SPMD.CT$comm, check.type = .pbd_env$SPMD.CT$check.type){ if(check.type){ - ct <- c(.pbd_env$SPMD.DT$raw, length(x)) - .Call("spmd_send_integer", 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