gpu.cpp 0.1.0
 
Loading...
Searching...
No Matches
gpu::Context Struct Reference

Represents a GPU context, aggregates WebGPU API handles to interact with the GPU including the instance, adapter, device, and queue. More...

#include <gpu.h>

Public Member Functions

 ~Context ()
 

Public Attributes

WGPUInstance instance
 
WGPUAdapter adapter
 
WGPUDevice device
 
WGPUQueue queue
 
TensorPool pool = TensorPool(this)
 
KernelPool kernelPool = KernelPool(this)
 

Detailed Description

Represents a GPU context, aggregates WebGPU API handles to interact with the GPU including the instance, adapter, device, and queue.

Additionally contains a TensorPool and KernelPool for managing GPU resources to simplify lifetime management of GPU resources.

Definition at line 434 of file gpu.h.

Constructor & Destructor Documentation

◆ ~Context()

gpu::Context::~Context ( )
inline

Definition at line 441 of file gpu.h.

441 {
442 LOG(kDefLog, kTrace, "Destroying context");
443 if (queue) {
444 wgpuQueueRelease(queue);
445 } else {
446 LOG(kDefLog, kWarn, "Queue is null");
447 }
448 if (device) {
449 wgpuDeviceRelease(device);
451 } else {
452 LOG(kDefLog, kWarn, "Device is null");
453 }
454 if (adapter) {
455 wgpuAdapterRelease(adapter);
457 } else {
458 LOG(kDefLog, kWarn, "Adapter is null");
459 }
460 if (instance) {
461 wgpuInstanceRelease(instance);
462 } else {
463 LOG(kDefLog, kWarn, "Instance is null");
464 }
465 LOG(kDefLog, kInfo, "Context destroyed");
466 }
static Logger kDefLog
Default logger for logging messages to stdout at the info level. Output stream and logging level for ...
Definition logging.h:64
void LOG(Logger &logger, int level, const char *message,...)
Log a message to the logger. If NDEBUG is defined in a source or as a compiler flag,...
Definition logging.h:34
void processEvents(const WGPUInstance &instance)
Definition gpu.h:419
@ kWarn
Definition logging.h:9
@ kTrace
Definition logging.h:9
@ kInfo
Definition logging.h:9
WGPUQueue queue
Definition gpu.h:438
WGPUInstance instance
Definition gpu.h:435
WGPUAdapter adapter
Definition gpu.h:436
WGPUDevice device
Definition gpu.h:437

Member Data Documentation

◆ adapter

WGPUAdapter gpu::Context::adapter

Definition at line 436 of file gpu.h.

◆ device

WGPUDevice gpu::Context::device

Definition at line 437 of file gpu.h.

◆ instance

WGPUInstance gpu::Context::instance

Definition at line 435 of file gpu.h.

◆ kernelPool

KernelPool gpu::Context::kernelPool = KernelPool(this)

Definition at line 440 of file gpu.h.

◆ pool

TensorPool gpu::Context::pool = TensorPool(this)

Definition at line 439 of file gpu.h.

◆ queue

WGPUQueue gpu::Context::queue

Definition at line 438 of file gpu.h.


The documentation for this struct was generated from the following file: