InsightSoftwareConsortium / InsightSoftwareConsortium/ITK-Wasm

About Multithreading

Open
#1,200 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
235
Forks
61
Avg merge
4d 19h
Merged PRs (30d)
4

Description

I want to know why WorkerPool is used instead of pthread for implementing multithreading? My application needs to share the same image data across multiple wasm threads, but I found that the pipeline implementation creates new data. Is my understanding incorrect?
`packages/core/typescript/itk-wasm/src/pipeline/internal/run-pipeline-emscripten.ts`:
```ts
// ...
function setPipelineModuleInputArray (emscriptenModule: PipelineEmscriptenModule, dataArray: TypedArray | null, inputIndex: number, subIndex: number): number {
let dataPtr = 0
if (dataArray !== null) {
dataPtr = emscriptenModule.ccall('itk_wasm_input_array_alloc', 'number', ['number', 'number', 'number', 'number'], [0, inputIndex, subIndex, dataArray.buffer.byteLength])
emscriptenModule.HEAPU8.set(new Uint8Array(dataArray.buffer), dataPtr)
}
return dataPtr
}
// ...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.