{"id":1071,"date":"2021-04-18T18:30:00","date_gmt":"2021-04-18T18:30:00","guid":{"rendered":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/?p=1071"},"modified":"2021-04-30T12:10:04","modified_gmt":"2021-04-30T12:10:04","slug":"designing-algorithms-for-parallel-computing","status":"publish","type":"post","link":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/designing-algorithms-for-parallel-computing\/","title":{"rendered":"Designing algorithms for parallel computing"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1071\" class=\"elementor elementor-1071\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e589e8d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e589e8d\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4a43660\" data-id=\"4a43660\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f555780 elementor-widget elementor-widget-text-editor\" data-id=\"f555780\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Computers aren\u2019t getting faster anymore. Well, computers are still getting \u201cfaster\u201d but not in the traditional sense. The speed of computers<br>was historically given in terms of the clock speed or frequency of the Central Processing Unit (CPU).&nbsp; After the introduction of the first commercial CPU in 1971 (The intel C4004 that I&#8217;ve attempted to capture the likeliness of above), the frequency of CPUs was increasing linearly in time until the early 2000s when the frequency of CPUs began to plateau. The reason for this is one of power efficiency and heat output. The heat output of CPU transistors increases with frequency and above a certain frequency it will become too much for the CPU to operate at safe temperatures (i.e. not melt).<\/p>\n<p>This issue meant that around 2004, semiconductor manufacturers decided to shift their CPU design philosophy from trying to increase clock speed to increasing the number of CPU cores on each chip. This had the effect of increasing the computational power of CPUs whilst maintaining safe temperatures. Heat is dissipated better from the multiple CPU cores running at moderate frequencies.&nbsp; Another advantage of multiple CPU cores are that they are capable of running separate streams of instructions to each other which is the basis for parallel computing.<\/p>\n<p>The previous focus on clock speed of a single core CPU, plus the fact that it is generally easier, meant that historically the algorithms used in computer programming were based on serial execution in which the instructions in the algorithm are executed by the CPU one after another in a sequence. This is illustrated on the left had side of the figure below where the tasks \u201center\u201d and are processed one by one. The increasing prevalence of parallel computing hardware such as multicore processors and clusters of linked multicore processors has given rise to a new way of approaching algorithm design. If it is possible to design an algorithm such that certain instructions\\tasks can be computed simultaneously, then these tasks can be computed in parallel by several CPU cores (as illustrated on the left of the figure) to achieve a speed-up in the running time of the algorithm.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b32e963 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b32e963\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0a3185e\" data-id=\"0a3185e\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a28b2fe elementor-widget elementor-widget-image\" data-id=\"a28b2fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"420\" src=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/Parallelvsserial-1024x420.png\" class=\"attachment-large size-large wp-image-1120\" alt=\"Parallelvsserial\" srcset=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/Parallelvsserial-1024x420.png 1024w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/Parallelvsserial-300x123.png 300w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/Parallelvsserial-768x315.png 768w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/Parallelvsserial.png 1290w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2b7fed2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2b7fed2\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ace6351\" data-id=\"ace6351\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-56827ea elementor-widget elementor-widget-text-editor\" data-id=\"56827ea\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-size: 16px;font-style: normal;font-weight: 400\">This often runs into a few challenges. For example, many of the serial algorithms that have been developed to perform certain computational\u00a0<span style=\"font-size: 16px;font-style: normal;font-weight: 400\">tasks that are dependent on the outcome of other tasks. This means that <\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">dependent tasks often cannot be executed in parallel. An algorithm that\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">consists of many dependent tasks will be difficult to redesign in a way that\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">will benefit from parallelisation. Another challenge that is encountered is\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">that new errors arise due to parallelisation. For example, the designer of a parallel <\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">algorithm has to be very careful that parallel tasks that work on the same data <\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">do not influence how that data appears in other tasks such that the result <\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">varies depending on which task is completed first.<\/span><\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\">Despite this, it is often worthwhile to try and overcome these challenges because of the resulting increase in speed of the algorithm. It&#8217;s likely to not just an immediate speed-up either as parallel algorithms will continue to increase in speed as more parallel cores become available.<\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\">A simple example of an algorithm that can be sped up using parallelisation is an algorithm designed to sort a list. Consider splitting the list up into \\( N \\) smaller lists, where\u00a0<span style=\"font-size: 16px;font-style: normal;font-weight: 400\">\\( N \\)<\/span>\u00a0is the number of available parallel cores, and then sorting those smaller lists in parallel. These sorted lists can then be joined back together and the joined list can be sorted easily as it is just a list of sorted blocks. Sorting the list in this manner results in a speedup for lists of an appreciable size.<\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\">Another example that is more relevant to statistics and OR is Monte-Carlo sampling (<a href=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/hamish-thorburn\/2020\/04\/19\/60-second-stats-monte-carlo-simulation\/\">Check out STOR-i student Hamish&#8217;s 60 second stats post on Monte-Carlo for a review on how Monte-Carlo sampling works<\/a>)<span style=\"font-size: 16px;font-style: normal;font-weight: 400\">. Consider the simple example of approximating \\( \\pi \\) using Monte-Carlo sampling. We typically do this by sampling randomly within a square that encloses a circle, such as the one shown below, and labelling points based on whether they fall into the circle or not. We can then approximately calculate\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">\\( \\pi \\)\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">by using the ratio of points that fall into the circle and those that don\u2019t. Consider splitting the square into four quarters. It would then be possible to perform Monte-Carlo sampling on each of these quarters on four parallel cores and then using all four ratios obtained to calculate\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">\\( \\pi \\)\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">. In this manner, we can perform more samples in the same amount of time, increasing the accuracy of the approximation.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b781846 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b781846\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e252e7f\" data-id=\"e252e7f\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a5620f6 elementor-widget elementor-widget-image\" data-id=\"a5620f6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"432\" height=\"431\" src=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/MCparallel.png\" class=\"attachment-large size-large wp-image-1118\" alt=\"MCparallel\" srcset=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/MCparallel.png 432w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/MCparallel-300x300.png 300w, https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-content\/uploads\/sites\/24\/2021\/04\/MCparallel-150x150.png 150w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e055bec elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e055bec\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1bceab1\" data-id=\"1bceab1\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0deef1e elementor-widget elementor-widget-text-editor\" data-id=\"0deef1e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">In general, parallelisation has the potential to speed up\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">many of the algorithms that are essential in computational statistics and\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">operational research such as the <a href=\"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/the-particle-filter\/\">particle filter<\/a>\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">or branch and bound methods for solving integer programs. In many of these\u00a0<\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">cases, parallelisation requires the implementation of intelligent mathematical solutions to <\/span><span style=\"font-size: 16px;font-style: normal;font-weight: 400\">try and overcome some of the dependency problems I discussed earlier.<\/span><\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\"><span style=\"font-size: 16px;font-weight: bold\">Relevant Links<\/span><\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\"><a href=\"https:\/\/www.tandfonline.com\/doi\/abs\/10.1198\/jcgs.2010.10039?casa_token=Nofnf76bbtUAAAAA:Wz-DMdofy0DRzTuDFK5MxSaIXBG_1rbaowXlLq54E7HkJXA3vz-XhZbf1ffPh7WPr7ieUpQ3Q7Hd\">Paper on the parallelisation of advanced Monte Carlo methods<\/a><\/p><p style=\"font-size: 16px;font-style: normal;font-weight: 400\"><a href=\"https:\/\/www.sciencedirect.com\/science\/article\/pii\/S0743731517302861\">Paper on parallelisation of branch and bound algorithm<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Computers aren\u2019t getting faster anymore. Well, computers are still getting \u201cfaster\u201d but not in the traditional sense. The speed of computerswas historically given in terms of the clock speed or frequency of the Central Processing Unit (CPU).&nbsp; After the introduction of the first commercial CPU in 1971 (The intel C4004 that I&#8217;ve attempted to capture [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":1080,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"slim_seo":{"title":"Designing algorithms for parallel computing - JACK TRAINER","description":"Computers aren\u2019t getting faster anymore. Well, computers are still getting \u201cfaster\u201d but not in the traditional sense. The speed of computers was historically gi"},"footnotes":""},"categories":[21,14,28],"tags":[19,24,32],"class_list":["post-1071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computational-statistics","category-computer-science","category-operational-research","tag-algorithms","tag-monte-carlo","tag-parallel-computing"],"_links":{"self":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/posts\/1071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/comments?post=1071"}],"version-history":[{"count":17,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/posts\/1071\/revisions"}],"predecessor-version":[{"id":1197,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/posts\/1071\/revisions\/1197"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/media\/1080"}],"wp:attachment":[{"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/media?parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/categories?post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/jack-trainer\/wp-json\/wp\/v2\/tags?post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}