2012-08-12 348 views
1

我使用英特尔编译器套件编译了Linux上的最新OpenMPI。我正在尝试编译OpenMPI应用程序。我的特殊应用程序使用RInside和RcppEigen。如果我注释掉我的代码的的openmpi部件,编译字符串是:使用英特尔编译器套件编译OpenMPI应用程序

icpc -I/usr/share/R/include -I/usr/lib/R/site-library/Rcpp/include -I/usr/local/lib/R/site-library/RInside/include -O3 -pipe -g -Wall -I/usr/local/lib/R/site-library/RcppEigen/include sjb_simple_smle_with_Rinside.cpp -L/usr/lib/R/lib -lR -lblas -llapack -L/usr/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/lib/R/site-library/Rcpp/lib -L/usr/local/lib/R/site-library/RInside/lib -lRInside -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -o sjb_simple_smle_with_Rinside 

因此,我试图与MPIC编译++使用:

MPIC++ -I的/ usr /共享/ R /包括-I/usr/lib/R/site-library/Rcpp/include -I/usr/local/lib/R/site-library/RInside/include -O3 -pipe -g -Wall -I/usr/local/lib/R/site-library/RcppEigen/include sjb_simple_smle_with_Rinside.cpp -L/usr/lib/R/lib -lR -lblas -llapack -L/usr/lib/R/site-library/Rcpp/lib -lRcpp - Wl,-rpath,/ usr/lib/R/site-library/Rcpp/lib -L ​​/ usr/local/lib/R/site-library/RInside/lib -lRInside -Wl,-rpath,/ usr/local/LIB/R /站点-LIB郭宝宏/ RInside/lib目录-o sjb_simple_smle_with_Rinside

如果我取消

#include "mpi.h" 

,并尝试编译,我得到以下错误。使用英特尔编译器编译OpenMPI应用程序有什么窍门吗?完整的源列表如下:

[email protected]:~/Projects/big_data_sim_mle/simple_smle/R_inside_version$ mpic++ -I/usr/share/R/include -I/usr/lib/R/site-library/Rcpp/include -I/usr/local/lib/R/site-library/RInside/include -O3 -pipe -g -Wall -I/usr/local/lib/R/site-library/RcppEigen/include sjb_simple_smle_with_Rinside.cpp -L/usr/lib/R/lib -lR -lblas -llapack -L/usr/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/lib/R/site-library/Rcpp/lib -L/usr/local/lib/R/site-library/RInside/lib -lRInside -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib -o sjb_simple_smle_with_Rinside -shared-intel -I/usr/local/include -pthread -L/usr/local/lib -lmpi_cxx -lmpi -ldl -lm -Wl,--export-dynamic -lrt -lnsl -lutil 
/usr/local/include/openmpi/ompi/mpi/cxx/datatype.h(142): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/datatype.h(142): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/datatype.h(142): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/datatype.h(142): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/datatype.h(142): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/op.h(48): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/op.h(48): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/op.h(48): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/op.h(48): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/op.h(48): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request.h(96): error: expected a type specifier 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request.h(96): error: expected a ")" 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request.h(96): error: expected an identifier 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request.h(96): error: "virtual" is not allowed 
    virtual void Free(void); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/request.h(96): error: expected a ";" 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/group.h(111): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/group.h(111): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/group.h(111): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/group.h(111): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/group.h(111): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/comm.h(264): error: expected a type specifier 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/comm.h(264): error: expected a ")" 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/comm.h(264): error: expected an identifier 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/comm.h(264): error: "virtual" is not allowed 
    virtual void Free(void); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/comm.h(264): error: expected a ";" 
    virtual void Free(void); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/win.h(118): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/win.h(118): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/win.h(118): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/win.h(118): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/win.h(118): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/errhandler.h(59): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/errhandler.h(59): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/errhandler.h(59): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/errhandler.h(59): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/errhandler.h(59): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/info.h(84): error: expected a type specifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/info.h(84): error: expected a ")" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/info.h(84): error: expected an identifier 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/info.h(84): error: "virtual" is not allowed 
    virtual void Free(); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/info.h(84): error: expected a ";" 
    virtual void Free(); 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(39): error: expected an identifier 
    MPI::Request::Free() 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(38): error: inline specifier allowed on function declarations only 
    inline void 
^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(39): error: incomplete type is not allowed 
    MPI::Request::Free() 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(39): error: a nonstatic member reference must be relative to a specific object 
    MPI::Request::Free() 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(39): error: expected an expression 
    MPI::Request::Free() 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(39): error: expected a ")" 
    MPI::Request::Free() 
       ^

