Loading...
Searching...
No Matches
metal.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * MetalGPUDeviceBackend forward declaration header.
5 *
6 * Provides the Metal-specific accessors (device, command queue, buffer lookup)
7 * that MPS BLAS and MPSGraph FFT need. This header can be included from
8 * other .mm files without pulling in Metal/Metal.h.
9 */
10
11#ifdef __OBJC__
12#import <Metal/Metal.h>
13#endif
14
16
17#include <memory>
18
19namespace q3 {
20namespace execution {
21namespace gpu {
22namespace device {
23
24/**
25 * MetalGPUDeviceBackend — abstract interface for Metal-specific accessors.
26 *
27 * Concrete implementation lives in device/metal.mm.
28 */
30 public:
31 virtual ~MetalGPUDeviceBackend() = default;
32
33#ifdef __OBJC__
34 /**
35 * Get the Metal device.
36 */
37 virtual id<MTLDevice> metal_device() const = 0;
38
39 /**
40 * Get the Metal command queue.
41 */
42 virtual id<MTLCommandQueue> metal_command_queue() const = 0;
43
44 /**
45 * Look up the MTLBuffer for a pointer allocated by this backend.
46 *
47 * Returns nil if the pointer was not allocated by this backend.
48 */
49 virtual id<MTLBuffer> get_metal_buffer(const void* pointer) const = 0;
50#endif
51};
52
53} // namespace device
54} // namespace gpu
55} // namespace execution
56} // namespace q3