diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ce21103b5d3..bfb4fd4f3072 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -907,7 +907,7 @@ jobs: - platform: emscripten arch: wasm32 abi: wasm32 - docker_image: "gcr.io/iree-oss/emscripten@sha256:7652907cef454d08211e2bc08da6d27d6e9d6e9df06508224dadc2d5ba6c1873" + docker_image: "gcr.io/iree-oss/emscripten@sha256:3569560116a0de257f43961361640c636e6d92f5249a799dabebd7cf7ecedad1" build_script: "./build_tools/cmake/build_runtime_emscripten.sh" # No test script diff --git a/.github/workflows/samples.yml b/.github/workflows/samples.yml index 2143cdbd7519..f321378df74e 100644 --- a/.github/workflows/samples.yml +++ b/.github/workflows/samples.yml @@ -72,5 +72,5 @@ jobs: ./build_tools/github_actions/docker_run.sh \ --env "IREE_HOST_BUILD_DIR=${HOST_BUILD_DIR}" \ --env "IREE_EMPSCRIPTEN_BUILD_DIR=${IREE_EMPSCRIPTEN_BUILD_DIR}" \ - gcr.io/iree-oss/emscripten@sha256:7652907cef454d08211e2bc08da6d27d6e9d6e9df06508224dadc2d5ba6c1873 \ + gcr.io/iree-oss/emscripten@sha256:3569560116a0de257f43961361640c636e6d92f5249a799dabebd7cf7ecedad1 \ ./experimental/web/build_and_test_samples.sh diff --git a/build_tools/docker/dockerfiles/emscripten.Dockerfile b/build_tools/docker/dockerfiles/emscripten.Dockerfile index 4d2410638820..4bb330aedaea 100644 --- a/build_tools/docker/dockerfiles/emscripten.Dockerfile +++ b/build_tools/docker/dockerfiles/emscripten.Dockerfile @@ -12,8 +12,8 @@ FROM gcr.io/iree-oss/base@sha256:d6c426d1fe55947a4afe7669abae6c7e6aa44fa94e84804 # * https://github.com/emscripten-core/emsdk/blob/main/docker/Dockerfile # * https://hub.docker.com/r/emscripten/emsdk -ARG EMSDK_COMMIT=21611d2a507fad73385120d89e05a794666070ae -ARG SDK_VERSION=3.1.20 +ARG EMSDK_COMMIT=a896e3d066448b3530dbcaa48869fafefd738f57 +ARG SDK_VERSION=3.1.44 WORKDIR / @@ -43,4 +43,4 @@ RUN mkdir -p "${EM_CACHE}" && chmod -R 777 "${EM_CACHE}" # Normally we'd run `source emsdk_env.sh`, but that doesn't integrate with # Docker's environment properties model. Instead, we directly extend the path # to include the directories suggested by `emsdk activate`. -ENV PATH="${EMSDK}:${EMSDK}/node/14.18.2_64bit/bin:${EMSDK}/upstream/emscripten:$PATH" +ENV PATH="${EMSDK}:${EMSDK}/upstream/emscripten:$PATH" diff --git a/build_tools/docker/prod_digests.txt b/build_tools/docker/prod_digests.txt index 4d10d27109b0..904a77744605 100644 --- a/build_tools/docker/prod_digests.txt +++ b/build_tools/docker/prod_digests.txt @@ -7,7 +7,7 @@ gcr.io/iree-oss/frontends-swiftshader@sha256:eb0063d640d8402b077fcec5533f247ba34 gcr.io/iree-oss/gradle-android@sha256:5df113f9993a3f4515275bd5ab902a1d9c3dc6ff9682cd5e9806b20dc26fc15c gcr.io/iree-oss/riscv@sha256:c4c3f409ab6461ccca920bce2f2c30285a17a61979b54570459f76797e381cb5 gcr.io/iree-oss/nvidia@sha256:de6e4453614aa48059fd611d7e7255f4d6ac27ac29a47aabdc04191ec1758533 -gcr.io/iree-oss/emscripten@sha256:7652907cef454d08211e2bc08da6d27d6e9d6e9df06508224dadc2d5ba6c1873 +gcr.io/iree-oss/emscripten@sha256:3569560116a0de257f43961361640c636e6d92f5249a799dabebd7cf7ecedad1 gcr.io/iree-oss/android@sha256:c05cb80509c818132378c04e638d5908ce961250a90dd60281b2f582378df063 gcr.io/iree-oss/manylinux2014_x86_64-release@sha256:e83893d35be4ce3558c989e9d5ccc4ff88d058bc3e74a83181059cc76e2cf1f8 gcr.io/iree-oss/shark@sha256:2b2e41dbf909194b598e226144a2fb1e74d31851d41fe519d0fcb6d071b77461 diff --git a/experimental/web/build_and_test_samples.sh b/experimental/web/build_and_test_samples.sh index f1d6ec2b33ea..e9ca050af7af 100755 --- a/experimental/web/build_and_test_samples.sh +++ b/experimental/web/build_and_test_samples.sh @@ -29,3 +29,9 @@ test -f "${IREE_EMPSCRIPTEN_BUILD_DIR}/CMakeCache.txt" \ experimental/web/sample_static/build_sample.sh experimental/web/sample_dynamic/build_sample.sh + +# Clear the cache again before building the webgpu sample. +test -f "${IREE_EMPSCRIPTEN_BUILD_DIR}/CMakeCache.txt" \ + && rm "${IREE_EMPSCRIPTEN_BUILD_DIR}/CMakeCache.txt" + +experimental/web/sample_webgpu/build_sample.sh diff --git a/experimental/web/sample_dynamic/build_sample.sh b/experimental/web/sample_dynamic/build_sample.sh index 0b0deb7451d8..f6b5a410e7ad 100755 --- a/experimental/web/sample_dynamic/build_sample.sh +++ b/experimental/web/sample_dynamic/build_sample.sh @@ -33,8 +33,8 @@ ROOT_DIR=$(git rev-parse --show-toplevel) HOST_BUILD_DIR="${IREE_HOST_BUILD_DIR:-${ROOT_DIR}/build-host}" BUILD_DIR="${IREE_EMPSCRIPTEN_BUILD_DIR:-build-emscripten}" INSTALL_ROOT="$(realpath ${1:-${HOST_BUILD_DIR}/install})" -SOURCE_DIR=${ROOT_DIR}/experimental/web/sample_dynamic -BINARY_DIR=${BUILD_DIR}/experimental/web/sample_dynamic +SOURCE_DIR="${ROOT_DIR}/experimental/web/sample_dynamic" +BINARY_DIR="${BUILD_DIR}/experimental/web/sample_dynamic" IREE_PYTHON3_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE:-$(which python3)}" diff --git a/experimental/web/sample_webgpu/CMakeLists.txt b/experimental/web/sample_webgpu/CMakeLists.txt index 61c1641352f1..c3ceaf0f911e 100644 --- a/experimental/web/sample_webgpu/CMakeLists.txt +++ b/experimental/web/sample_webgpu/CMakeLists.txt @@ -39,6 +39,8 @@ target_link_options(${_NAME} PRIVATE "-sEXPORTED_FUNCTIONS=['_setup_sample', '_cleanup_sample', '_load_program', '_inspect_program', '_unload_program', '_call_function', '_malloc', '_free']" "-sEXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'UTF8ToString', 'dynCall', 'addFunction']" # + "-sUSE_WEBGPU=1" + # "-sASSERTIONS=1" # # Programs loaded dynamically can require additional memory, so allow growth. diff --git a/experimental/web/sample_webgpu/build_sample.sh b/experimental/web/sample_webgpu/build_sample.sh index 4bf7af958a65..cb7b70abb608 100755 --- a/experimental/web/sample_webgpu/build_sample.sh +++ b/experimental/web/sample_webgpu/build_sample.sh @@ -15,7 +15,15 @@ # Usage: # build_sample.sh (optional install path) && serve_sample.sh -set -e +set -euo pipefail + +ROOT_DIR=$(git rev-parse --show-toplevel) + +HOST_BUILD_DIR="${IREE_HOST_BUILD_DIR:-${ROOT_DIR}/build-host}" +BUILD_DIR="${IREE_EMPSCRIPTEN_BUILD_DIR:-build-emscripten}" +INSTALL_ROOT="$(realpath ${1:-${HOST_BUILD_DIR}/install})" +SOURCE_DIR="${ROOT_DIR}/experimental/web/sample_webgpu" +BINARY_DIR="${BUILD_DIR}/experimental/web/sample_webgpu" ############################################################################### # Setup and checking for dependencies # @@ -27,18 +35,10 @@ then exit 1 fi -CMAKE_BIN=${CMAKE_BIN:-$(which cmake)} -ROOT_DIR=$(git rev-parse --show-toplevel) -SOURCE_DIR=${ROOT_DIR}/experimental/web/sample_webgpu - -BUILD_DIR=${ROOT_DIR?}/build-emscripten -mkdir -p ${BUILD_DIR} +source "${ROOT_DIR}/build_tools/cmake/setup_build.sh" -BINARY_DIR=${BUILD_DIR}/experimental/web/sample_webgpu mkdir -p ${BINARY_DIR} -INSTALL_ROOT="${1:-${ROOT_DIR}/build-host/install}" - ############################################################################### # Compile from .mlir input to portable .vmfb file using host tools # ############################################################################### diff --git a/experimental/web/sample_webgpu/main.c b/experimental/web/sample_webgpu/main.c index 83bc98bab091..d1fad751edb1 100644 --- a/experimental/web/sample_webgpu/main.c +++ b/experimental/web/sample_webgpu/main.c @@ -439,15 +439,12 @@ static void buffer_map_async_callback(WGPUBufferMapAsyncStatus map_status, switch (map_status) { case WGPUBufferMapAsyncStatus_Success: break; - case WGPUBufferMapAsyncStatus_Error: - fprintf(stderr, " buffer_map_async_callback status: Error\n"); - break; case WGPUBufferMapAsyncStatus_DeviceLost: fprintf(stderr, " buffer_map_async_callback status: DeviceLost\n"); break; - case WGPUBufferMapAsyncStatus_Unknown: default: - fprintf(stderr, " buffer_map_async_callback status: Unknown\n"); + fprintf(stderr, " buffer_map_async_callback status: Error %d\n", + map_status); break; } diff --git a/experimental/webgpu/builtins.c b/experimental/webgpu/builtins.c index 1b2f30116210..cfeced7a6a8d 100644 --- a/experimental/webgpu/builtins.c +++ b/experimental/webgpu/builtins.c @@ -71,18 +71,12 @@ static iree_status_t iree_hal_webgpu_builtins_initialize_fill_buffer( const char* code = iree_hal_webgpu_builtins_find_code("fill_buffer.wgsl"); const WGPUShaderModuleWGSLDescriptor wgsl_descriptor = { - .chain = - { - .next = NULL, - .sType = WGPUSType_ShaderModuleWGSLDescriptor, - }, -#if defined(IREE_PLATFORM_EMSCRIPTEN) - // Emscripten uses this older name. - .source = code, -#else - // Spec uses this name: https://www.w3.org/TR/webgpu/#shader-module-creation - .code = code, -#endif + .chain = + { + .next = NULL, + .sType = WGPUSType_ShaderModuleWGSLDescriptor, + }, + .code = code, }; const WGPUShaderModuleDescriptor module_descriptor = { .nextInChain = &wgsl_descriptor.chain, diff --git a/experimental/webgpu/executable.c b/experimental/webgpu/executable.c index f9a0fe96b05b..ff3822517c8d 100644 --- a/experimental/webgpu/executable.c +++ b/experimental/webgpu/executable.c @@ -106,18 +106,12 @@ static iree_status_t iree_hal_webgpu_create_wgsl_shader_module( const char* code = iree_hal_wgsl_ShaderModuleDef_code_get(shader_module_def); const WGPUShaderModuleWGSLDescriptor descriptor = { - .chain = - { - .next = NULL, - .sType = WGPUSType_ShaderModuleWGSLDescriptor, - }, -#if defined(IREE_PLATFORM_EMSCRIPTEN) - // Emscripten uses this older name. - .source = code, -#else - // Spec uses this name: https://www.w3.org/TR/webgpu/#shader-module-creation - .code = code, -#endif + .chain = + { + .next = NULL, + .sType = WGPUSType_ShaderModuleWGSLDescriptor, + }, + .code = code, }; const WGPUShaderModuleDescriptor module_descriptor = { .nextInChain = &descriptor.chain,