File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ option(GGML_VULKAN_VALIDATE "ggml: enable Vulkan validation"
189189option (GGML_VULKAN_RUN_TESTS "ggml: run Vulkan tests" OFF )
190190option (GGML_WEBGPU "ggml: use WebGPU" OFF )
191191option (GGML_WEBGPU_DEBUG "ggml: enable WebGPU debug output" OFF )
192+ option (GGML_WEBGPU_JSPI "ggml: use JSPI for WebGPU" ON )
192193option (GGML_ZDNN "ggml: use zDNN" OFF )
193194option (GGML_METAL "ggml: use Metal" ${GGML_METAL_DEFAULT} )
194195option (GGML_METAL_USE_BF16 "ggml: use bfloat if available" OFF )
Original file line number Diff line number Diff line change @@ -42,11 +42,19 @@ if(EMSCRIPTEN)
4242 if (NOT EMDAWNWEBGPU_DIR)
4343 # default built-in port
4444 target_compile_options (ggml-webgpu PRIVATE "--use-port=emdawnwebgpu" )
45- target_link_options (ggml-webgpu INTERFACE "--use-port=emdawnwebgpu" "-sASYNCIFY=1" )
45+ target_link_options (ggml-webgpu INTERFACE "--use-port=emdawnwebgpu" )
4646 else ()
4747 # custom port
4848 target_compile_options (ggml-webgpu PRIVATE "--use-port=${EMDAWNWEBGPU_DIR} /emdawnwebgpu.port.py" )
49- target_link_options (ggml-webgpu INTERFACE "--use-port=${EMDAWNWEBGPU_DIR} /emdawnwebgpu.port.py" "-sASYNCIFY=1" )
49+ target_link_options (ggml-webgpu INTERFACE "--use-port=${EMDAWNWEBGPU_DIR} /emdawnwebgpu.port.py" )
50+ endif ()
51+
52+ if (GGML_WEBGPU_JSPI)
53+ target_compile_options (ggml-webgpu PRIVATE "-fwasm-exceptions" )
54+ target_link_options (ggml-webgpu INTERFACE "-sJSPI" "-fwasm-exceptions" )
55+ else ()
56+ target_compile_options (ggml-webgpu PRIVATE "-fexceptions" )
57+ target_link_options (ggml-webgpu INTERFACE "-sASYNCIFY" "-exceptions" )
5058 endif ()
5159
5260 set (DawnWebGPU_TARGET webgpu_cpp)
@@ -58,8 +66,7 @@ endif()
5866if (GGML_WEBGPU_DEBUG)
5967 target_compile_definitions (ggml-webgpu PRIVATE GGML_WEBGPU_DEBUG=1)
6068 if (EMSCRIPTEN)
61- target_compile_options (ggml-webgpu PRIVATE "-fexceptions" )
62- target_link_options (ggml-webgpu INTERFACE "-sASSERTIONS=2" "-fexceptions" )
69+ target_link_options (ggml-webgpu INTERFACE "-sASSERTIONS=2" )
6370 endif ()
6471endif ()
6572
Original file line number Diff line number Diff line change @@ -1297,12 +1297,8 @@ ggml_backend_reg_t ggml_backend_webgpu_reg() {
12971297 webgpu_ctx->instance = wgpu::CreateInstance (&instance_descriptor);
12981298
12991299#ifdef __EMSCRIPTEN__
1300- #ifndef __EMSCRIPTEN_PTHREADS__
1301- GGML_LOG_WARN (" ggml_webgpu: pthread is disabled. This may cause bugs\n " );
1302- #endif
1303-
13041300 if (webgpu_ctx->instance == nullptr ) {
1305- GGML_LOG_ERROR (" ggml_webgpu: Failed to create WebGPU instance. Make sure -sASYNCIFY is set\n " );
1301+ GGML_LOG_ERROR (" ggml_webgpu: Failed to create WebGPU instance. Make sure either -sASYNCIFY or -sJSPI is set\n " );
13061302 return nullptr ;
13071303 }
13081304#endif
You can’t perform that action at this time.
0 commit comments