MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / dispatchKernel

Function dispatchKernel

gpu.hpp:1429–1442  ·  view source on GitHub ↗

* @brief Asynchronously submits a kernel to the GPU queue for execution. * It also sets up a callback to notify when the kernel has finished executing * by setting the value of the promise in the kernel instance argument. * * dispatchKernel does *not* wait for the kernel to finish executing and * returns immediately. The caller can wait for the kernel to finish executing * by calling wait()

Source from the content-addressed store, hash-verified

1427 * @endcode
1428 */
1429inline void dispatchKernel(Context &ctx, Kernel &kernel,
1430 std::promise<void> &promise) {
1431 // Submit the command buffer
1432 wgpuQueueSubmit(ctx.queue, 1, &kernel.commandBuffer);
1433 wgpuQueueOnSubmittedWorkDone(
1434 ctx.queue,
1435 [](WGPUQueueWorkDoneStatus status, void *data) {
1436 check(status == WGPUQueueWorkDoneStatus_Success, "Queue work done",
1437 __FILE__, __LINE__);
1438 auto *promise = static_cast<std::promise<void> *>(data);
1439 promise->set_value();
1440 },
1441 &promise);
1442}
1443
1444} // namespace gpu
1445

Callers 15

runTestFunction · 0.85
showResultFunction · 0.85
showResultFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
runTestFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
testWGSLFunction · 0.85
mainFunction · 0.85

Calls 1

checkFunction · 0.70

Tested by 15

testResidualFunction · 0.68
testHadamardFunction · 0.68
testMatmulFunction · 0.68
testGeluFunction · 0.68
testLayerNormFunction · 0.68
testSoftmaxFunction · 0.68
ENCODER_FORWARD_GPUFunction · 0.68
ENCODER_BACKWARD_GPUFunction · 0.68
LAYERNORM_FORWARD_GPUFunction · 0.68
LAYERNORM_BACKWARD_GPUFunction · 0.68
MATMUL_FORWARD_GPUFunction · 0.68
MATMUL_BACKWARD_GPUFunction · 0.68