html5-img
1 / 48

Linux 与并行计算

Linux 与并行计算. 曙光信息产业(北京)有限公司 技术支持中心 戴荣 2007 年 12 月. 主要内容. 并行计算简介 Linux 与 HPC 搭建 Linux Cluster 小结. 并行计算 -- 高性能计算. 并行计算 (Parallel Computing ) 高性能计算 (High Performance Computing) 并行计算,就是在并行机上所做的计算 理论、实验与计算,被认为是人类认识自然的三大支柱。 降低单个问题求解的时间 提高问题求解精度 增加问题求解规模 无法替代的模拟计算.

vance
Download Presentation

Linux 与并行计算

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux与并行计算 曙光信息产业(北京)有限公司 技术支持中心 戴荣 2007年12月

  2. 主要内容 • 并行计算简介 • Linux与HPC • 搭建Linux Cluster • 小结

  3. 并行计算--高性能计算 • 并行计算(Parallel Computing) • 高性能计算(High Performance Computing) • 并行计算,就是在并行机上所做的计算 • 理论、实验与计算,被认为是人类认识自然的三大支柱。 • 降低单个问题求解的时间 • 提高问题求解精度 • 增加问题求解规模 • 无法替代的模拟计算

  4. 为什么要做并行计算? --应用需求

  5. 并行计算机 • 并行计算机就是由多个处理单元组成的计算机系统,这些处理单元相互通信和协作以快速、高效求解大型复杂问题。 • 处理单元有多少 • 处理单元的功能有多强 • 处理单元之间怎样连接 • 处理单元的数据如何传递 • 各处理单元如何相互协作 • 并行程序如何编写

  6. 并行计算机的发展 • (1)并行机的萌芽阶段(1964-1975) • (2)向量机/ SMP的发展和鼎盛阶段(1976-1990) • (3)MPP出现和蓬勃发展阶段(1990-1995) • (4)Cluster出现,并成为并行计算机的主流(1995年后)

  7. 并行计算机结构模型

  8. 各种架构对比 • 共享存储体系结构 • SMP瓶颈在访存带宽,限制了可扩展性(性能会严重下降),通过增大Cache来缓解,又有数据一致性的问题。 • DSM具有较好的可扩展性,且具有与SMP相同的编程模式。共享存储的机器可以运行各种编程模式的程序,包括串行程序、共享存储并行程序和消息传递并行程序。 • 共享存储的机器首先可以看作是一个内存扩充了的串行机器,可以运行数据量极大的串行程序,如大数据量的数据库应用。利用多个处理器的并行处理性能,自动并行(靠编译器)作用有限,需要其他编程方式的应用,如OpenMP。

  9. 各种架构对比(续) • 分布式存储体系结构 • 无共享的机器,MPP和Cluster,具有最好的可扩展性,采用消息传递编程,可编程性不如OpenMP,也可以通过DSM软件的方式来模拟实现共享存储(其实还是通过消息传递,只不过对上层通明),性能受到影响,但可以运行OpenMP应用程序。 • MPP/PVP在构造大规模系统,应用饱和性能方面具有优势,资金充足的依然会选择; • Cluster由于无可比拟的性价比优势占据主流位置。 • 更高的计算能力 • 系统的高可用性 • 良好的可扩展性 • 更高的性价比

  10. 主要内容 • 并行计算简介 • Linux与HPC • 搭建Linux Cluster • 小结

  11. www.top500.org

  12. Linpack • Linpack是国际上流行的用于测试高性能计算机系统浮点性能的benchmark • 通过对高性能计算机求解线性代数方程组能力的测试,评价高性能计算机的浮点性能 • HPL(High Performance Linpack) • 针对大规模的并行计算机系统的测试 • HPL版Linpack一般用于并行超级计算机 • 用户可以选择矩阵的大小(问题规模)、使用各种优化方法来执行测试程序,寻求最佳的测试结果 • 计算量(2/3 * N^3 – 2*N^2) / 计算时间 • http://www.netlib.org/benchmark/hpl/

  13. Linux在HPC领域的优势 硬件要求 低 并行代码 多 软件成本 低 开源工具 多 维护成本 低 可定制性 好

  14. Linux在HPC领域的劣势 发行版本太多 推广普及不够

  15. 主要内容 • 并行计算简介 • Linux与HPC • 搭建Linux Cluster • 小结

  16. 集群系统体系结构

  17. 采用Linux来搭建集群系统 • 基本流程 • 对头结点/管理结点 • 操作系统安装 • 集群服务配置 • 对每个计算结点 • 操作系统安装 • 集群服务配置 • 集群系统联调

  18. Linux的七种武器 • Linux的七种武器(RedHat) • dd:操作系统克隆 • rsh:远程登录、执行 • mpich:并行编程和运行环境 • nfs:网络共享文件系统 • ntp:集群时间同步 • nis:集群帐号同步 • openpbs:作业调度系统

  19. 七种武器之一:dd • 操作系统克隆 • echo scsi add-single-device 0 0 1 0 > /proc/scsi/scsi • Host: scsi0 Channel: 00 Id: 01 Lun: 00 • dd if=/dev/sda of=/dev/sdb bs=4096 • if:系统源盘 • of:系统镜像盘 • bs:块大小 • 73GB SCSI硬盘 17分钟 • 要求源盘与镜像盘型号完全一致

  20. 七种武器之二:rsh • 远程登录、执行 • 实现节点之间的无密码切换 • 打开服务rsh、rexec、rlogin • chkconfig rsh on • chkconfig rexec on • chkconfig rlogin on • /etc/init.d/xinetd restart • 将所有节点名加入/etc/hosts.equiv

  21. 对于root用户 • echo rsh >> /etc/securetty • echo rexec >> /etc/securetty • echo rlogin >> /etc/securetty • cp /etc/hosts.equiv /root/.rhosts • ssh:更安全的remote shell

  22. 七种武器之三:mpich • 并行编程和运行环境 • 并行编程标准 • 多线程库标准 • Win32 API. • POSIX threads. • 编译制导标准 • OpenMP – 可移植共享存储并行编程标准. • 消息传递库标准–最重要的并行程序设计方式 • MPI • PVM

  23. mpich的安装 • tar -xzvf mpich-1.2.6.tar.gz • cd mpich-1.2.6 • ./configure --prefix=/usr/local/mpich-1.2.6 • make • make install • 环境变量设置 • vi /etc/profile 加入下面的行 • source /etc/profile export MPI_PATH=/usr/local/mpich-1.2.6 export PATH=$MPI_PATH/bin:$PATH export MANPATH=$MPI_PATH/man:$MANPATH

  24. MPICH的使用 • 最简单MPI程序 #include <stdio.h> #include "mpi.h“ int main( int argc,char *argv[] ) { MPI_Init( &argc, &argv ); printf( "Hello, world!\n" ); MPI_Finalize(); return 0; }

  25. MPI程序的编译 • mpicc -o hello hello.c • MPI程序的运行 • mpirun -np 4 hello • mpirun -np 8 -machinefile ma hello

  26. 七种武器之四:nfs • 网络共享文件系统 • 头节点 • 1.打开nfs服务 • chkconfig nfs on • /etc/init.d/nfs start • 2.编辑/etc/exports 假设将/public共享给其它节点 • 不限制用户、可读写、信任客户端、先写入内存 • 3.执行exportfs -a,共享/public目录 • 执行exportfs ,可以看到 /public *(rw,no_root_squash,async) /public <world>

  27. 计算节点 • 1.建/public目录 • mkdir /public • 2.手动挂载nfs • mount server:/public /public • 3.看mount 情况 • 4.开机自动挂载nfs • echo mount node38:/public /public >> /etc/rc.local

  28. 七种武器之五:ntp • 集群时间同步 • 头节点 • 1.设置系统时间 • date -s 20071215 • date -s 15:35 • hwclock --systohc • 2. 修改/etc/ntp.conf文件 • vi /etc/ntp.conf • 3. 打开ntp服务 • chkconfig ntpd on • /etc/init.d/ntpd start # -- CLIENT NETWORK ------- restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap

  29. 计算节点 • 1.与头节点手动同步 • ntpdate node1 • hwclock --systohc • 2. 修改/etc/ntp.conf文件 • vi /etc/ntp.conf • 3. 打开ntp服务 • chkconfig ntpd on • /etc/init.d/ntpd start # --- OUR TIMESERVERS ----- restrict 192.168.0.1 mask 255.255.255.255 nomodify notrap noquery server 192.168.0.1

  30. 七种武器之六:nis • 集群帐号同步 • 头节点 • 1.设定NIS域名 • nisdomainname dawning • echo NISDOMAIN=dawning >> /etc/sysconfig/network • 2.打开NIS服务 • chkconfig ypserv on • chkconfig yppasswdd on • /etc/init.d/ypserv start • /etc/init.d/yppasswdd start

  31. 3.初始化NIS数据库 • /var/lib64/yp/ypinit -m • /etc/init.d/ypserv restart • 4.nfs共享头节点/home目录 • vi /etc/exports • exportfs –a • 计算节点 • 1.设定NIS域名 • nisdomainname dawning • echo NISDOMAIN=dawning >> /etc/sysconfig/network /home *(rw,no_root_squash,async)

  32. 2.打开NIS服务 • chkconfig ypbind on • chkconfig yppasswdd on • /etc/init.d/ypbind start • /etc/init.d/yppasswdd start • 3.使用头节点NIS数据库 • vi /etc/nsswitch • 4.挂载头节点/home目录 • mount node1:/home /home • echo mount node1:/home /home >> /etc/rc.local passwd: files shadow: files group: files passwd: files nis shadow: files nis group: files nis

  33. 5.测试NIS • yptest • 增加/删除/修改用户 • 在头节点上用useradd/userdel/usermod • 重新生成NIS数据库 • /var/lib64/yp/ypinit -m • /etc/init.d/ypserv restart • 修改用户密码 • 不能使用passwd,而要使用yppasswd • 修改 yp 密码会改变系统密码﹐修改系统密码却不改变 yp 密码

  34. 七种武器之七:openpbs • 作业调度系统 • 系统组成

  35. 安装 • 解压源文件包 • tar -zxvf openpbs-2.3.16.tar.gz • cd OpenPBS_2.3.16 • 编译设置 • ./configure --disable-gui –enable-docs --set-server_home=/var/spool/pbs --x-libraries=/usr/X11R6/lib64 • 编译安装 • make • make install

  36. 配置 • 系统配置文件/etc/pbs.conf • 系统启动脚本 • /etc/init.d/openpbs • Server的系统启动脚本 /etc/init.d/pbs_server • Scheduler系统启动脚本 /etc/init.d/pbs_sched • Mom系统启动脚本 /etc/init.d/pbs_mom 头节点 计算节点 #!/bin/sh pbs_home=/var/spool/pbs pbs_exec=/usr/local start_server=1 start_sched=1 start_mom=1 #!/bin/sh pbs_home=/var/spool/pbs pbs_exec=/usr/local start_server=0 start_sched=0 start_mom=1

  37. 头节点 • 初始化server: (第一次运行或者重新配置) • /usr/local/sbin/pbs_server –t create • Server配置目录 • /var/spool/pbs/server_priv/ • 节点属性声明:/var/spool/pbs/server_priv/nodes node2 R220A np=2 node3 R220A np=2 node4 dualcore np=4 node5 dualcore np=4 node6 R4280A np=4 node7 R4280A np=4

  38. 队列设置 • 导入server配置文件:qmgr < queue.conf • 输出配置文件:qmgr –c “print server” > queue.conf • 配置文件例子: create queue default set queue default queue_type = execution set queue default max_running = 20 set queue default enabled = True set queue default started = True set server scheduling = True set server max_user_run = 20 set server default_queue = default set server query_other_jobs = True

  39. 计算节点 • mom配置目录: /var/spool/pbs/mom_priv/ • mom配置文件: /var/spool/pbs/mom_priv/config # MOM server configuration file # if more than one value, separate it by comma. ## rule is defined by the name $ideal_load 1.5 $max_load 2 ## host allowed to connect to Mom server on unprivileged port $restricted *. ## log event : # 0x1ff log all events + debug events # 0x0ff just all events $logevent 0x0ff ## host allowed to connect to mom server on privileged port $clienthost node1 ## alarm if the script hang or take very long time to execute $prologalarm 30

  40. 使用 • qsub job.pbs • qstat #PBS –N vasp.Hg #PBS –l nodes=8:ppn=2 echo "This jobs is "$PBS_JOBID@$PBS_QUEUE cd $PBS_O_WORKDIR mpirun -np 16 -machinefile $PBS_NODEFILE ./vasp

  41. NPACI Rocks • National Partnership for Advanced Computational Infrastructure (NPACI) 的Rocks软件,是和Linux操作系统捆绑的集成化的中间件系统,安装和管理都十分方便。http://www.rocksclusters.org/ • NPACI Rocks软件被广泛地应用于学术和政府机构,其中包括西北大学、西北太平洋国家实验室、斯坦福大学等。

  42. Rocks Basic Approach • Install a frontend • Insert Rocks Base CD • Insert Roll CDs (optional components) • Answer 7 screens of configuration data • Drink coffee (takes about 30 minutes to install) • Install compute nodes: • Login to frontend • Execute insert-ethers • Boot compute node with Rocks Base CD (or PXE) • Insert-ethers discovers nodes • Goto step 3 • Add user accounts • Start computing Optional Rolls • Condor • Grid (based on NMI R4) • Intel (compilers) • Java • SCE (developed in Thailand) • Sun Grid Engine • PBS (developed in Norway) • Area51 (security monitoring tools) • Many Others …

  43. Rocks的七种武器 • Rocks的七种武器 • insert-ethers:操作系统快速部署 • cluster-fork:集群并行命令 • mpich/openmpi:并行编程和运行环境 • pvfs:并行文件系统 • ganglia:集群状态监控 • 411:集群帐号同步 • sge/torque:作业调度系统

  44. 主要内容 • 并行计算简介 • Linux与HPC • 搭建Linux Cluster • 小结

  45. 小结 • 集群是高性能计算机的发展方向 • Linux在高性能计算机中大量采用 • 配置Linux Cluster非常方便 • 采用NPACI Rocks可以大大减少工作量

  46. Q&A

More Related