Files
zeekay d14b104790 feat(zap): v2 generic API, bufpool, transport allocator + UMA/RDMA cgo
Three orthogonal additions, one wire format.

v2 package — generic ad-hoc schema dispatch (~/work/lux/zap/v2):
- README + IMPOSSIBILITY + BENCH_RESULTS document the v1↔v2 split.
- builder/field/iter/list/pool/registry/schema/view + codegen package
  emit v1-equivalent fast paths from declarative .zap sources.
- _compile_fail_test/ + examples/ cover negative and positive cases.
- v2_test.go exercises the generic dispatch path.
- doc.go in v1 marks v1 deprecated for *new* schema authoring; existing
  v1 buffers stay parseable by both v1 and v2.

bufpool — pooled read slabs (bufpool.go + bufpool_test.go):
- Message gains optional *bufRef; Release() returns the slab to its
  pool when sourced from the pooled read path, GC-managed otherwise.
- ParseHeader returns (data, rootOffset) without allocating *Message,
  used by zapv2 to avoid two allocations per parse.
- bench_read_test.go + node_quic_stream_test.go cover both paths.

Transport allocator + UMA/RDMA cgo (transport/*):
- Transport.Caps()/Buffer interface: capability + slab-typed buffer
  contract. Bytes() vs DevicePtr() decoupled so UMA and GPUDirect
  can share the same call surface.
- DPDK PMD + GPUDirect RDMA + CUDA UMA real cgo backends gated behind
  build tags; stub paths remain default on darwin / non-Linux.
- transport_test.go covers Caps reporting + Buffer lifecycle on the
  default transport.

LLM.md + go.mod follow the additions.
2026-06-04 17:06:59 -07:00

42 lines
1.4 KiB
C

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//
// Host-side C API for the cudaMallocManaged-backed UMA pool. Headers are
// kept ASCII-clean so non-cgo builds can still include this file for
// static analysis.
#ifndef LUX_ZAP_TRANSPORT_UMA_CUDA_H
#define LUX_ZAP_TRANSPORT_UMA_CUDA_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// luxzap_cuda_probe returns 0 if at least one CUDA device is usable on
// this host, otherwise a non-zero CUDA error code. Side-effect free
// beyond a single cudaGetDeviceCount call — safe to call before any
// other cudaMalloc*.
int luxzap_cuda_probe(void);
// luxzap_cuda_alloc_managed allocates `size` bytes via cudaMallocManaged
// with cudaMemAttachGlobal. Returns 0 on success; *out_ptr receives the
// unified pointer. Returns the cudaError_t on failure with *out_ptr=NULL.
int luxzap_cuda_alloc_managed(size_t size, void** out_ptr);
// luxzap_cuda_free releases memory previously returned by
// luxzap_cuda_alloc_managed. Safe to call with NULL.
int luxzap_cuda_free(void* ptr);
// luxzap_cuda_device_name fills `buf` with up to `buflen-1` chars of the
// device-0 name and NUL-terminates. Returns the number of bytes written
// (excluding the NUL), or 0 on error. Used only for the boot log line.
size_t luxzap_cuda_device_name(char* buf, size_t buflen);
#ifdef __cplusplus
}
#endif
#endif // LUX_ZAP_TRANSPORT_UMA_CUDA_H