{"id":2406,"date":"2021-05-09T19:02:53","date_gmt":"2021-05-09T13:32:53","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=2406"},"modified":"2021-05-09T19:02:53","modified_gmt":"2021-05-09T13:32:53","slug":"eager-future2-common-lisp-library","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2021\/05\/09\/eager-future2-common-lisp-library\/","title":{"rendered":"Eager Future2 Common Lisp Library"},"content":{"rendered":"<p><a href=\"https:\/\/common-lisp.net\/project\/eager-future\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Eager Future2<\/strong><\/em><\/a> is a Common Lisp library that facilitates parallel computation. It is based on the idea of a <em><strong>\u201cfuture\u201d<\/strong><\/em> that acts as a <em><strong>\u201cproxy\u201d<\/strong><\/em> for a concurrently computed expression. Unlike the <em><strong>\u201clparallel\u201d<\/strong><\/em> library that I had discussed in the <a href=\"https:\/\/www.rangakrish.com\/index.php\/2021\/04\/26\/lparallel-a-parallel-programming-library\/\" target=\"_blank\" rel=\"noopener\"><em><strong>last article<\/strong><\/em><\/a>, this library does not give us control over the number of <em><strong>\u201cworker threads\u201d<\/strong><\/em> to be used in the computation. Even in terms of features, this library is much simpler compared to <em><strong>\u201clparallel\u201d<\/strong><\/em>.<\/p>\n<p>Nevertheless, I wanted to take a quick look at its core functionality, and decided to use the same <em><strong>\u201cFibonacci\u201d<\/strong><\/em> example that I had used in the context of <em><strong>\u201clparallel\u201d<\/strong><\/em>. As before, I used <em><strong>Lispworks Enterprise Edition (64-bit)<\/strong><\/em> on Windows 10.<\/p>\n<p>Here are 3 implementations of <em><strong>Fib<\/strong><\/em> computation:<\/p>\n<figure id=\"attachment_2407\" aria-describedby=\"caption-attachment-2407\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"2407\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/05\/09\/eager-future2-common-lisp-library\/code-15\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg\" data-orig-size=\"520,671\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1620568467&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Fibonacci Calculation &amp;#8211; 3 Ways\" data-image-description=\"&lt;p&gt;Fibonacci Calculation &amp;#8211; 3 Ways&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Fibonacci Calculation &amp;#8211; 3 Ways&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg\" class=\"wp-image-2407\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg?resize=450%2C581&#038;ssl=1\" alt=\"Fibonacci Calculation - 3 Ways\" width=\"450\" height=\"581\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg?resize=232%2C300&amp;ssl=1 232w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code.jpg?w=520&amp;ssl=1 520w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-2407\" class=\"wp-caption-text\"><strong>Fibonacci Calculation &#8211; 3 Ways<\/strong><\/figcaption><\/figure>\n<p><em><strong>\u201cfib\u201d<\/strong><\/em> is the classic single-threaded implementation. <em><strong>\u201cfib-par\u201d<\/strong><\/em> uses Eager Future2\u2019s <em><strong>\u201cpexec\u201d<\/strong><\/em> function (a minor variant of <em><strong>\u201cpcall\u201d<\/strong><\/em>) to create <em><strong>\u201cfutures\u201d \u201ca\u201d<\/strong><\/em> and <em><strong>\u201cb\u201d<\/strong><\/em>, and then uses <em><strong>\u201cyield\u201d<\/strong><\/em> function to retrieve the respective values. <em><strong>\u201cfib-par2\u201d<\/strong><\/em> uses the <em><strong>\u201cplet\u201d<\/strong><\/em> construct (similar to the one available in <em><strong>\u201clparallel\u201d<\/strong><\/em>) to compute the previous two <em><strong>Fib<\/strong><\/em> values in parallel.<\/p>\n<p>Let us now execute these functions to see the time each one takes.<\/p>\n<figure id=\"attachment_2408\" aria-describedby=\"caption-attachment-2408\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2408\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/05\/09\/eager-future2-common-lisp-library\/measurement\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg\" data-orig-size=\"769,828\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1620568338&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Performance Comparison\" data-image-description=\"&lt;p&gt;Performance Comparison&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Performance Comparison&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg\" class=\"wp-image-2408\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg?resize=500%2C538&#038;ssl=1\" alt=\"Performance Comparison\" width=\"500\" height=\"538\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg?resize=279%2C300&amp;ssl=1 279w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Measurement.jpg?w=769&amp;ssl=1 769w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2408\" class=\"wp-caption-text\"><strong>Performance Comparison<\/strong><\/figcaption><\/figure>\n<p>Looking at the <em><strong>\u201cElapsed time\u201d<\/strong><\/em>, we notice that <em><strong>\u201cfib-par\u201d<\/strong><\/em> and <em><strong>\u201cfib-par2\u201d<\/strong><\/em> take less time to compute compared to <em><strong>\u201cfib\u201d<\/strong><\/em>.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Here is the CPU utilisation as shown by <em><strong>Windows Task Manager<\/strong><\/em>.<\/p>\n<figure id=\"attachment_2410\" aria-describedby=\"caption-attachment-2410\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2410\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/05\/09\/eager-future2-common-lisp-library\/cpu-utlization\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg\" data-orig-size=\"654,683\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1620568231&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"CPU Utlization\" data-image-description=\"&lt;p&gt;CPU Utlization&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;CPU Utlization&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg\" class=\"wp-image-2410\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg?resize=400%2C418&#038;ssl=1\" alt=\"CPU Utlization\" width=\"400\" height=\"418\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg?resize=287%2C300&amp;ssl=1 287w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/CPU-Utlization.jpg?w=654&amp;ssl=1 654w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-2410\" class=\"wp-caption-text\"><strong>CPU Utilization<\/strong><span style=\"font-size: 16px;\">\u00a0<\/span><\/figcaption><\/figure>\n<p>The three regions, from left to right, correspond to <em><strong>\u201cfib\u201d<\/strong><\/em>, <em><strong>\u201cfib-par\u201d<\/strong><\/em> and <em><strong>\u201cfib-par2\u201d<\/strong><\/em> respectively.<\/p>\n<p>You can download the Lisp code from <a href=\"http:\/\/www.rangakrish.com\/downloads\/Eager-future2-example.lisp\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eager Future2 is a Common Lisp library that facilitates parallel computation. It is based on the idea of a \u201cfuture\u201d that acts as a \u201cproxy\u201d for a concurrently computed expression. Unlike the \u201clparallel\u201d library that I had discussed in the last article, this library does not give us control over the number of \u201cworker threads\u201d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,17],"tags":[110,281],"class_list":["post-2406","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming","tag-common-lisp","tag-eager-future2"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-CO","jetpack-related-posts":[{"id":2377,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/04\/12\/book-review-programming-algorithms-in-lisp\/","url_meta":{"origin":2406,"position":0},"title":"Book Review: Programming Algorithms in Lisp","author":"admin","date":"April 12, 2021","format":false,"excerpt":"Title: Programming Algorithms in Lisp: Writing Efficient Programs with Examples in ANSI Common Lisp Author: Vsevolod Domkin Publisher: Apress Year: 2021 It is only about 5 months since I read and reviewed\u00a0a good book on Lisp written by Micha\u0142 \u201cphoe\u201d Herda. The present book is by Vsevolod Domkin\u00a0and I purchased\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/04\/Book-Cover-209x300.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2383,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/04\/26\/lparallel-a-parallel-programming-library\/","url_meta":{"origin":2406,"position":1},"title":"lparallel: A Parallel Programming Library","author":"admin","date":"April 26, 2021","format":false,"excerpt":"You may recall that in the last article I had reviewed the book \"Algorithms in Lisp\"\u00a0by Vsevolod Domkin. There was a reference to the lparallel\u00a0library in Chapter 15 of the book. That immediately reminded me of the nice discussion of lparallel by Edi Weitz in Chapter 11 of his excellent\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"pmap: Parallel Map","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/04\/pmap-300x208.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/04\/pmap-300x208.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/04\/pmap-300x208.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":495,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/04\/08\/accessing-azure-blobs-in-lisp\/","url_meta":{"origin":2406,"position":2},"title":"Accessing Azure BLOBs in Lisp","author":"admin","date":"April 8, 2017","format":false,"excerpt":"Recently I was looking for a Common Lisp library for accessing Azure services. Azure has official SDKs in many languages, but Lisp is not one of them. Quite understandable and I have no complaints. Because the services are all exposed via REST interfaces, it should not be difficult to implement\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Fig.1","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=525%2C300 1.5x"},"classes":[]},{"id":190,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/03\/15\/book-review-common-lisp-recipes-by-edi-weitz\/","url_meta":{"origin":2406,"position":3},"title":"Book Review: Common Lisp Recipes &#8211; A Problem-Solution Approach","author":"admin","date":"March 15, 2016","format":false,"excerpt":"Last Saturday (March 12, 2016), I got my most eagerly awaited book from Amazon.com. Yes, I am talking about Common Lisp Recipes: A Problem-Solution Approach\u00a0authored by Dr.Edmund Weitz. Of course, if you have been programming in Lisp for a couple of years, you would have definitely heard of Dr.Edi Weitz,\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2242,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/12\/20\/jfugue-a-java-library-for-music-synthesis\/","url_meta":{"origin":2406,"position":4},"title":"JFugue: A Java Library for Music Synthesis","author":"admin","date":"December 20, 2020","format":false,"excerpt":"JFugue\u00a0is an open-source Java library that can be used for algorithmic music composition. Developed by David Koelle, currently it is in its fifth major version. You can get the library from here. I had downloaded the library some time ago, but could not spend much time since my primary focus\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Simple Java Program","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3312,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/01\/28\/the-hy-programming-language\/","url_meta":{"origin":2406,"position":5},"title":"The Hy Programming Language","author":"admin","date":"January 28, 2024","format":false,"excerpt":"In an earlier article\u00a0I had explained how to execute Python code from within Common Lisp using \u201cCLPython\u201d package. In contrast to that approach, \u201cHy\u201d\u00a0is a Lisp-style language (not compatible with Common Lisp) that is embedded in Python and hence provides seamless interoperability with Python code. Installation is straightforward (it is\u2026","rel":"","context":"In &quot;Hy Language&quot;","block_context":{"text":"Hy Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/hy-language\/"},"img":{"alt_text":"Hy REPL","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/01\/console-300x148.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=2406"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=2406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=2406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=2406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}