CGLRun
Loads the specified compiled Metal library and selects its named kernel. The library and function must exist and be compatible with the available GPU.
Graphics & compute
Load and dispatch a compiled Metal kernel using ordinary Catalyst buffers and values.
#include <mc/CGL.h>Link Catalyst::MacShared or Catalyst::MacStatic and provide a compatible GPU. The constructor takes a .metallib path and kernel function name.
Cosmic gpu functions and kernel entry points can be compiled with mc-cosmic --metallib. Add arguments in kernel order, configure the grid and thread group, then dispatch.
class CGLRunLoads the specified compiled Metal library and selects its named kernel. The library and function must exist and be compatible with the available GPU.
~CGLRun();
template<class T> CGLRun& operator<<(T&& x);
Registers the next argument through add() and returns the runner for chaining. Arguments are bound in insertion order.
template<class T> void add(CVector<T>& v);
template<class T> void add(T& x);
void add(void* data, size_t bytes);
Registers an argument in kernel order. Keep supplied memory allocated at the same address until dispatch finishes.
void clear();
Clears the registered argument list.
size_t maxThreads() const;
Returns the maximum thread count allowed in a threadgroup for this kernel. The product of dimensions supplied to setThreadGroup() must not exceed it.
void setGrid(size_t gx, size_t gy = 1, size_t gz = 1);
Sets the dispatched thread grid dimensions.
void setThreadGroup(size_t tx, size_t ty = 1, size_t tz = 1);
Sets the threadgroup dimensions; the product must fit the kernel/device limit.
void setMemory(size_t scratchBytesPerThread);
Sets scratch bytes per dispatched thread.
void setLog(size_t logBytesPerThread);
Sets log bytes per dispatched thread.
void start();
Copies bound inputs and submits work asynchronously. Keep host storage stable until await() copies the results back.
void await();
Waits for submitted work and makes output available in the bound host buffers.
void run();
Submits and waits for completion.
void outputLog(size_t thread);
Outputs the selected dispatched thread’s kernel log. Configure log bytes before dispatch and wait for completion before reading logs.