A Study on Parallel Computation Based on 3 D Forward Algorithm of Gravity

Interpretation of geophysical material is the prospecting method. Interpretation of Gravity-megnetic data is based on data processing and inversion. When the grid is divided into several million cells, the computing task is heavy and time-consuming. In order to increase efficiency of the 3D forward modeling, the paper will adopt MPI parallel algorithm and the several processes will deal with data in the method. Finally, we can gather the result. Through comparing the result of sequence algorithm with the result of MPI parallel algorithm, we can see the result is the same. When the number of processes is 2 to 8, the speed-up ratio is 1.97 to 5. The MPI parallel algorithm is very efficient.


Introduction
Interpretation of Gravity-megnetic data is based on data processing and inversion.Forward modeling is important and difficult in the interpretation of geophysical data [1] [2] [3], so we spend much time to do research on the problem and get much achievement.With the development of demand for geophysical data interpretation, 2D gravity-megnetic forward modeling can't meet the requirement of identifying the geological structure, so we need to develop the gravity 3D forward modeling [4] [5] [6].3D forward modeling is very difficult and the increased computation task makes it more difficult.Many researchers do research on the problem and raise treatment method.Changli Yao adopts the grid separation and storage technology, the method decreases the computation tasks and storage [7] [8], so it gets better effect.In the method we need to sup-M.Wang

Gravity 3D Forward Modeling
We divide the source field underground into many cuboids (Figure 1).Forward modeling is the basic work of inversion [11] [12].By means of traditional method that deals with the forward data one by one, the computation tasks will be huge and it will take a long time.The 3D density model forward equation illustrates the forward status.In the Figure 1, according the known equation we can get the gravity anomaly of the P(x,y,z) which is the jth cell. ( )( ) G is gravitational constant, σ j is the density of the jth cell.

( ) ( ) ( )
By analyzing the equation, we know that in order to compute the gravity anomaly that the jth cell produces at the point P(x,y,z), we need to do so many computations: 16 times log, 8 times inverse trigonometric functions, 64 times multiplications, 8 times divisions, 8 times evolutions, 120 times additions or subtractions.The computation task is so huge for a cell at a point.If the number of the model cell is big, the total computation task will be very huge.The total computation is very huge, so the huge computation is a bottleneck problem.

Introduction of MPI
MPI realize the data broadcasting, data sending, data receiving and data synchronization [13].MPI support several data type, including complex.Although In the MPI program, every process has all the variates and functions.The variates and functions have the same name, but the data in the variate is always not the same.If the process needs to know the data of other process, it needs to communicate.Every process can allocate different memory for a pointer.When the task is different for a process in the 3D gravity forward algorithm, it needs to allocate memory more flexibly [14] [15].

The MPI Parallel Algorithm Based on 3D Gravity Forward
The gravity forward modeling is that the sum of the anomaly that every cuboid in the model produces.The serial program needs loop computation for 5 times.
For the observing point, we need to calculate the point of x direction and y direction.For every point, we need calculate the sum of anomaly that the cell produces for x direction, y direction and z direction.The pseudo-code is following.
For(i=1;i<nx_obs;i++) //observing x direction, nx_obs points For(j=1;i<ny_obs;i++) //observing x direction, ny_obs points For(l=1;i<nz_model;i++) //cells along the z direction，the number of cells along z direction is nz_model For(m=1;i<nx_model;i++) //cells along the x direction，the number of cells along x direction is nz_model For(n=1;i<ny_model;i++) //cells along the y direction，the number of cells along y direction is nz_model forwarddata(I,j) =forwarddata (I,j)+forward(I,j,l,m,n) We analyze the 3d gravity forward algorithm and find that the algorithm needs loop computation for 5 times.The loop is the main work for parallel computation.We can divide the nx_obs into several parts for processes.The computation task that every process in parallel algorithm needs to do is less than that in the serial algorithm.cates the computation tasks to every process, and process 0 is the manager process.It reads the parameter file, and allocates the computation tasks to every process.It broadcasts the parameter to processes, and gathers the data result from processes.Finally, it writes the result file.Other processes receive the parameter, and do the computation tasks.They send the data result to the manager process.At the same time, manager process also do computation task.We will introduce the performing process.
(1) Initial the MPI environment, MPI_INT().The manager process reads the model data and broadcasts the data to other process, MPI_Bcast().
(2) The manager process allocates the computation tasks according to the task   1. Processes do the tasks separately and get the forward data for every observed point.
(3) After all the processes have done the tasks, the manager process gathers the data.Command: Mpiexec -np N ./gstd_forwardN is the number of processes.

