cudahazard

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cudahazard models GPU memory access hazards across execution scopes and memory spaces without importing higher-level tile or compiler packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteRangeOverlap

func ByteRangeOverlap(aOffset uint64, aSize uint32, bOffset uint64, bSize uint32) bool

ByteRangeOverlap reports whether two byte intervals [aOffset, aOffset+aSize) and [bOffset, bOffset+bSize) intersect.

func CheckClusterHardware

func CheckClusterHardware(arch string) error

CheckClusterHardware checks whether the target architecture supports thread block clusters and DSMEM. Compute capability 9.0+ (sm_90+) is required. For architectures below sm_90 (e.g. sm_80), it returns cuda.ErrHardwarePending rather than simulating device execution.

func WordOverlap

func WordOverlap(aOffset uint64, aSize uint32, bOffset uint64, bSize uint32) bool

WordOverlap reports whether two memory accesses touch the same aligned 32-bit word.

Types

type ExecutionScope

type ExecutionScope uint8

ExecutionScope identifies the concurrency level at which memory operations interact.

const (
	ScopeSubwarp ExecutionScope = iota + 1
	ScopeWarp
	ScopeCTA
	ScopeCluster
	ScopeDevice
	ScopeHostDevice
	ScopeMultiGPU
)

func (ExecutionScope) String

func (s ExecutionScope) String() string

String implements fmt.Stringer.

type HazardMatrix

type HazardMatrix struct {
	TargetArch  string
	ClusterSize int
	// contains filtered or unexported fields
}

HazardMatrix tracks concurrent memory operations and classifies hazards across execution scopes.

func NewHazardMatrix

func NewHazardMatrix(targetArch string) *HazardMatrix

NewHazardMatrix initializes a hazard matrix for a given target GPU architecture.

func (*HazardMatrix) AddAccess

func (m *HazardMatrix) AddAccess(acc MemoryAccess) error

AddAccess registers a memory access into the matrix.

func (*HazardMatrix) Evaluate

func (m *HazardMatrix) Evaluate() ([]HazardRecord, error)

Evaluate inspects all pairs of recorded accesses and classifies race conditions versus false positives.

func (*HazardMatrix) HasRace

func (m *HazardMatrix) HasRace() (bool, error)

HasRace reports whether any true data race was identified across all evaluated accesses.

type HazardRecord

type HazardRecord struct {
	AccessA       MemoryAccess
	AccessB       MemoryAccess
	Type          HazardType
	WordConflict  bool
	ByteConflict  bool
	IsRace        bool
	ScopeConflict bool
	Description   string
}

HazardRecord records an evaluated interaction between two concurrent memory accesses.

type HazardType

type HazardType uint8

HazardType classifies memory access conflicts.

const (
	HazardNone HazardType = iota
	HazardReadWrite
	HazardWriteWrite
	HazardWriteRead
)

func (HazardType) String

func (h HazardType) String() string

String implements fmt.Stringer.

type MemoryAccess

type MemoryAccess struct {
	Scope     ExecutionScope
	AgentID   int
	StreamID  int
	ThreadID  int
	BlockID   int
	ClusterID int
	Space     MemorySpace
	Offset    uint64
	SizeBytes uint32
	IsWrite   bool
	Stage     int
}

MemoryAccess describes an individual read or write access. AgentID distinguishes independent agents such as kernels. For device-scoped accesses from different agents, a shared nonzero StreamID records launch ordering; thread, block and cluster identify execution coordinates within an agent. One agent cannot represent accesses on multiple nonzero streams; accesses with the same agent ID on different nonzero streams are treated as distinct.

type MemorySpace

type MemorySpace uint8

MemorySpace identifies the physical or virtual GPU memory space.

const (
	MemoryShared MemorySpace = iota + 1
	MemoryDSMEM
	MemoryGlobal
	MemoryUnified
)

func (MemorySpace) String

func (m MemorySpace) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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