Documentation ¶
Overview ¶
Package data provides structures to store arrays in a hardware-agnostic (GPU-CPU) way.
Index ¶
- Constants
- func Copy(dst, src *Slice)
- func Downsample(In [][][][]float32, N [3]int) [][][][]float32
- func EnableGPU(free, freeHost func(unsafe.Pointer), ...)
- func Index(size [3]int, ix, iy, iz int) int
- func SizeOf(block [][][]float32) [3]int
- type Mesh
- func (m *Mesh) CellSize() [3]float64
- func (m *Mesh) GNEB() [2]int
- func (m *Mesh) GNEB_code() byte
- func (m *Mesh) NCell() int
- func (m *Mesh) NumberOfImages() int
- func (m *Mesh) PBC() [3]int
- func (m *Mesh) PBC_code() byte
- func (m *Mesh) SetGNEB(gneb2D, gneb3D int)
- func (m *Mesh) SetPBC(nx, ny, nz int)
- func (m *Mesh) Size() [3]int
- func (m *Mesh) String() string
- func (m *Mesh) WorldSize() [3]float64
- type Meta
- type Slice
- func Crop(in *Slice, x1, x2, y1, y2, z1, z2 int) *Slice
- func NewSlice(nComp int, size [3]int) *Slice
- func NilSlice(nComp int, size [3]int) *Slice
- func Resample(in *Slice, N [3]int) *Slice
- func SliceFromArray(data [][]float32, size [3]int) *Slice
- func SliceFromPtrs(size [3]int, memType int8, ptrs []unsafe.Pointer) *Slice
- func (s *Slice) CPUAccess() bool
- func (s *Slice) Comp(i int) *Slice
- func (s *Slice) DevPtr(component int) unsafe.Pointer
- func (s *Slice) Disable()
- func (s *Slice) Free()
- func (s *Slice) GPUAccess() bool
- func (s *Slice) Get(comp, ix, iy, iz int) float64
- func (s *Slice) Host() [][]float32
- func (s *Slice) HostCopy() *Slice
- func (s *Slice) Index(ix, iy, iz int) int
- func (s *Slice) IsNil() bool
- func (s *Slice) Len() int
- func (s *Slice) MemType() int
- func (s *Slice) NComp() int
- func (f *Slice) Scalars() [][][]float32
- func (s *Slice) Set(comp, ix, iy, iz int, value float64)
- func (s *Slice) SetScalar(ix, iy, iz int, v float64)
- func (s *Slice) SetVector(ix, iy, iz int, v Vector)
- func (s *Slice) Size() [3]int
- func (s *Slice) String() string
- func (f *Slice) Tensors() [][][][]float32
- func (f *Slice) Vectors() [3][][][]float32
- type Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) Cross(b Vector) Vector
- func (v Vector) Div(a float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (v Vector) Len() float64
- func (a Vector) MAdd(s float64, b Vector) Vector
- func (v Vector) Mul(a float64) Vector
- func (a Vector) Sub(b Vector) Vector
- func (v Vector) X() float64
- func (v Vector) Y() float64
- func (v Vector) Z() float64
Constants ¶
const ( CPUMemory = 1 << 0 GPUMemory = 1 << 1 )
value for Slice.memType
const ( X = 0 Y = 1 Z = 2 )
const SIZEOF_FLOAT32 = 4
Variables ¶
This section is empty.
Functions ¶
func Downsample ¶
Downsample returns a slice of new size N, smaller than in.Size(). Averaging interpolation over the input slice. in is returned untouched if the sizes are equal.
Types ¶
type Mesh ¶
type Mesh struct { Unit string // unit of cellSize, default: "m" // contains filtered or unexported fields }
Mesh stores info of a finite-difference mesh.
func NewMesh ¶
Retruns a new mesh with N0 x N1 x N2 cells of size cellx x celly x cellz. Optional periodic boundary conditions (pbc): number of repetitions in X, Y, Z direction. 0,0,0 means no periodicity.
func NewMeshGneb ¶
func (*Mesh) NumberOfImages ¶
// Returns Number of Images as passed to constructor.
type Meta ¶
Holds meta data to be saved together with a slice. Typically winds up in OVF or DUMP header
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice is like a [][]float32, but may be stored in GPU or host memory.
func NilSlice ¶
Return a slice without underlying storage. Used to represent a mask containing all 1's.
func Resample ¶
Resample returns a slice of new size N, using nearest neighbor interpolation over the input slice.
func SliceFromArray ¶
func SliceFromPtrs ¶
Internal: construct a Slice using bare memory pointers.
func (*Slice) CPUAccess ¶
CPUAccess returns whether the Slice is accessible by the CPU. true means it is stored in host memory.
func (*Slice) DevPtr ¶
DevPtr returns a CUDA device pointer to a component. Slice must have GPUAccess. It is safe to call on a nil slice, returns NULL.
func (*Slice) Disable ¶
func (s *Slice) Disable()
INTERNAL. Overwrite struct fields with zeros to avoid accidental use after Free.
func (*Slice) Free ¶
func (s *Slice) Free()
Frees the underlying storage and zeros the Slice header to avoid accidental use. Slices sharing storage will be invalid after Free. Double free is OK.
func (*Slice) GPUAccess ¶
GPUAccess returns whether the Slice is accessible by the GPU. true means it is either stored on GPU or in unified host memory.
func (*Slice) Host ¶
Host returns the Slice as a [][]float32 indexed by component, cell number. It should have CPUAccess() == true.
func (*Slice) MemType ¶
MemType returns the memory type of the underlying storage: CPUMemory, GPUMemory or UnifiedMemory
func (*Slice) Scalars ¶
Floats returns the data as 3D array, indexed by cell position. Data should be scalar (1 component) and have CPUAccess() == true.