[Rcpp-devel] Rcpp-devel Digest, Vol 4, Issue 14

Dirk Eddelbuettel edd at debian.org
Wed Feb 17 20:49:35 CET 2010

Hi Jianping,

On 17 February 2010 at 11:51, Jianping Hua wrote:
| Hi, Dirk:
| Segmentation error is my stupid typo. The memory assignment in line 19
| surely should be
|     double *allvalues = new double [ nodesize ]; // to save all results
| rather than
|     double *allvalues = new double ( nodesize ); // to save all results

Oh boy, now we both look silly :)  I glanced at this for a while and thought
it looked funny. But I use std::vector so much and not new / delete[] that it
didn't click.  

That does indeed fix things.
| The new makefile did not work on my MBP still because of the mtune
| parameter. Basically I have to use

What I currently have has your two contributed examples in a new subdirectory
(as not everybody will have MPI around) and that use the Makefile below. Can
you try that?  It uses mpic++ -showme:.... to extract the proper values for
the header files and libraries. That works for me with Open MPI.  Can you try it?
| Surely you can add these examples to next RInside tarball.

Awesome, thanks.  We will of course give you proper credits for the contribution.


## -*- mode: make; tab-width: 8; -*-
## Simple Makefile
## TODO: 
##  proper configure for non-Debian file locations,   [ Done ]
##  allow RHOME to be set for non-default R etc

## comment this out if you need a different version of R, 
## and set set R_HOME accordingly as an environment variable
R_HOME := 		$(shell R RHOME)

sources := 		$(wildcard *.cpp)
programs := 		$(sources:.cpp=)

# OpenMPI header and libraries
MPICPPFLAGS :=		$(shell mpic++ -showme:compile)
MPILIBS :=		$(shell mpic++ -showme:link)

## include headers and libraries for R 
RCPPFLAGS := 		$(shell $(R_HOME)/bin/R CMD config --cppflags)
RLDFLAGS := 		$(shell $(R_HOME)/bin/R CMD config --ldflags)
RBLAS := 		$(shell $(R_HOME)/bin/R CMD config BLAS_LIBS)
RLAPACK := 		$(shell $(R_HOME)/bin/R CMD config LAPACK_LIBS)

## include headers and libraries for Rcpp interface classes
RCPPINCL := 		$(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RCPPLIBS := 		$(shell echo 'Rcpp:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)

## include headers and libraries for RInside embedding classes
RINSIDEINCL := 		$(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RINSIDELIBS := 		$(shell echo 'RInside:::LdFlags()'  | $(R_HOME)/bin/R --vanilla --slave)

## compiler etc settings used in default make rules
CXX := 			$(shell $(R_HOME)/bin/R CMD config CXX)
CPPFLAGS := 		-Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS)
LDFLAGS	= 		-s

all : 			$(programs)

			rm -vf $(programs)

  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!

More information about the Rcpp-devel mailing list