Skip to content

Commit

Permalink
feat(runPipelineEmscripten): Check for SIMD support
Browse files Browse the repository at this point in the history
SIMD support is now available by default in node.js and all major browsers.
  • Loading branch information
thewtex committed Aug 10, 2023
1 parent da63059 commit 9c6ced3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"glob": "^8.1.0",
"markdown-table": "^3.0.3",
"mime-types": "^2.1.35",
"wasm-feature-detect": "^1.5.1",
"webworker-promise": "^0.4.2"
},
"bin": {
Expand Down
8 changes: 8 additions & 0 deletions src/pipeline/runPipeline.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import createWebWorkerPromise from '../core/createWebWorkerPromise.js'
import loadEmscriptenModuleMainThread from '../core/internal/loadEmscriptenModuleMainThread.js'

import { simd } from 'wasm-feature-detect'

import config from '../itkConfig.js'

import IOTypes from '../core/IOTypes.js'
Expand Down Expand Up @@ -53,6 +55,12 @@ async function runPipeline (
inputs: PipelineInput[] | null,
options?: RunPipelineOptions
): Promise<RunPipelineResult> {
if (!await simd()) {
const simdErrorMessage = 'WebAssembly SIMD support is required -- please update your browser.'
alert(simdErrorMessage)
throw new Error(simdErrorMessage)
}

if (webWorker === false) {
const pipelineModule = await loadPipelineModule(pipelinePath.toString())
const result = runPipelineEmscripten(pipelineModule, args, outputs, inputs)
Expand Down

0 comments on commit 9c6ced3

Please sign in to comment.