parallel

package
v0.8.44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: GPL-3.0, LGPL-3.0, LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package parallel defines interfaces for optional parallel block execution and GPU acceleration in the Lux EVM.

By default (no build tags), a sequential executor is used. When built with -tags parallel, the evmgpu Block-STM engine is linked. When built with -tags parallel,gpu, GPU-accelerated hashing and ecrecover are also enabled.

This package lives in lux/evm so that the state processor can call into it without importing evmgpu. The evmgpu package provides the real implementations that satisfy these interfaces.

Package parallel defines interfaces for optional parallel block execution and GPU acceleration in the Lux EVM.

No build tags required. GPU acceleration is auto-detected at init time:

  • darwin + CGo: Metal GPU via gpu_bridge.go
  • linux + CGo + CUDA: NVIDIA GPU (future)
  • otherwise: CPU sequential (zero overhead)

The registration pattern allows platform-specific init() functions to register GPU backends without import cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterExecutor

func RegisterExecutor(e BlockExecutor)

RegisterExecutor sets the parallel block executor.

func RegisterGPU

func RegisterGPU(g GPUAccelerator)

RegisterGPU sets the GPU accelerator.

Types

type BlockExecutor

type BlockExecutor interface {
	// ExecuteBlock processes all transactions in a block.
	// Returns receipts in original transaction order, or an error.
	// A nil return (nil, nil) means "not handled, fall through to sequential."
	ExecuteBlock(
		config *ethparams.ChainConfig,
		header *types.Header,
		txs types.Transactions,
		statedb *state.StateDB,
		vmCfg vm.Config,
	) ([]*types.Receipt, error)
}

BlockExecutor processes all transactions in a block. The default implementation delegates to sequential per-tx execution. The parallel implementation uses Block-STM speculative execution.

func DefaultExecutor

func DefaultExecutor() BlockExecutor

DefaultExecutor returns the registered parallel executor, or a no-op sequential fallback if none was registered.

type GPUAccelerator

type GPUAccelerator interface {
	// Available reports whether a GPU backend is detected.
	Available() bool

	// BatchEcrecover recovers sender addresses for a batch of transactions.
	// Returns a map from tx hash to recovered sender address.
	BatchEcrecover(txs []*types.Transaction) (map[common.Hash]common.Address, error)

	// BatchKeccak hashes multiple inputs on GPU.
	BatchKeccak(inputs [][]byte) ([]common.Hash, error)
}

GPUAccelerator provides optional GPU-offloaded crypto operations. The default implementation returns Available() == false.

func DefaultGPU

func DefaultGPU() GPUAccelerator

DefaultGPU returns the registered GPU accelerator, or a no-op if none was registered.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL