AnswerDotAI / gpu.cpp

A lightweight library for portable low-level GPU computation using WebGPU.
https://gpucpp.answer.ai
Apache License 2.0
3.68k stars 175 forks source link

Add createContextByGpuIdx to support for multi GPUs #50

Closed junjihashimoto closed 1 month ago

junjihashimoto commented 1 month ago

Currently it is not possible to explicitly select a GPU. This PR adds createContextByGpuIdx to select a specific GPU. However, the DAWN header is required.

austinvhuang commented 1 month ago

Have been thinking we need to request device by index, thanks!

Is there a way we can implement this without the DawnNative.h? (and avoiding as much as possible using dawn-specific features).

Want to avoid too much preprocessor branching on webgpu implementations and avoid depending on dawn's internals if we can because it makes testing more complicated and also means that code will break when using alternative webgpu implementations (emscripten/wasm today, maybe wgpu in the future).

For some things it's required (as you can see from emscripten) but want to avoid it as much as possible unless there's no other way.

junjihashimoto commented 1 month ago

For now, there is no webgpu implementation. https://github.com/gpuweb/gpuweb/issues/995 The dawn implementation simply checks whether the adapter has the features the user desires. https://github.com/google/dawn/blob/014d6f768e0a37ec76fe9bec3f27a249e9e427bd/src/dawn/fuzzers/DawnWireServerFuzzer.cpp#L119-L129 We cannot select a specific GPU when there are GPUs with similar capabilities.