{"id":1214,"date":"2009-05-12T19:20:05","date_gmt":"2009-05-12T18:20:05","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=1214"},"modified":"2009-05-12T19:21:28","modified_gmt":"2009-05-12T18:21:28","slug":"parallelisation-is-matlab-doing-it-wrong","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=1214","title":{"rendered":"Parallelisation:  Is MATLAB doing it wrong?"},"content":{"rendered":"<p>In the old days of computing, life was relatively simple as far as processor speed was concerned.\u00a0 If your current computer ran at 1Ghz and you were about to buy one that ran at 2Ghz then, as a rough rule of thumb, you expected it to be about twice as fast.\u00a0 Of course there was more to it than that (there always is) and other things such as amount of memory, hard disk speed etc etc also had an impact on how fast you got the results of your calculations.\u00a0 It also didn&#8217;t help that not all Ghz were created equally &#8211; two chips that ran at the same clock speed but with different architectures could exhibit radically different calculation performance.<\/p>\n<p>I did say life was &#8216;relatively simple&#8217; not just &#8216;simple&#8217;.<\/p>\n<p>These days we still have all of the above to worry about, but we also have the added complication that a typical modern computer contains not one, but two processors.\u00a0 It&#8217;s almost like having two machines for the price of one and higher end desktops can contain as many as 8.\u00a0 Which is a lot!<\/p>\n<p>Back in the old, single processor, days we could take our slow code from an old machine, put it on a new machine and it would go faster.\u00a0\u00a0 That was it &#8211; no worries, no hassle.\u00a0 If only life were so simple today&#8230;.<\/p>\n<p>These days we need to actually rewrite our code so that it makes better use of all the idle processors lying around in our new fangled machines or, to put it more technically, we need to parallelize our code.\u00a0 Sometimes this is simple, often it&#8217;s not but one thing is for sure and that is that the environment we are programming in has to provide a set of parallel programming commands to help us do this extra work.<\/p>\n<p>Old style languages such as C and FORTRAN have had this sort of stuff for years in the form of libraries such as <a href=\"http:\/\/www.open-mpi.org\/\">Open MPI<\/a> and <a href=\"http:\/\/openmp.org\/wp\/\">Open MP<\/a> but mathematical programming languages such as Mathematica and Maple have only recently gotten in on the act.<\/p>\n<p><a href=\"http:\/\/www.wolfram.com\/products\/mathematica\/newin7\/content\/BuiltInParallelComputing\/\">Version 7<\/a> of Mathematica and <a href=\"http:\/\/www.adeptscience.co.uk\/products\/mathsim\/maple13\/newfeatures\/pro\/mulit_thread.html\">Version 13 of Maple*<\/a> both included a set of tools for enabling parallel programming as part of their basic installs.\u00a0 In other words &#8211; you don&#8217;t need to pay any extra money to get these programs to use your multi-processor computers to their full potential.<\/p>\n<p>MATLAB, on the other hand, expects you to pay extra to be able to parallelize\u00a0 your code by requiring you to purchase the <a href=\"http:\/\/www.mathworks.co.uk\/products\/parallel-computing\/\">Parallel Computing Toolbox<\/a>.\u00a0 It&#8217;s not cheap either!\u00a0 Of course, Mathworks are free to charge whatever they like for their products but I don&#8217;t think that this particular policy is doing them any favours.<\/p>\n<p>It&#8217;s not all bad &#8211; certain functions in basic MATLAB make full use of your multi core processors.\u00a0 As of version 2009a, for example, their Fast Fourier Transform function (<a href=\"http:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/ref\/fft.html\">fft<\/a>) will perform much faster on multi-processor machines but if you want to parallelize your own code then you still have to buy the Parallel toolbox.\u00a0 Your alternatives include messing around with batch processing (if your problem can be solved this way) or use another package such as Mathematica or Maple which has full parallel support out of the box.<\/p>\n<p>At my University we have several hundred network licenses for MATLAB itself and only 2 or 3 licenses for the Parallel toolbox.\u00a0 That doesn&#8217;t mean that people aren&#8217;t interested in parallel MATLAB, quite the opposite, they simply do not want to have to pay extra to parallelize code on desktops and will go to great lengths (all legal I hasten to add) to avoid the extra cost.<\/p>\n<p>Unfortunately for Mathworks one of the easiest options for someone starting on a new project is simply to use one of their competitors and this is starting to happen.\u00a0 Manchester has a site license for Mathematica and I saw a big spike in interest after version 7 thanks to the parallel programming features it contains.<\/p>\n<p>In summary I think that The Mathworks would do themselves a great favour by including the parallel toolbox as part of their basic package.<\/p>\n<p>Any thoughts?<\/p>\n<p>*Maple actually had parallel support before version 13 but it has been vastly improved in this latest version<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the old days of computing, life was relatively simple as far as processor speed was concerned.\u00a0 If your current computer ran at 1Ghz and you were about to buy one that ran at 2Ghz then, as a rough rule of thumb, you expected it to be about twice as fast.\u00a0 Of course there was [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,11],"tags":[],"class_list":["post-1214","post","type-post","status-publish","format-standard","hentry","category-math-software","category-matlab"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-jA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1214"}],"version-history":[{"count":6,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1214\/revisions"}],"predecessor-version":[{"id":1220,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1214\/revisions\/1220"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}