{"id":13730195,"url":"https://github.com/yuki-koyama/parallel-util","last_synced_at":"2025-03-23T14:31:12.578Z","repository":{"id":92881193,"uuid":"137631141","full_name":"yuki-koyama/parallel-util","owner":"yuki-koyama","description":"Simple header-only implementation of \"parallel_for\" and \"parallel_map\" for C++11","archived":false,"fork":false,"pushed_at":"2020-07-31T03:18:01.000Z","size":32,"stargazers_count":31,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T21:08:48.670Z","etag":null,"topics":["multi-thread","parallel-for","parallel-map"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuki-koyama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-06-17T05:24:48.000Z","updated_at":"2025-01-06T07:55:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"58fc4019-7f9e-4804-adc4-e10b74905bd0","html_url":"https://github.com/yuki-koyama/parallel-util","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki-koyama%2Fparallel-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki-koyama%2Fparallel-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki-koyama%2Fparallel-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuki-koyama%2Fparallel-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuki-koyama","download_url":"https://codeload.github.com/yuki-koyama/parallel-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245115754,"owners_count":20563228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multi-thread","parallel-for","parallel-map"],"created_at":"2024-08-03T02:01:11.228Z","updated_at":"2025-03-23T14:31:12.204Z","avatar_url":"https://github.com/yuki-koyama.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# parallel-util\n\n![Test](https://github.com/yuki-koyama/parallel-util/workflows/Test/badge.svg)\n\nA single-header implementation of `parallel_for`, `parallel_map`, and `parallel_exec` using C++11.\n\nThis library is based on multi-threading on CPU (`std::thread`) and the default concurrency is set to the hardware concurrency (`std::thread::hardware_concurrency()`).\n\n## Usage of `parallel_for`\n\nSuppose that you have a callable function that can be stored by an instance of `std::function\u003cvoid(int)\u003e`, for example, defined by C++11 lambda expression:\n```\nauto process = [](int i) { ... };\n```\nand want to parallelize the following for-loop procedure:\n```\nfor (int i = 0; i \u003c n; ++ i) { process(i); }\n```\nBy using parallel-util, this can be easily parallelized by\n```\nparallelutil::parallel_for(n, process);\n```\n\n## Usage of `parallel_map`\n\nSuppose that you have a callable function that takes an instance of `T1` as input and returns an instance of `T2` as output, and thus can be stored by an instance of `std::function\u003cT2(T1)\u003e`. For example,\n```\nauto square = [](double x) { return x * x; };\n```\nIn this case, `T1` = `T2` = `double`. Also suppose that you have an array of `T1` and want to obtain an array of `T2` by applying the function to each array element. For example, you have an array:\n```\nstd::vector\u003cdouble\u003e input_array = { 0.2, 0.9, - 0.4, 0.5, 0.3 };\n```\nand want to their squares. By using parallel-util, this can be easily parallelized by\n```\nauto output_array = parallelutil::parallel_map(input_array, square);\n```\nwhere `output_array` is an array: `{ 0.04, 0.81, 0.16, 0.25, 0.09 }`.\n\nIf you are using C++17 Parallel STL, `std::transform` has similar functionality.\n\n## Usage of `parallel_exec`\n\nAn arbitrary number of functions whose type is `std::function\u003cvoid()\u003e`, for example,\n```\nauto process_1 = [](){ ... };\nauto process_2 = [](){ ... };\nauto process_3 = [](){ ... };\n```\ncan be executed in parallel by\n```\nparallelutil::parallel_exec({ process_1, process_2, process_3 });\n```\n\n## Installation\n\n`parallel-util` is a header-only, single-file library. It can be used by just copying `parallel-util.hpp` and pasting it into your project.\n\nAlternatively, it can be installed using `cmake`. If your project is also managed using `cmake`, `ExternalProject` or `add_subdirectory` commands are useful for including `parallel-util` to your project.\n\nIf you want to install `parallel-util` to your system, use the typical `cmake` cycle:\n```\ngit clone https://github.com/yuki-koyama/parallel-util.git\nmkdir build\ncd build\ncmake ../parallel-util\nmake install\n```\n\n## Dependencies\n\n- C++ Standard Library; Thread support library (require `-pthread`)\n\n## Persuing Further Performance\n\nPlease consider to use more sophisticated libraries such as Intel(R) Threading Building Blocks.\n\n## Projects using parallel-util\n\n- Unblending \u003chttps://github.com/yuki-koyama/unblending\u003e\n- OptiMo \u003chttps://github.com/yuki-koyama/optimo\u003e\n- Sequential Line Search \u003chttps://github.com/yuki-koyama/sequential-line-search\u003e\n- SelPh \u003chttps://github.com/yuki-koyama/selph\u003e\n\n## LICENSING\n\nMIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuki-koyama%2Fparallel-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuki-koyama%2Fparallel-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuki-koyama%2Fparallel-util/lists"}