一、GA库的安装
- 解压
- configure
./configure F77=gfortran CC=gcc CXX=g++ MPIF77=mpif77 MPICXX=mpicxx MPICC=mpicc \
--with-gnu-ld --enable-cxx --prefix=/home/jrf/tools/ga-5.8 \
--exec-prefix=/home/jrf/tools/ga-5.8 --with-blas=/home/jrf/tools/openblas \
--with-mpi-pr=1
- make && make install
注意
-
--with-mpi-pr=1
将ARMCI的网络模式设置为Mpi-pr的模式,这是最被推荐的选项。若不设置mpi-pr,默认使用mpi-ts,不支持异步通信,可能会在和PETSc函数库结合的时候导致通信死锁。使用了mpi-pr 之后,每个节点会有一个进程被用来专门负责通信,不支持实际的计算任务。在该模式下编程时,需要使用GA的函数创建一个新的通信子,该通信子包含的仅有可以用来执行计算的进程,在使用boost和PETSc的时候需要将GA生成的通信子传递给这两个函数库。具体看这里。
二、部分函数使用介绍
1.put get的使用
void GlobalArray::put(int lo[], int hi[], void *buf, int ld[])
Type | Name | Description | Intent |
---|---|---|---|
int* | lo[ndim] | array of starting indices for global array section | input |
int* | hi[ndim] | array of ending indices for global array section | input |
void* | buf | pointer to the local buffer array where the data is | input |
int* | ld[ndim-1] | array specifying leading dimensions/strides/extents for buffer array | input |
(1)二维数组
当为2维数组时,这里的lo、hi包含的第一个数字和第二个数字分别为行索引、列索引,而ld仅有一个数字,代表总列数(因为用的是c++,数组是按行存储的。)
完整的测试算例:
#include<boost/mpi.hpp>
#include<iostream>
#include"ga++.h"
#include<macdecls.h>
#include<vector>
namespace mpi = boost::mpi;
void test_get();
int main(int argc, char **argv){
int heap = 3000000, stack = 3000000;
size_t size = 0;
GA::Initialize(argc, argv, heap, stack