简体   繁体   English

从 C++ 调用 ScaLAPACK

[英]Calling ScaLAPACK from C++

Hi can any one provide me an example Makefile for calling ScaLAPACK from C++, I am having difficulties.嗨,任何人都可以为我提供一个示例 Makefile,用于从 C++ 调用 ScaLAPACK,我遇到了困难。

I have the newest version compiled correctly with all the tests passed.我已经正确编译了最新版本,并通过了所有测试。 I have it compiled with GCC and OpenMPI on Fedora, and I have also tried using the pre-built binaries from the repository with no luck.我在 Fedora 上用 GCC 和 OpenMPI 编译了它,我也尝试使用存储库中的预构建二进制文件,但没有成功。

I used the following declarations for ScaLAPACK procedures:我对 ScaLAPACK 过程使用了以下声明:

extern "C" void pdgesvd_(char *jobu, char *jobvt, int *M, int *N, double *A, int *ia, int *ja, int *desca, double *s, double *u, int *iu, int *ju,
            int *descu, double *vt, int *ivt, int *jvt, int *descvt, double *work, int *lwork, int *info);

extern "C" void pdgemv_(char *t, int *M, int *N, double *alpha, double *A, int *ia, int *ja, int *desca, double *X, int *ix, int *jx,int *descx,
            int *incx, double *beta, double *Y, int *iy, int *jy, int *descy, int *incy);


extern "C" void pdgemm_(char *transa, char *transb, int *M, int *N, int *K, double *alpha, double *A, int *ia, int *ja, int *desca, double *B,
            int *ib, int *jb, int *descb, double *beta, double *C, int *ic, int *jc, int *descc);

BLACS procedures are declared in the same way: BLACS 过程以相同的方式声明:

extern "C" void blacs_get_(/*in*/int *icontxt, /*in*/int *what, /*out*/int *val); 

I append the "_" character to procedure names, because BLAS and ScaLAPACK were built with -DAdd_ compiler option.我将“_”字符附加到过程名称,因为 BLAS 和 ScaLAPACK 是使用 -DAdd_ 编译器选项构建的。 This may be different for your system.这可能因您的系统而异。 If so, try objdump -t on libscalapack.a and other static library files to determine actual procedure names.如果是这样,请在libscalapack.a和其他静态库文件上尝试objdump -t以确定实际过程名称。

Your program with ScaLAPACK calls may be compiled with something like this:带有 ScaLAPACK 调用的程序可能会被编译成这样:

mpicxx -o your_binary_name -O2 your_source.cpp -lscalapack -lblacs -lcblacs -lblacs -llapack -lblas -lgfortran

Note that the order of static libraries in g++ invocation line ( -lblacs -lcblacs -lblacs -llapack -lblas -lgfortran ) is important!请注意,g++ 调用行( -lblacs -lcblacs -lblacs -llapack -lblas -lgfortran )中静态库的顺序很重要! Also check the existance of all these static library files ( libblas.a , libcblacs.a and so on) in the library directories.还要检查库目录中所有这些静态库文件( libblas.alibcblacs.a等)是否存在。 Don't forget about Fortran package (for -lgfortran ).不要忘记 Fortran 包(对于-lgfortran )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM