版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Copyright©2010,ElsevierInc.AllrightsReservedChapter1WhyParallelComputing?AnIntroductiontoParallelProgrammingPeterPachecoCopyright©2010,ElsevierIncCopyright©2010,ElsevierInc.AllrightsReservedRoadmapWhyweneedever-increasingperformance.Whywe’rebuildingparallelsystems.Whyweneedtowriteparallelprograms.Howdowewriteparallelprograms?Whatwe’llbedoing.Concurrent,parallel,distributed!#ChapterSubtitleCopyright©2010,ElsevierIncChangingtimesCopyright©2010,ElsevierInc.AllrightsReservedFrom1986–2002,microprocessorswerespeedinglikearocket,increasinginperformanceanaverageof50%peryear.
Sincethen,it’sdroppedtoabout20%increaseperyear.ChangingtimesCopyright©2010AnintelligentsolutionCopyright©2010,ElsevierInc.AllrightsReservedInsteadofdesigningandbuildingfastermicroprocessors,putmultipleprocessorsonasingleintegratedcircuit.
AnintelligentsolutionCopyrigNowit’suptotheprogrammersAddingmoreprocessorsdoesn’thelpmuchifprogrammersaren’tawareofthem……ordon’tknowhowtousethem.
Serialprogramsdon’tbenefitfromthisapproach(inmostcases).Copyright©2010,ElsevierInc.AllrightsReservedNowit’suptotheprogrammersWhyweneedever-increasingperformanceComputationalpowerisincreasing,butsoareourcomputationproblemsandneeds.Problemsweneverdreamedofhavebeensolvedbecauseofpastincreases,suchasdecodingthehumangenome.Morecomplexproblemsarestillwaitingtobesolved.Copyright©2010,ElsevierInc.AllrightsReservedWhyweneedever-increasingpeClimatemodelingCopyright©2010,ElsevierInc.AllrightsReservedClimatemodelingCopyright©20ProteinfoldingCopyright©2010,ElsevierInc.AllrightsReservedProteinfoldingCopyright©201DrugdiscoveryCopyright©2010,ElsevierInc.AllrightsReservedDrugdiscoveryCopyright©2010EnergyresearchCopyright©2010,ElsevierInc.AllrightsReservedEnergyresearchCopyright©201DataanalysisCopyright©2010,ElsevierInc.AllrightsReservedDataanalysisCopyright©2010,Whywe’rebuildingparallelsystemsUptonow,performanceincreaseshavebeenattributabletoincreasingdensityoftransistors.
Butthereare
inherent
problems.Copyright©2010,ElsevierInc.AllrightsReservedWhywe’rebuildingparallelsyAlittlephysicslessonSmallertransistors=fasterprocessors.Fasterprocessors=increasedpowerconsumption.Increasedpowerconsumption=increasedheat.Increasedheat=unreliableprocessors.Copyright©2010,ElsevierInc.AllrightsReservedAlittlephysicslessonSmallerSolutionMoveawayfromsingle-coresystemstomulticoreprocessors.“core”=centralprocessingunit(CPU)
Copyright©2010,ElsevierInc.AllrightsReservedIntroducingparallelism!!!SolutionMoveawayfromsingleWhyweneedtowriteparallelprogramsRunningmultipleinstancesofaserialprogramoftenisn’tveryuseful.Thinkofrunningmultipleinstancesofyourfavoritegame.Whatyoureallywantisfor
ittorunfaster.Copyright©2010,ElsevierInc.AllrightsReservedWhyweneedtowriteparallelApproachestotheserialproblemRewriteserialprogramssothatthey’reparallel.
Writetranslationprogramsthatautomaticallyconvertserialprogramsintoparallelprograms.Thisisverydifficulttodo.Successhasbeenlimited.Copyright©2010,ElsevierInc.AllrightsReservedApproachestotheserialproblMoreproblemsSomecodingconstructscanberecognizedbyanautomaticprogramgenerator,andconvertedtoaparallelconstruct.However,it’slikelythattheresultwillbeaveryinefficientprogram.Sometimesthebestparallelsolutionistostepbackanddeviseanentirelynewalgorithm.Copyright©2010,ElsevierInc.AllrightsReservedMoreproblemsSomecodingconstExampleComputenvaluesandaddthemtogether.Serialsolution:Copyright©2010,ElsevierInc.AllrightsReservedExampleComputenvaluesandadExample(cont.)Wehavepcores,pmuchsmallerthann.Eachcoreperformsapartialsumofapproximatelyn/pvalues.Copyright©2010,ElsevierInc.AllrightsReservedEachcoreusesit’sownprivatevariablesandexecutesthisblockofcode
independentlyoftheothercores.Example(cont.)WehavepcoresExample(cont.)Aftereachcorecompletesexecutionofthecode,isaprivatevariablemy_sumcontainsthesumofthevaluescomputedbyitscallstoCompute_next_value.Ex.,8cores,n=24,thenthecallstoCompute_next_valuereturn:Copyright©2010,ElsevierInc.AllrightsReserved1,4,3,9,2,8,5,1,1,5,2,7,2,5,0,4,1,8,6,5,1,2,3,9Example(cont.)AftereachcoreExample(cont.)Onceallthecoresaredonecomputingtheirprivatemy_sum,theyformaglobalsumbysendingresultstoadesignated“master”corewhichaddsthefinalresult.Copyright©2010,ElsevierInc.AllrightsReservedExample(cont.)OnceallthecoExample(cont.)Copyright©2010,ElsevierInc.AllrightsReservedExample(cont.)Copyright©201Example(cont.)Copyright©2010,ElsevierInc.AllrightsReservedCore01234567my_sum8197157131214Globalsum8+19+7+15+7+13+12+14=95Core01234567my_sum95197157131214Example(cont.)Copyright©201Copyright©2010,ElsevierInc.AllrightsReservedButwait!There’samuchbetterway
tocomputetheglobalsum.Copyright©2010,ElsevierIncBetterparallelalgorithmDon’tmakethemastercoredoallthework.Shareitamongtheothercores.Pairthecoressothatcore0addsitsresultwithcore1’sresult.Core2addsitsresultwithcore3’sresult,etc.Workwithoddandevennumberedpairsofcores.Copyright©2010,ElsevierInc.AllrightsReservedBetterparallelalgorithmDon’tBetterparallelalgorithm(cont.)Repeattheprocessnowwithonlytheevenlyrankedcores.Core0addsresultfromcore2.Core4addstheresultfromcore6,etc.Nowcoresdivisibleby4repeattheprocess,andsoforth,untilcore0hasthefinalresult.Copyright©2010,ElsevierInc.AllrightsReservedBetterparallelalgorithm(conMultiplecoresformingaglobalsumCopyright©2010,ElsevierInc.AllrightsReservedMultiplecoresformingaglobaAnalysisInthefirstexample,themastercoreperforms7receivesand7additions.Inthesecondexample,themastercoreperforms3receivesand3additions.Theimprovementismorethanafactorof2!Copyright©2010,ElsevierInc.AllrightsReservedAnalysisInthefirstexample,Analysis(cont.)Thedifferenceismoredramaticwithalargernumberofcores.Ifwehave1000cores:Thefirstexamplewouldrequirethemastertoperform999receivesand999additions.Thesecondexamplewouldonlyrequire10receivesand10additions.
That’sanimprovementofalmostafactorof100!Copyright©2010,ElsevierInc.AllrightsReservedAnalysis(cont.)ThedifferenceHowdowewriteparallelprograms?TaskparallelismPartitionvarioustaskscarriedoutsolvingtheproblemamongthecores.
DataparallelismPartitionthedatausedinsolvingtheproblemamongthecores.Eachcorecarriesoutsimilaroperationsonit’spartofthedata.Copyright©2010,ElsevierInc.AllrightsReservedHowdowewriteparallelprogrProfessorPCopyright©2010,ElsevierInc.AllrightsReserved15questions300examsProfessorPCopyright©2010,EProfessorP’sgradingassistantsCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3ProfessorP’sgradingassistanDivisionofwork–
dataparallelismCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3100exams100exams100examsDivisionofwork–
dataparalDivisionofwork–
taskparallelismCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3Questions1-5Questions6-10Questions11-15Divisionofwork–
taskparalDivisionofwork–
dataparallelismCopyright©2010,ElsevierInc.AllrightsReservedDivisionofwork–
dataparalDivisionofwork–
taskparallelismCopyright©2010,ElsevierInc.AllrightsReservedTasksReceivingAdditionDivisionofwork–
taskparalCoordinationCoresusuallyneedtocoordinatetheirwork.Communication–oneormorecoressendtheircurrentpartialsumstoanothercore.Loadbalancing–sharetheworkevenlyamongthecoressothatoneisnotheavilyloaded.Synchronization–becauseeachcoreworksatitsownpace,makesurecoresdonotgettoofaraheadoftherest.Copyright©2010,ElsevierInc.AllrightsReservedCoordinationCoresusuallyneedWhatwe’llbedoingLearningtowriteprogramsthatareexplicitlyparallel.UsingtheClanguage.UsingthreedifferentextensionstoC.Message-PassingInterface(MPI)PosixThreads(Pthreads)OpenMPCopyright©2010,ElsevierInc.AllrightsReservedWhatwe’llbedoingLearningtoTypeofparallelsystemsShared-memoryThecorescanshareaccesstothecomputer’smemory.Coordinatethecoresbyhavingthemexamineandupdatesharedmemorylocations.Distributed-memoryEachcorehasitsown,privatememory.Thecoresmustcommunicateexplicitlybysendingmessagesacrossanetwork.Copyright©2010,ElsevierInc.AllrightsReservedTypeofparallelsystemsSharedTypeofparallelsystemsCopyright©2010,ElsevierInc.AllrightsReservedShared-memoryDistributed-memoryTypeofparallelsystemsCopyriTerminologyConcurrentcomputing–aprogramisoneinwhichmultipletaskscanbeinprogressatanyinstant.Parallelcomputing–aprogramisoneinwhichmultipletaskscooperatecloselytosolveaproblemDistributedcomputing–aprogrammayneedtocooperatewithotherprogramstosolveaproblem.Copyright©2010,ElsevierInc.AllrightsReservedTerminologyConcurrentcomputiConcludingRemarks(1)Thelawsofphysicshavebroughtustothedoorstepofmulticoretechnology.Serialprogramstypicallydon’tbenefitfrommultiplecores.Automaticparallelprogramgenerationfromserialprogramcodeisn’tthemostefficientapproachtogethighperformancefrommulticorecomputers.Copyright©2010,ElsevierInc.AllrightsReservedConcludingRemarks(1)ThelawsConcludingRemarks(2)Learningtowriteparallelprogramsinvolveslearninghowtocoordinatethecores.Parallelprogramsareusuallyverycomplexandtherefore,requiresoundprogramtechniquesanddevelopment.Copyright©2010,ElsevierInc.AllrightsReservedConcludingRemarks(2)LearningCopyright©2010,ElsevierInc.AllrightsReservedChapter1WhyParallelComputing?AnIntroductiontoParallelProgrammingPeterPachecoCopyright©2010,ElsevierIncCopyright©2010,ElsevierInc.AllrightsReservedRoadmapWhyweneedever-increasingperformance.Whywe’rebuildingparallelsystems.Whyweneedtowriteparallelprograms.Howdowewriteparallelprograms?Whatwe’llbedoing.Concurrent,parallel,distributed!#ChapterSubtitleCopyright©2010,ElsevierIncChangingtimesCopyright©2010,ElsevierInc.AllrightsReservedFrom1986–2002,microprocessorswerespeedinglikearocket,increasinginperformanceanaverageof50%peryear.
Sincethen,it’sdroppedtoabout20%increaseperyear.ChangingtimesCopyright©2010AnintelligentsolutionCopyright©2010,ElsevierInc.AllrightsReservedInsteadofdesigningandbuildingfastermicroprocessors,putmultipleprocessorsonasingleintegratedcircuit.
AnintelligentsolutionCopyrigNowit’suptotheprogrammersAddingmoreprocessorsdoesn’thelpmuchifprogrammersaren’tawareofthem……ordon’tknowhowtousethem.
Serialprogramsdon’tbenefitfromthisapproach(inmostcases).Copyright©2010,ElsevierInc.AllrightsReservedNowit’suptotheprogrammersWhyweneedever-increasingperformanceComputationalpowerisincreasing,butsoareourcomputationproblemsandneeds.Problemsweneverdreamedofhavebeensolvedbecauseofpastincreases,suchasdecodingthehumangenome.Morecomplexproblemsarestillwaitingtobesolved.Copyright©2010,ElsevierInc.AllrightsReservedWhyweneedever-increasingpeClimatemodelingCopyright©2010,ElsevierInc.AllrightsReservedClimatemodelingCopyright©20ProteinfoldingCopyright©2010,ElsevierInc.AllrightsReservedProteinfoldingCopyright©201DrugdiscoveryCopyright©2010,ElsevierInc.AllrightsReservedDrugdiscoveryCopyright©2010EnergyresearchCopyright©2010,ElsevierInc.AllrightsReservedEnergyresearchCopyright©201DataanalysisCopyright©2010,ElsevierInc.AllrightsReservedDataanalysisCopyright©2010,Whywe’rebuildingparallelsystemsUptonow,performanceincreaseshavebeenattributabletoincreasingdensityoftransistors.
Butthereare
inherent
problems.Copyright©2010,ElsevierInc.AllrightsReservedWhywe’rebuildingparallelsyAlittlephysicslessonSmallertransistors=fasterprocessors.Fasterprocessors=increasedpowerconsumption.Increasedpowerconsumption=increasedheat.Increasedheat=unreliableprocessors.Copyright©2010,ElsevierInc.AllrightsReservedAlittlephysicslessonSmallerSolutionMoveawayfromsingle-coresystemstomulticoreprocessors.“core”=centralprocessingunit(CPU)
Copyright©2010,ElsevierInc.AllrightsReservedIntroducingparallelism!!!SolutionMoveawayfromsingleWhyweneedtowriteparallelprogramsRunningmultipleinstancesofaserialprogramoftenisn’tveryuseful.Thinkofrunningmultipleinstancesofyourfavoritegame.Whatyoureallywantisfor
ittorunfaster.Copyright©2010,ElsevierInc.AllrightsReservedWhyweneedtowriteparallelApproachestotheserialproblemRewriteserialprogramssothatthey’reparallel.
Writetranslationprogramsthatautomaticallyconvertserialprogramsintoparallelprograms.Thisisverydifficulttodo.Successhasbeenlimited.Copyright©2010,ElsevierInc.AllrightsReservedApproachestotheserialproblMoreproblemsSomecodingconstructscanberecognizedbyanautomaticprogramgenerator,andconvertedtoaparallelconstruct.However,it’slikelythattheresultwillbeaveryinefficientprogram.Sometimesthebestparallelsolutionistostepbackanddeviseanentirelynewalgorithm.Copyright©2010,ElsevierInc.AllrightsReservedMoreproblemsSomecodingconstExampleComputenvaluesandaddthemtogether.Serialsolution:Copyright©2010,ElsevierInc.AllrightsReservedExampleComputenvaluesandadExample(cont.)Wehavepcores,pmuchsmallerthann.Eachcoreperformsapartialsumofapproximatelyn/pvalues.Copyright©2010,ElsevierInc.AllrightsReservedEachcoreusesit’sownprivatevariablesandexecutesthisblockofcode
independentlyoftheothercores.Example(cont.)WehavepcoresExample(cont.)Aftereachcorecompletesexecutionofthecode,isaprivatevariablemy_sumcontainsthesumofthevaluescomputedbyitscallstoCompute_next_value.Ex.,8cores,n=24,thenthecallstoCompute_next_valuereturn:Copyright©2010,ElsevierInc.AllrightsReserved1,4,3,9,2,8,5,1,1,5,2,7,2,5,0,4,1,8,6,5,1,2,3,9Example(cont.)AftereachcoreExample(cont.)Onceallthecoresaredonecomputingtheirprivatemy_sum,theyformaglobalsumbysendingresultstoadesignated“master”corewhichaddsthefinalresult.Copyright©2010,ElsevierInc.AllrightsReservedExample(cont.)OnceallthecoExample(cont.)Copyright©2010,ElsevierInc.AllrightsReservedExample(cont.)Copyright©201Example(cont.)Copyright©2010,ElsevierInc.AllrightsReservedCore01234567my_sum8197157131214Globalsum8+19+7+15+7+13+12+14=95Core01234567my_sum95197157131214Example(cont.)Copyright©201Copyright©2010,ElsevierInc.AllrightsReservedButwait!There’samuchbetterway
tocomputetheglobalsum.Copyright©2010,ElsevierIncBetterparallelalgorithmDon’tmakethemastercoredoallthework.Shareitamongtheothercores.Pairthecoressothatcore0addsitsresultwithcore1’sresult.Core2addsitsresultwithcore3’sresult,etc.Workwithoddandevennumberedpairsofcores.Copyright©2010,ElsevierInc.AllrightsReservedBetterparallelalgorithmDon’tBetterparallelalgorithm(cont.)Repeattheprocessnowwithonlytheevenlyrankedcores.Core0addsresultfromcore2.Core4addstheresultfromcore6,etc.Nowcoresdivisibleby4repeattheprocess,andsoforth,untilcore0hasthefinalresult.Copyright©2010,ElsevierInc.AllrightsReservedBetterparallelalgorithm(conMultiplecoresformingaglobalsumCopyright©2010,ElsevierInc.AllrightsReservedMultiplecoresformingaglobaAnalysisInthefirstexample,themastercoreperforms7receivesand7additions.Inthesecondexample,themastercoreperforms3receivesand3additions.Theimprovementismorethanafactorof2!Copyright©2010,ElsevierInc.AllrightsReservedAnalysisInthefirstexample,Analysis(cont.)Thedifferenceismoredramaticwithalargernumberofcores.Ifwehave1000cores:Thefirstexamplewouldrequirethemastertoperform999receivesand999additions.Thesecondexamplewouldonlyrequire10receivesand10additions.
That’sanimprovementofalmostafactorof100!Copyright©2010,ElsevierInc.AllrightsReservedAnalysis(cont.)ThedifferenceHowdowewriteparallelprograms?TaskparallelismPartitionvarioustaskscarriedoutsolvingtheproblemamongthecores.
DataparallelismPartitionthedatausedinsolvingtheproblemamongthecores.Eachcorecarriesoutsimilaroperationsonit’spartofthedata.Copyright©2010,ElsevierInc.AllrightsReservedHowdowewriteparallelprogrProfessorPCopyright©2010,ElsevierInc.AllrightsReserved15questions300examsProfessorPCopyright©2010,EProfessorP’sgradingassistantsCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3ProfessorP’sgradingassistanDivisionofwork–
dataparallelismCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3100exams100exams100examsDivisionofwork–
dataparalDivisionofwork–
taskparallelismCopyright©2010,ElsevierInc.AllrightsReservedTA#1TA#2TA#3Questions1-5Questions6-10Questions11-15Divisionofwork–
taskparalDivisionofwork–
dataparallelismCopyright©2010,ElsevierInc.AllrightsReservedDivisionofwork–
dataparalDivisionofwork–
taskparallelismCopyright©2010,ElsevierInc.AllrightsReservedTasksReceivingAdditionDivisionofwork–
taskparalCoordinationCoresusuallyneedtocoordinatetheirwork.Communication–oneormorecoressendtheircurrentpartialsumstoanothercore.Loadbalancing–sharetheworkevenlyamongthecoressothatoneisnotheavily
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 涂装预处理工班组评比评优考核试卷含答案
- 汽车吊司机操作安全知识考核试卷含答案
- 精制制盐工复试水平考核试卷含答案
- 玻璃制品机械成型工岗后能力考核试卷含答案
- 金属玻璃家具制作工岗后竞赛考核试卷含答案
- 科技魅力:探索科技世界激发创新思维小学主题班会课件
- 儿科护理核心技能培训
- 骨盆区纤维瘤病护理查房
- 数据中心机房规划及实施指南
- 筑牢安全防线守护生命至上,小学主题班会课件
- GB/T 4982-2025真空技术夹紧型快卸连接器尺寸
- 齐商银行笔试题库及答案
- 雨课堂学堂在线学堂云《国学通论(吉大 )》单元测试考核答案
- 科研助理聘用协议书
- 2025年国家义务教育质量监测小学四年级劳动教育模拟测试题及答案
- 2025年生物会考成都真题及答案
- 2024集中式光伏电站场区典型设计手册
- 新媒体伦理与法规-形成性考核一(第1-3章权重15%)-国开-参考资料
- GB/T 46075.3-2025电子束焊机验收检验第3部分:电子束电流特性的测量
- 生物医药创新药物研发成本效益可行性研究报告
- 24节气固元灸课件
评论
0/150
提交评论