Skip to content

Commit

Permalink
Build sample_webgpu in build_test_test_samples. (iree-org#14690)
Browse files Browse the repository at this point in the history
This should help spot regressions in the webgpu work. The build script
runs the compiler and builds the runtime (HAL driver and "sample"
application code).

Note: we still don't have any alerting configured for the [samples.yml
workflow](https://github.com/openxla/iree/actions/workflows/samples.yml),
and it has been failing for around a month (TensorFlow Python issues).
Better than nothing though...

Testing this at (you_didnt_see_anything.gif) 
* ~~https://github.com/openxla/iree/actions/runs/5872478019~~
* ~~https://github.com/openxla/iree/actions/runs/5872744401~~
* ~~https://github.com/openxla/iree/actions/runs/5872858233~~
* ~~https://github.com/openxla/iree/actions/runs/5881255239~~
* ~~https://github.com/openxla/iree/actions/runs/5881744607~~
* https://github.com/openxla/iree/actions/runs/5881953294
  • Loading branch information
ScottTodd authored and dcaballe committed Aug 21, 2023
1 parent 96d0e6a commit b4f358b
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions build_tools/docker/dockerfiles/emscripten.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 /

Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion build_tools/docker/prod_digests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions experimental/web/build_and_test_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions experimental/web/sample_dynamic/build_sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"


Expand Down
2 changes: 2 additions & 0 deletions experimental/web/sample_webgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions experimental/web/sample_webgpu/build_sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand All @@ -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 #
###############################################################################
Expand Down
7 changes: 2 additions & 5 deletions experimental/web/sample_webgpu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 6 additions & 12 deletions experimental/webgpu/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 6 additions & 12 deletions experimental/webgpu/executable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b4f358b

Please sign in to comment.