{"id":18016594,"url":"https://github.com/webassembly/wasi-parallel","last_synced_at":"2026-03-11T01:31:38.880Z","repository":{"id":92463550,"uuid":"404836547","full_name":"WebAssembly/wasi-parallel","owner":"WebAssembly","description":" wasi-parallel is a proposal to add a parallel for construct to WASI. ","archived":false,"fork":false,"pushed_at":"2022-09-23T14:11:10.000Z","size":2592,"stargazers_count":23,"open_issues_count":6,"forks_count":4,"subscribers_count":22,"default_branch":"main","last_synced_at":"2025-04-08T01:34:23.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebAssembly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-09-09T18:53:28.000Z","updated_at":"2025-03-22T20:46:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"f72d7021-ffdd-4e6f-84ba-41cea34cb558","html_url":"https://github.com/WebAssembly/wasi-parallel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WebAssembly/wasi-parallel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-parallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-parallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-parallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-parallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebAssembly","download_url":"https://codeload.github.com/WebAssembly/wasi-parallel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebAssembly%2Fwasi-parallel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262748938,"owners_count":23358304,"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":[],"created_at":"2024-10-30T04:18:34.397Z","updated_at":"2026-03-11T01:31:38.850Z","avatar_url":"https://github.com/WebAssembly.png","language":"Shell","readme":"# `wasi-parallel`\n\nA proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI)\nAPI for parallel computation.\n\n### Current Phase\n\n`wasi-parallel` is currently in [Phase 1].\n\n[Phase 1]: https://github.com/WebAssembly/WASI/blob/main/Proposals.md#phase-1---feature-proposal-cg\n\n### Champions\n\n- [Andrew Brown](https://github.com/abrown)\n- [Mingqiu Sun](https://github.com/mingqiusun)\n\n### Phase 4 Advancement Criteria\n\n`wasi-parallel` must have at least two complete independent implementations.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Goals ](#goal)\n- [Non-goals](#non-goals)\n- [API walk-through](#api-walk-through)\n- [Detailed design discussion](#detailed-design-discussion)\n- [Considered alternatives](#considered-alternatives)\n- [Stakeholder Interest \u0026 Feedback](#stakeholder-interest--feedback)\n- [References \u0026 acknowledgements](#references--acknowledgements)\n\n\n\n### Introduction\n\n`wasi-parallel` addresses the need for parallel execution. By treating\nparallelism as a system capability, this API allows parallel workloads to be\noffloaded to a variety of devices, from CPUs to GPUs to FPGAs. The current\nspecification is a subset of the features provided by other parallel programming\nframeworks (e.g., OpenMP, OpenCL).\n\nWebAssembly lacks support for parallel execution in general and this can be a\nsignificant performance lag in several domains (ML, HPC). SIMD (128-bit or\n[larger]) does not fully address the issue: many programs benefit from parallel\nexecution and standalone WebAssembly engines have no standard way to access this system\ncapability (unlike browser Web Workers).\n\n[larger]: https://github.com/WebAssembly/flexible-vectors\n\n`wasi-parallel` was introduced in 2021 (see the [slides and meeting notes]),\nprior to the `wasi-threads` proposal. If you are solely interested in spawning\nCPU threads, `wasi-threads` is the right API (see the [considered\nalternatives](#considered-alternatives) sections for more details).\n\n[slides and meeting notes]: https://github.com/WebAssembly/meetings/blob/main/wasi/2021/WASI-08-12.md\n\n\n\n### Goals\n\n- __improve performance__: this API should make it possible to improve the\n  performance of certain parallel applications, especially those designed around\n  a \"parallel for\" construct.\n- __any kind of parallel device__: this proposal aims for parallel execution on\n  heterogeneous devices (e.g., CPU, GPU, FPGA?).\n\n\n\n### Non-goals\n\n- __modify core WebAssembly__: the current proposal does not propose changes to\n  the WebAssembly instruction set.\n- __replicate a parallel programming model__: many parallel programming\n  frameworks already exist (e.g., OpenMP, OpenCL, `pthreads`); this API does not\n  intend to match all features of any existing framework. Here, we explore the\n  possibility of compiling programs written under those frameworks but do not\n  guarantee compilation of existing parallel programs (i.e., due to \"missing\"\n  `wasi-parallel` functionality).\n\n\n\n### API walk-through\n\nTODO\n\n\n\n\n### Detailed design discussion\n\nThe design of `wasi-parallel` is still in an experimental phase. Suggestions are\nwelcome as an [issue]!\n\n[issue]: https://github.com/WebAssembly/wasi-parallel/issues\n\n#### Device selection\n\nFirst, the user must be able to pick a parallel device to execute on. Early\nfeedback on the design (from the browser ecosystem) indicated that, since not\nall hosts would support all kinds of parallel devices, the command to retrieve a\ndevice should always succeed. This means that the kind of device the user\nselects is only a hint and can be overriden by the host.\n\n```wit\nget-device: func(hint: device-kind) -\u003e expected\u003cdevice, error\u003e\n```\n\n#### Buffer management\n\nSince the parallel device could be something other than the CPU, there must be\nsome way to indicate what regions of WebAssembly memory will be used by the\ndevice. The host is then responsible for transferring the memory to and from the\ndevice. The host, however, is not required to copy the memory \u0026mdash\nimplementations of a parallel CPU device could simply pass around pointers to\nshared memory.\n\n```wit\ncreate-buffer: func(device: device, size: u32, kind: buffer-access-kind) -\u003e expected\u003cbuffer, error\u003e\n```\n```wit\nwrite-buffer: func(data: list\u003cu8\u003e, buffer: buffer) -\u003e expected\u003cunit, error\u003e\n```\n```wit\nread-buffer: func(buffer: buffer) -\u003e expected\u003clist\u003cu8\u003e, error\u003e\n```\n\n#### Kernel definition\n\nThere must be a way to indicate what code should be run in parallel. Several\nother designs were discarded to reach the current mechanism: a binary-encoded\nWebAssembly module that exports a `kernel` function and imports a shared\n`memory`. When invoked by `parallel-exec`, this kernel is instantiated by the\nhost and scheduled on the parallel device; the call returns once the parallel\nexecution is complete.\n\n```wit\nparallel-exec: func(device: device, kernel: list\u003cu8\u003e, num-iterations: u32, block-size: u32, buffers: list\u003cbuffer\u003e) -\u003e expected\u003cunit, error\u003e\n```\n\n\n\n### Considered alternatives\n\nOther approaches are possible:\n\n#### `wasi-threads`\n\nThe [`wasi-threads`] proposal aims to expose host thread creation to a\nWebAssembly program. With some caveats, `wasi-threads` can be used to implement\n`pthreads`. The primary use case is exposing CPU-executed, OS-managed\nthreads; users who simply need threads should look there first.\n\nBecause `wasi-parallel` aims to allow parallel execution on more than just CPUs,\nthe API is quite different. Memory may be synchronized between devices, so it\nincludes buffer management APIs. And the number of iterations to execute must be\nknown up front for the device driver (e.g., GPU) to schedule the iterations\noptimally.\n\n[`wasi-threads`]: https://github.com/WebAssembly/wasi-threads\n\n#### Host APIs\n\nThis API standardizes a subset of the functionality available for parallel\nexecution on a host system. Users of WebAssembly programs could instead use this\nparallelism natively on the host side and expose custom APIs for their workload\n\u0026mdash; in other words, skip standardization. This is a legitimate approach that\nusers should consider, especially if the host hardware is known and fixed.\n`wasi-parallel` is targeted at situations in which parallelism is needed but the\nexact host environment is unknown.\n\n\n\n### Stakeholder Interest \u0026 Feedback\n\nTODO before entering Phase 3.\n\n\n\n\n### References \u0026 acknowledgements\n\nMany thanks for valuable feedback and advice from:\n\n- [Enrico Galli](https://github.com/egalli)\n- [Petr Penzin](https://github.com/penzn)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebassembly%2Fwasi-parallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebassembly%2Fwasi-parallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebassembly%2Fwasi-parallel/lists"}