Skip to content

Commit 14e7ab5

Browse files
committed
use async context waitForContext()
1 parent 9ac780b commit 14e7ab5

File tree

4 files changed

+180
-112
lines changed

4 files changed

+180
-112
lines changed

cmake/example.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ if(EMSCRIPTEN)
4545
# Set Emscripten-specific link flags that enable WASM output and expose certain symbols.
4646
# Needed to use updated version, emdawnwebgpu
4747
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "\
48+
-O3 \
4849
-sUSE_WEBGPU=0 \
4950
-sWASM=1 \
5051
-DDAWN_EMSCRIPTEN_TOOLCHAIN=${EMSCRIPTEN_DIR} \
5152
-sEXPORTED_FUNCTIONS=_main,_malloc,_free,_memcpy \
5253
-sEXPORTED_RUNTIME_METHODS=ccall \
5354
-sUSE_GLFW=3 \
54-
-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=5MB \
55+
-sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=15MB \
5556
-sASYNCIFY \
57+
-sASYNCIFY_DEBUG \
5658
--js-library=${DAWN_BUILD_DIR}/gen/src/emdawnwebgpu/library_webgpu_enum_tables.js \
5759
--js-library=${DAWN_BUILD_DIR}/gen/src/emdawnwebgpu/library_webgpu_generated_struct_info.js \
5860
--js-library=${DAWN_BUILD_DIR}/gen/src/emdawnwebgpu/library_webgpu_generated_sig_info.js \

examples/hello_world/run.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ int main(int argc, char **argv) {
2828
printf("--------------\n\n");
2929

3030
// std::unique_ptr<Context> ctx = createContext();
31-
Context ctx = createContext();
31+
Context ctx = waitForContext();
3232
static constexpr size_t N = 10000;
3333
std::array<float, N> inputArr, outputArr;
3434
for (int i = 0; i < N; ++i) {
3535
inputArr[i] = static_cast<float>(i) / 10.0; // dummy input data
3636
}
3737
Tensor input = createTensor(ctx, Shape{N}, kf32, inputArr.data());
3838
Tensor output = createTensor(ctx, Shape{N}, kf32);
39-
std::promise<void> promise;
40-
std::future<void> future = promise.get_future();
4139
std::future<Kernel> kernelFuture = createKernel(ctx, {kGelu, 256, kf32},
4240
Bindings{input, output},
4341
{cdiv(N, 256), 1, 1});

0 commit comments

Comments
 (0)