Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Multithreading #1200

Open
leecervan904 opened this issue Aug 15, 2024 · 1 comment
Open

About Multithreading #1200

leecervan904 opened this issue Aug 15, 2024 · 1 comment

Comments

@leecervan904
Copy link

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:

// ...
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
}
// ...
@thewtex
Copy link
Member

thewtex commented Aug 16, 2024

Hi @leecervan904 ,

The plan is also to support pthread threading also and fall back gracefully when SharedArrayBuffer, etc. is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants