Parallelization of the Phase Field Model: Difference between revisions

From Micro and Nano Mechanics Group
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:


== A brief description ==
== A brief description ==
The basic formulation of the phase field model is described in the MSMSE 2014 paper. Base on this, a C++ serial code has been written under the MD++ framework. The below figure gives a flow chart of the phase field code, in order to clarify the codes’ structure.
The basic formulation of the phase field model is described in our [[media:Multi_phase_field_MSMSE_2014.pdf‎ |MSMSE 2014 paper]]. Base on this, a C++ serial code has been written under the MD++ framework. The below figure gives a flow chart of the phase field code, in order to clarify the codes’ structure.


[[Image: Phasefield_flow_chart.jpg | frame | center]]
[[Image: Phasefield_flow_chart.jpg | frame | center]]
Line 31: Line 31:


== MPI code ==
== MPI code ==
The MPI related files are src/phasefield_mpi.cpp, and src/StencilToolkit. Some modifications are also made in src/main.cpp for initialize and finalize MPI

For the current MPI implementation, we adopted the StencilToolkit library developed by KISTI to divide the 3D arrays into designate chunks, considering the periodic boundary and the boundary synchronization.
The number of nodes is specified with the following command in the src/phasefield.cpp. n_x, n_y and n_z give the number of nodes in each dimension.
_node = new Node3D(n_z, n_y, n_x)
These numbers are required to be specified before compilation. In addition, the number of grids should be divisible by the number of nodes for each dimension. For example, NX%n_x = 0.
To compile the code, still using cluster MC2 as the example, type

make phasefield build=R SYS=mc2_mpi MPI=yes

After the MPI code is compiled, it should generate the executable phasefield_mc2_mpi in bin/ and a library file libstk.so in the same folder. To make this shared library loaded when the program is running, the following command is required, assuming the current directory is the MD++ home folder.
export LD_LIBRARY_PATH = “./bin:$LD_LIBRARY_PATH”

== CUDA code ==

Revision as of 04:57, 1 April 2015


Parallelization of the Phase Field Model

Yanming Wang and Wei Cai

Mar 31 , 2015



A brief description

The basic formulation of the phase field model is described in our MSMSE 2014 paper. Base on this, a C++ serial code has been written under the MD++ framework. The below figure gives a flow chart of the phase field code, in order to clarify the codes’ structure.

Phasefield flow chart.jpg

Starting from the serial c++ code, parallelization is done with OpenMP, MPI, and CUDA three approaches. In the following sections, we would like to show how to use these parallel codes in details.

OpenMP code

src/phasefield_omp.cpp contains our implementation of the OpenMP code. To compile the code, using cluster MC2 as an example, type

   make phasefield build=R SYS=mc2_omp

You may check src/Makefile.base to look at the flags we set up for compiling OpenMP. Generally adding the specification of “-openmp” for icc compiler or “-fopenmp” for gcc compiler should make the computer to recognize OpenMP.

In this example, if the code is compiled successfully, the executable should be named as phasefield_mc2_omp in the bin/ folder.

You can specify the number of threads you want to use. For example if you want to have 8 threads for your simulation, you can type the following line in the command window (or include it in the PBS script) .

   export OMP_NUM_THREADS = 8

MPI code

The MPI related files are src/phasefield_mpi.cpp, and src/StencilToolkit. Some modifications are also made in src/main.cpp for initialize and finalize MPI

For the current MPI implementation, we adopted the StencilToolkit library developed by KISTI to divide the 3D arrays into designate chunks, considering the periodic boundary and the boundary synchronization. The number of nodes is specified with the following command in the src/phasefield.cpp. n_x, n_y and n_z give the number of nodes in each dimension. _node = new Node3D(n_z, n_y, n_x) These numbers are required to be specified before compilation. In addition, the number of grids should be divisible by the number of nodes for each dimension. For example, NX%n_x = 0. To compile the code, still using cluster MC2 as the example, type

  make phasefield build=R SYS=mc2_mpi MPI=yes

After the MPI code is compiled, it should generate the executable phasefield_mc2_mpi in bin/ and a library file libstk.so in the same folder. To make this shared library loaded when the program is running, the following command is required, assuming the current directory is the MD++ home folder.

 export LD_LIBRARY_PATH = “./bin:$LD_LIBRARY_PATH” 

CUDA code