/usr/local/include/openmpi/ompi/mpi/cxx/request_inln.h(40): error: expected a ";" 
    { 
^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(123): error: identifier "ompi_op_set_cxx_callback" is undefined 
     ompi_op_set_cxx_callback(mpi_op, (MPI_User_function*) func); 
    ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(128): error: expected an identifier 
    MPI::Op::Free() 
     ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(127): error: inline specifier allowed on function declarations only 
    inline void 
^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(128): error: incomplete type is not allowed 
    MPI::Op::Free() 
     ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(128): error: a nonstatic member reference must be relative to a specific object 
    MPI::Op::Free() 
     ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(128): error: expected an expression 
    MPI::Op::Free() 
     ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(128): error: expected a ")" 
    MPI::Op::Free() 
     ^

/usr/local/include/openmpi/ompi/mpi/cxx/op_inln.h(129): error: expected a ";" 
    { 
^

sjb_simple_smle_with_Rinside.cpp(35): warning #12: parsing restarts here after previous syntax error 
    using namespace Rcpp; 
        ^

sjb_simple_smle_with_Rinside.cpp(77): error: identifier "as" is undefined 
    const Map<MatrixXd> Xmat(as<Map<MatrixXd> >(Xmat_sexp)); 
          ^

sjb_simple_smle_with_Rinside.cpp(77): error: type name is not allowed 
    const Map<MatrixXd> Xmat(as<Map<MatrixXd> >(Xmat_sexp)); 
           ^

sjb_simple_smle_with_Rinside.cpp(80): error: type name is not allowed 
    const Map<MatrixXd> Ymat(as<Map<MatrixXd> >(Ymat_sexp)); 
           ^

sjb_simple_smle_with_Rinside.cpp(87): error: type name is not allowed 
    const Map<MatrixXd> ua(as<Map<MatrixXd> >(ua_sexp)); 
          ^

sjb_simple_smle_with_Rinside.cpp(89): error: type name is not allowed 
    const Map<MatrixXd> ub(as<Map<MatrixXd> >(ub_sexp)); 
          ^

sjb_simple_smle_with_Rinside.cpp(98): error: type name is not allowed 
    const Map<VectorXd> start_vector(as<Map<VectorXd> >(start_sexp)); 
             ^

compilation aborted for sjb_simple_smle_with_Rinside.cpp (code 2) 

完整的源代码:

// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*- 
// 
// SJB - first shot at RInside and Eigen combined 
// 
// Copyright (C) 2012    Stephen J. Barr 
// 
// GPL'ed 


#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <fstream> 
#include "mkl.h" 
#include "math.h" 
#include <vector> 
#include <cmath> 
#include <string> 
#include <cstdlib> 
#include <fcntl.h> 
#include <sys/stat.h> 
#include <ctype.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <getopt.h> 
#include <map> 
#include <utility> 

#include <RcppEigen.h> 
#include <Rcpp.h> 
#include <RInside.h>       // for the embedded R via RInside 
#include "mpi.h" 

using namespace Rcpp; 
using namespace Eigen; 
using namespace std; 
int main(int argc, char *argv[]) { 


    const int N_TRU_PARAMS = 5; 
    const int n = 1000; 
    const int t = 100; 
    const int nr = 500; 

    RInside R(argc, argv);      // create an embedded R instance 

    stringstream ss; 
    ss << "n = " << n << "; t = " << t << ";" << " nr = " << nr << ";"; 
    cout << ss.str() << endl; 
    R.parseEval(ss.str()); 

    VectorXd tru = VectorXd(N_TRU_PARAMS); 
    tru << 2,1,-2,1,1; 

    // R.parseEval("n = 100;"); 
    // R.parseEval("t = 100;"); 
    R.parseEval("set.seed(123)"); 
    string cmdstr = "tru = c(2,1,-2,1,1);" 
        "set.seed(123);" 
        "a = rnorm(n,tru[1],tru[2]);" 
        "b = rnorm(n,tru[3],tru[4]);"   
    //    Make some data lists 
        "x = NULL;" 
        "y = NULL;" 

    //    Generate some data for each firm 
        "for(i in 1:n) {" 
        " x[[i]] = rnorm(t,1,1);" 
        " y[[i]] = a[i]+b[i]*x[[i]]+ rnorm(t)*tru[5];" 
    "}"; 


    R.parseEval(cmdstr); 

    SEXP Xmat_sexp = R.parseEval("Xmat = do.call(rbind, x)"); 
    const Map<MatrixXd> Xmat(as<Map<MatrixXd> >(Xmat_sexp)); 

    SEXP Ymat_sexp = R.parseEval("Ymat = do.call(rbind, y)"); 
    const Map<MatrixXd> Ymat(as<Map<MatrixXd> >(Ymat_sexp)); 

    cout << "X: " << Xmat.rows() << " x " << Xmat.cols() << endl; 
    cout << "Y: " << Ymat.rows() << " x " << Ymat.cols() << endl; 

    // Make matrices ua and ub 
    SEXP ua_sexp = R.parseEval( "ua = matrix(rnorm(nr*n),n,nr)"); 
    const Map<MatrixXd> ua(as<Map<MatrixXd> >(ua_sexp)); 
    SEXP ub_sexp = R.parseEval( "ub = matrix(rnorm(nr*n),n,nr)"); 
    const Map<MatrixXd> ub(as<Map<MatrixXd> >(ub_sexp)); 

    cmdstr = "track = 0;" 
    "Y = unlist(y);" 
    "X = unlist(x);" 
    "start = lm(Y~X)$coeff;" 
    "start =c(start[1],0,start[2],0);"; 
    R.parseEval(cmdstr); 
    SEXP start_sexp = R.parseEval("start"); 
    const Map<VectorXd> start_vector(as<Map<VectorXd> >(start_sexp)); 

    cout << "Starting point: " << start_vector.transpose() << endl; 

    // THERE ARE TWO PAIRS OF FUNCTIONS, smle_init and smle_nll_mpi 
    // smle_init: distributes, using mpi broadcast, the necessary 
    // data to all machines. 
    // 
    // smle_nll_mpi: assuming smle_init has been successfully completed 
    // compute the negative log likelihood using MPI 
    // 

    // for now, these functions will be written out in the code 


    // // MPI INITIALIZATION 
    // int rank, size; 
    // const int root = 0; 
    // cout << "Before init" << endl; 
    // MPI::Init(); 
    // rank = MPI::COMM_WORLD.Get_rank(); 
    // size = MPI::COMM_WORLD.Get_size(); 
    // double * ua_ptr = ua.data(); 
    // double * ub_ptr = ub.data(); 

    cout << "Initializating MPI Broadcast" << endl; 


} 
+0

要求打开MPI相关问题的最佳位置在[Open MPI邮件列表](http://www.open-mpi.org/community/lists/ompi.php)上。 ** User **列表背后的社区特别有用。 – 2012-08-12 10:26:37

+0

谢谢Hristo。我也通过电子邮件发送了名单,但没有收到回复。希望我找出一些东西。 – stevejb 2012-08-12 22:51:26

+0

周日通常不是名单上最繁忙的一天。不过,你已经明白了,这很好。快乐消息传递并记住MPI C++接口在MPI 2.2中已被_deprecated_并且将从MPI 3.0中完全删除。 – 2012-08-13 07:40:51

回答

1

RInside package带有工作例子为MPI:

[email protected]ax:~$ ls -l /usr/local/lib/R/site-library/RInside/examples/mpi/ 
total 24 
drwxr-xr-x 2 edd staff 4096 Jun 27 10:14 cmake 
-rw-r--r-- 1 edd staff 1897 Jun 27 10:14 Makefile 
-rw-r--r-- 1 edd staff 1224 Jun 27 10:14 rinside_mpi_sample0.cpp 
-rw-r--r-- 1 edd staff 2896 Jun 27 10:14 rinside_mpi_sample1.cpp 
-rw-r--r-- 1 edd staff 1137 Jun 27 10:14 rinside_mpi_sample2.cpp 
-rw-r--r-- 1 edd staff 2836 Jun 27 10:14 rinside_mpi_sample3.cpp 
[email protected]:~$ 

工作化妆支持和CMake。我会从那里开始。增加对RcppEigen的支持可能是微不足道的;我刚刚在几天前为RInside的SVN添加了另一个RcppArmadillo的示例目录。

如果Free()的定义很差,那么您可能会遇到头文件冲突,您可以通过重新排序包含语句来避免这种冲突。我没有英特尔编译,所以我不能帮助。

最后:推荐获取Rcpp和RInside帮助的方法是询问 rcpp-devel邮件列表。

+0

嘿德克,谢谢你的指针。我认为这是一个比Rcpp/RIniside问题更多的mpi问题。但是,我用g ++构建了所有inst/examples/mpi示例,并且它们构建得很好。我将g ++更改为icpc,构建也起作用,所以我认为你是对的,它与包含的顺序有关。与往常一样,非常感谢您提供快速有用的帮助。我非常喜欢Rcpp和RInside。 – stevejb 2012-08-12 22:54:14

+0

如果你得到它的工作,真正赞赏'rcpp-devel'的帖子。 – 2012-08-12 22:55:28

+0

会做。谢谢! – stevejb 2012-08-12 23:49:10