[R] help with random numbers and Rmpi
Faheem Mitha
faheem at email.unc.edu
Mon Dec 15 07:03:45 CET 2003
On Mon, 1 Dec 2003, A.J. Rossini wrote:
> Faheem Mitha <faheem at email.unc.edu> writes:
>
> > So, can this (parallelization at the C level) be done without running a
> > bunch of C slaves along the lines I had previously written? Any examples
> > would be helpful.
>
> How much heavy lifting happens before you spawn the slaves, and can
> that not be moved to R?
>
> Your best bet is to read the SNOW code for handling SPRNG/RSPRNG,
> otherwise.
I've tried to use snow as suggested. I have a R function mg.randvec which
generates a vector of random variates. This function calls a C routine via
the .C call. This works fine if I call it like say...
*********************************************************************
> mg.randvec(3,2,10,5)
$val
[1] -1.9967464 -1.8634205 -0.7459255 -1.7591047 -1.7811685 -1.9953316
[7] -1.7932502 -1.9823565 -1.7999789 -1.0501179 -1.9679886 0.1484859
[13] 0.5768898 1.9117889 1.9366872 -1.3847453 -1.5554107 -1.4933195
[19] -1.8508795 -1.6715850 -1.8951212 -1.8900167 -1.1630852 -1.3989748
[25] -1.9400337 -1.6774471 -1.8136065 -1.8685709 -1.9119879 -1.3378416
*********************************************************************
However, with snow I get
**********************************************************************
> clusterCall(cl,mg.randvec,3,2,10,5)
[[1]]
[1] "Error in .C(\"rocftp\", as.integer(k), as.integer(len),
as.double(theta), : \n\tC/Fortran function name not in load table\n"
attr(,"class")
[1] "try-error"
[[2]]
[1] "Error in .C(\"rocftp\", as.integer(k), as.integer(len),
as.double(theta), : \n\tC/Fortran function name not in load table\n"
attr(,"class")
[1] "try-error"
[[3]]
[1] "Error in .C(\"rocftp\", as.integer(k), as.integer(len),
as.double(theta), : \n\tC/Fortran function name not in load table\n"
attr(,"class")
[1] "try-error"
********************************************************************
In the cluster case it seems to have difficulty loading up the C routine.
I think snow is working Ok, because basic examples like the following
work.
********************************************************************
> clusterCall(cl,runif,3)
[[1]]
[1] 0.1527429 0.1134621 0.8663094
[[2]]
[1] 0.2256776 0.8981241 0.1120226
[[3]]
[1] 0.2371450 0.5090693 0.2776081
******************************************************************
Can anyone tell me what I am doing wrong? All data files is shared across
all three machines I am using (AFS space).
Thanks in advance.
Faheem.
More information about the R-help
mailing list