Result and Discussions
The grid of the model is 101 × 101 × 30.The model is 101 columns, 101 rows and 30 layers.The distance along x direction between 2 neighbor points is 10 m, the distance along y direction between 2 neighbor points is 10 m, the distance along z direction between 2 neighbor points is 2 m.The observed points are 101 × 101 on the ground.

Validate of the Forward Result
The parallel computation is based on the serial program.According to the characteristics, that process does computation task separately.It distributes the tasks to all processes and never changes other algorithm, so the parallel computation result is the same with the serial program's result.The study compares the forward result of two programs, the result is the same.We choose a line to draw a picture.In Figure 3, x axis is position of the observed point, y axis is the Δg forward data, dot is the MPI result and plus is the serial algorithm result.We can see that the forward data in 6th row is the same, so it proves the validity of the program.

Discussions of Parallel Efficiency
Analysis of the Table 2 shows that the efficiency is the highest when the number of processes is 2. The speedup changes slightly and the efficiency declines when   the number of processes changes from 4 to 8. The communication of the processes occupy much time when the number of processes increases from 4 to 8. We can see that the effect of parallel algorithm is very obvious.When the number of processes is 8, we can save 52 minutes compared to sequential algorithm.

Conclusion
The computation of 3D gravity forward for relatively big grid spends much time and the forward algorithm is called for dozens of times, so the key to the problems is parallel computation.The study realizes the parallel algorithm for 3D gravity forward in the MPI environment.The algorithm is proved correct and efficient.The study lays the foundation of the parallel computation for 3D gravity inversion.

Figure 1 .
Figure 1.(a) rectangular model, (b) a cell of the model.
Firstly, we need to divide the computation task into several parts.count = nx_obs / size; // observing along x direction, nx_obs points.Size is the number of processes segment = nx_obs %size; //when tasks is allocated for every process equally, segment is the number of remainder for (i = 0; i < size; i++) an array.The array records the computation task that every process needs to do.For example, nx_obs is 101, size is 4. We known parr[0] = 26, M. Wang et al.DOI: 10.4236/ijg.2017.890601076 International Journal of Geosciences parr[1] = 25, parr[2] = 25, parr[3] = 25.The processes need to calculate 1 -26, 27 -51, 52 -76, 77 -101 row data, so every process do smaller task in the MPI algorithm than that in the serial algorithm.The method uses MPI_Gatherv function to gather result.In the parallel algorithm, the program allocates the computation tasks, and every process only has his data result.If we don't gather the data result, the process can write a file for the result data.For example the algorithm has 4 processes, we can get 4 files of data.If we want to get the final data result, we need merge 4 files manually.It is very difficult.MPI_Gatherv (forwarddata, count, MPI_FLOAT, forwarddata_all, rcounts, displs, MPI_FLOAT, 0, MPI_COMM_WORLD).The function MPI_Gatherv gathers the forwarddata to forwarddata_all and gathers the data from different process to one process.The length of the data can not the same.It is very useful.

Figure 2
Figure 2 is gravity 3D forward MPI algorithm flow chart.The program allo-

( 4 )
The manager process writes the data file and finalize the MPI environ-

Figure 3 .
Figure 3. Forward result figure in 6 th row.
et al.
DOI: 10.4236/ijg.2017.890601074 International Journal of Geosciences plement many observation points.Zhaoxi Chen adopts the GPU parallel technology to accelerate the processing speed and it gets good effects [9] [10].The paper adopts the MPI parallel technology to accelerate the processing speed of 3D forward modeling.It gets good effects.

Table 2 .
3D gravity forward parallel algorithm time used statistics.