计算物理ComputationalPhysics计算物理 (10).pdf
《计算物理ComputationalPhysics计算物理 (10).pdf》由会员分享,可在线阅读,更多相关《计算物理ComputationalPhysics计算物理 (10).pdf(31页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Computational physiCsHigh-performance computing PC,cluster,supercomputer Parallelism by OpenMP Parallelism by MPI GPU programming Numerical librariesPC:Personal Computer Usually 1 CPU(Central processing unit)per computer Even though,it is already very powerful.x86(x86-64)-compatible microprocessors:
2、the most used CPUs in PCs.PentiumCore i3 i5,i7Athlon,PhenomA4,A6,A10,FXworkstation-powerfultower workstation4U workstation2U workstation1U workstationU=Rack unit1U rack Usually more than 1 CPU per node.Intel:Xeon AMD:OpteronNon-x86/x86-64 compatible CPUs Intel:ItaniumIntel architecture 64 IBM:Power(
3、Performance Optimization With Enhanced RISC)总参56所:ShenweiRISC architechture IOCT:CAS:LoongsonMIPS architechture Nvidia:TegraARM architectureCluster More than 1 computer(node)Connect by network Work together.More Powerful than PCCheaper than supercomputerCan be small:BladesTransformers The philosophy
4、 of PC cluster.Devastator挖地虎-大力神SupercomputerMore CpusFaster connectionvery expensiveParallelismBig problem?needs long CPU-time?The solution:Simplify the problem!Use a faster CPU!Use more than 1 CPU!-ParallelismProverb:Many hands make light work!Code example for(int i=0;i1000000;i+)ai=i;If you only
5、have one cpu:The process is:1.a0=0;2.a1=1;3.a2=2;.If you have two cpus:You can divide the task to two cpus:1.a0=0;a1=1;2.a2=2;a3=3;3.a4=4;a5=5;.(even)(odd)Save half time!automatically parallelized by compilersOne process,several threadsExample:9.1.openmp.cpp#include#include using namespace std;int m
6、ain()const int n=8;#pragma omp parallel forfor(int i=0;in;i+)couti;sleep(1);coutendl;return 0;g+9.1.openmp.cpptime./a.outg+-fopenmp 9.1.openmp.cpptime./a.outexport OMP_NUM_THREADS=29.2.openmp2.cppMPI-Message Passing Interface MPI is a language-independent communications protocol used to program para
7、llel computersSeveral software implementations:Open MPIMPICH/MPICH2LAM/MPIIntel MPIMicrosoft MPIcode example:9.3.mpi.cpp#include#include using namespace std;int main(int argc,char*argv)MPI_Init(&argc,&argv);int mpi_procs,mpi_rank;MPI_Comm_size(MPI_COMM_WORLD,&mpi_procs);MPI_Comm_rank(MPI_COMM_WORLD,
8、&mpi_rank);coutIt is the mpi_rank of total mpi_procsendl;MPI_Finalize();return 0;Compile and run a MPI program Install one MPI implementation,e.g.OpenMPI mpic+9.3.mpi.cpp mpirun-np 10 a.outMPI for molecular dynamics If you have N degrees of freedom during the molecular dynamics simulation,you can us
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算物理ComputationalPhysics计算物理 10 计算 物理 ComputationalPhysics 10
限制150内