Files
dex/pkg/lxgpu/orderbook_bridge_nocgo.go
zeekay d7edc9d715 dex/lx: rip AMM GPU accel, clob→dex, add HIP+Vulkan orderbook cgo backends
CORRECTION 2 (AMM GPU rip): the constant-product xy=k AMM runs on-chain in
the EVM/consensus — GPU-accelerating it was a hallucination. Remove the GPU
AMM surface: pkg/lx/amm_gpu{,_cuda,_metal,_stub}.go + amm_nogpu.go (the
BatchEvalConstantProduct dispatcher) + amm_gpu_test.go; strip the AMM bridge
(AMMSwap, fnAMMSwap, call_amm_xyk_batch, LuxAmmReservePair) from pkg/lxgpu so
it bridges only the order-book path; drop the obsolete GPU_Batch sub-bench.
PRESERVED: pkg/lx/amm.go (ConstantProductOut/ReservePair/BatchEvalConstantProductCPU,
the 128-bit-exact CPU math) — it is the deterministic pricing used by the DEX
router's AMM source (pkg/dex/source_amm.go), untouched.

CORRECTION 1 (clob→dex): rename Go identifiers clobGPUMatch→dexGPUMatch,
clobShadowInput→dexShadowInput, runCLOBShadow→runDEXShadow,
captureCLOBShadowLocked→captureDEXShadowLocked, clobBackendLabel→dexBackendLabel,
clobScenario→dexScenario, TestCLOB*→TestDEX*, MatchDivergence.Kind "clob"→"dex".

CORRECTION 3 (host drivers): add orderbook_gpu_hip.go (cgo && linux && hip &&
!vulkan) and orderbook_gpu_vulkan.go (cgo && linux && vulkan), mirroring the
CUDA binding; narrow orderbook_gpu_cuda.go to (cgo && linux && !hip && !vulkan)
so exactly one backend compiles per linux tag combo (verified via go list).

Verified: CGO_ENABLED=0 go build ./... GREEN; go test ./pkg/lx ./pkg/dex
./pkg/dchain GREEN; gofmt clean; cgo bridge compiles; build-tag exclusivity
confirmed for ''/hip/vulkan.
2026-06-27 11:51:48 -07:00

47 lines
1.5 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build !cgo
// dexvm_gpu_nocgo.go — nocgo stub for the GPU plugin bridge.
//
// When CGO_ENABLED=0 the dlopen path in dexvm_gpu.go is unreachable,
// so every public method returns ErrGPUNotAvailable and AutoBackend()
// reports GPUBackendNone. The package surface is identical to the
// cgo build — consumers compile unconditionally and branch on
// AutoBackend() at runtime.
package lxgpu
// AutoBackend reports GPUBackendNone under !cgo — dlopen is unreachable.
func AutoBackend() GPUBackend { return GPUBackendNone }
// GPUPluginPath returns "" under !cgo — no plugin was loaded.
func GPUPluginPath() string { return "" }
// OrderBookArena is a zero-sized opaque type so the package surface
// compiles uniformly under both build tags. The nocgo build never
// returns a non-nil arena from ArenaCreate.
type OrderBookArena struct{}
// ArenaCreate returns ErrGPUNotAvailable under !cgo.
func ArenaCreate() (*OrderBookArena, error) {
return nil, ErrGPUNotAvailable
}
// ArenaDestroy returns ErrGPUNotAvailable under !cgo. A nil arena is
// still a no-op for symmetry with the cgo build.
func ArenaDestroy(a *OrderBookArena) error {
if a == nil {
return nil
}
return ErrGPUNotAvailable
}
// OrderBookMatch returns ErrGPUNotAvailable under !cgo.
func OrderBookMatch(a *OrderBookArena, calldata []byte) (out [OrderBookOutLen]byte, numFills uint32, err error) {
_ = a
_ = calldata
return out, 0, ErrGPUNotAvailable
}