Software Open Access

A C++17 Thread Pool for High-Performance Scientific Computing

Shoshany, Barak


DCAT Export

<?xml version='1.0' encoding='utf-8'?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:adms="http://www.w3.org/ns/adms#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:dctype="http://purl.org/dc/dcmitype/" xmlns:dcat="http://www.w3.org/ns/dcat#" xmlns:duv="http://www.w3.org/ns/duv#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:frapo="http://purl.org/cerif/frapo/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:gsp="http://www.opengis.net/ont/geosparql#" xmlns:locn="http://www.w3.org/ns/locn#" xmlns:org="http://www.w3.org/ns/org#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:prov="http://www.w3.org/ns/prov#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:vcard="http://www.w3.org/2006/vcard/ns#" xmlns:wdrs="http://www.w3.org/2007/05/powder-s#">
  <rdf:Description rdf:about="https://doi.org/10.5281/zenodo.6959270">
    <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Dataset"/>
    <dct:type rdf:resource="http://purl.org/dc/dcmitype/Software"/>
    <dct:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://doi.org/10.5281/zenodo.6959270</dct:identifier>
    <foaf:page rdf:resource="https://doi.org/10.5281/zenodo.6959270"/>
    <dct:creator>
      <rdf:Description rdf:about="http://orcid.org/0000-0003-2222-127X">
        <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Agent"/>
        <dct:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0000-0003-2222-127X</dct:identifier>
        <foaf:name>Shoshany, Barak</foaf:name>
        <foaf:givenName>Barak</foaf:givenName>
        <foaf:familyName>Shoshany</foaf:familyName>
      </rdf:Description>
    </dct:creator>
    <dct:title>A C++17 Thread Pool for High-Performance Scientific Computing</dct:title>
    <dct:publisher>
      <foaf:Agent>
        <foaf:name>Zenodo</foaf:name>
      </foaf:Agent>
    </dct:publisher>
    <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#gYear">2021</dct:issued>
    <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2021-05-03</dct:issued>
    <owl:sameAs rdf:resource="https://zenodo.org/record/6959270"/>
    <adms:identifier>
      <adms:Identifier>
        <skos:notation rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://zenodo.org/record/6959270</skos:notation>
        <adms:schemeAgency>url</adms:schemeAgency>
      </adms:Identifier>
    </adms:identifier>
    <dct:relation rdf:resource="https://github.com/bshoshany/thread-pool/tree/v3.3.0"/>
    <dct:isVersionOf rdf:resource="https://doi.org/10.5281/zenodo.4742687"/>
    <owl:versionInfo>v3.3.0</owl:versionInfo>
    <dct:description>v3.3.0 (2022-08-03) &lt;ul&gt; &lt;li&gt;&lt;code&gt;BS_thread_pool.hpp&lt;/code&gt;:&lt;ul&gt; &lt;li&gt;The public member variable &lt;code&gt;paused&lt;/code&gt; of &lt;code&gt;BS::thread_pool&lt;/code&gt; has been made private for future-proofing (in case future versions implement a more involved pausing mechanism) and better encapsulation. It is now accessible only via the &lt;code&gt;pause()&lt;/code&gt;, &lt;code&gt;unpause()&lt;/code&gt;, and &lt;code&gt;is_paused()&lt;/code&gt; member functions. In other words:&lt;ul&gt; &lt;li&gt;Replace &lt;code&gt;pool.paused = true&lt;/code&gt; with &lt;code&gt;pool.pause()&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Replace &lt;code&gt;pool.paused = false&lt;/code&gt; with &lt;code&gt;pool.unpause()&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Replace &lt;code&gt;if (pool.paused)&lt;/code&gt; (or similar) with &lt;code&gt;if (pool.is_paused())&lt;/code&gt;.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;The public member variable &lt;code&gt;f&lt;/code&gt; of &lt;code&gt;BS::multi_future&lt;/code&gt; has been renamed to &lt;code&gt;futures&lt;/code&gt; for clarity, and has been made private for encapsulation and simplification purposes. Instead of operating on the vector &lt;code&gt;futures&lt;/code&gt; itself, you can now use the &lt;code&gt;[]&lt;/code&gt; operator of the &lt;code&gt;BS::multi_future&lt;/code&gt; to access the future at a specific index directly, or the &lt;code&gt;push_back()&lt;/code&gt; member function to append a new future to the list. The &lt;code&gt;size()&lt;/code&gt; member function tells you how many futures are currently stored in the object.&lt;/li&gt; &lt;li&gt;The explicit casts of &lt;code&gt;std::endl&lt;/code&gt; and &lt;code&gt;std::flush&lt;/code&gt;, added in v3.2.0 to enable flushing a &lt;code&gt;BS::synced_stream&lt;/code&gt;, caused ODR (One Definition Rule) violations if &lt;code&gt;BS_thread_pool.hpp&lt;/code&gt; was included in two different translation units, since they were mistakenly not defined as &lt;code&gt;inline&lt;/code&gt;. To fix this, I decided to make them static members of &lt;code&gt;BS::synced_stream&lt;/code&gt; instead of global variables, which also makes the code better organized in my opinion. These objects can now be accessed as &lt;code&gt;BS::synced_stream::endl&lt;/code&gt; and &lt;code&gt;BS::synced_stream::flush&lt;/code&gt;. I also added an example for how to use them in &lt;code&gt;README.md&lt;/code&gt;. See &lt;a href="https://github.com/bshoshany/thread-pool/issues/64"&gt;#64&lt;/a&gt;.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;code&gt;BS_thread_pool_light.hpp&lt;/code&gt;:&lt;ul&gt; &lt;li&gt;This package started out as a very lightweight thread pool, but over time has expanded to include many additional features, and at the time of writing it has a total of 340 lines of code, including all the helper classes. Therefore, I have decided to bundle a light version of the thread pool in a separate and stand-alone header file, &lt;code&gt;BS_thread_pool_light.hpp&lt;/code&gt;, with only 170 lines of code (half the size of the full package). This file does not contain any of the helper classes, only a new &lt;code&gt;BS::thread_pool_light&lt;/code&gt; class, which is a minimal thread pool with only the 5 most basic member functions:&lt;ul&gt; &lt;li&gt;&lt;code&gt;get_thread_count()&lt;/code&gt;&lt;/li&gt; &lt;li&gt;&lt;code&gt;push_loop()&lt;/code&gt;&lt;/li&gt; &lt;li&gt;&lt;code&gt;push_task()&lt;/code&gt;&lt;/li&gt; &lt;li&gt;&lt;code&gt;submit()&lt;/code&gt;&lt;/li&gt; &lt;li&gt;&lt;code&gt;wait_for_tasks()&lt;/code&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;A separate test program &lt;code&gt;BS_thread_pool_light_test.cpp&lt;/code&gt; tests only the features of the lightweight &lt;code&gt;BS::thread_pool_light&lt;/code&gt; class. In the spirit of minimalism, it does not generate a log file and does not do any benchmarks.&lt;/li&gt; &lt;li&gt;To be perfectly clear, each header file is 100% stand-alone. If you wish to use the full package, you only need &lt;code&gt;BS_thread_pool.hpp&lt;/code&gt;, and if you wish to use the light version, you only need &lt;code&gt;BS_thread_pool_light.hpp&lt;/code&gt;. Only a single header file needs to be included in your project.&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt;</dct:description>
    <dct:description>If you use this package in published research, please cite it as follows.</dct:description>
    <dct:accessRights rdf:resource="http://publications.europa.eu/resource/authority/access-right/PUBLIC"/>
    <dct:accessRights>
      <dct:RightsStatement rdf:about="info:eu-repo/semantics/openAccess">
        <rdfs:label>Open Access</rdfs:label>
      </dct:RightsStatement>
    </dct:accessRights>
    <dcat:distribution>
      <dcat:Distribution>
        <dct:rights>
          <dct:RightsStatement rdf:about="https://opensource.org/licenses/MIT">
            <rdfs:label>MIT License</rdfs:label>
          </dct:RightsStatement>
        </dct:rights>
        <dcat:accessURL rdf:resource="https://doi.org/10.5281/zenodo.6959270"/>
      </dcat:Distribution>
    </dcat:distribution>
    <dcat:distribution>
      <dcat:Distribution>
        <dcat:accessURL rdf:resource="https://doi.org/10.5281/zenodo.6959270"/>
        <dcat:byteSize>60179</dcat:byteSize>
        <dcat:downloadURL rdf:resource="https://zenodo.org/record/6959270/files/bshoshany/thread-pool-v3.3.0.zip"/>
        <dcat:mediaType>application/zip</dcat:mediaType>
      </dcat:Distribution>
    </dcat:distribution>
  </rdf:Description>
</rdf:RDF>
741
23
views
downloads
All versions This version
Views 741165
Downloads 232
Data volume 621.5 kB120.4 kB
Unique views 683157
Unique downloads 132

Share

Cite as