gocca

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 7 Imported by: 0

README

gocca - Go bindings for OCCA

[Go Reference] (https://pkg.go.dev/github.com/notargets/gocca)

Go bindings for OCCA, a portable and vendor-neutral framework for parallel programming on heterogeneous platforms.

Introduction

Occa provides the ability to write code once and run on GPU, Multi-core CPU and HPC cluster supercomputers with high efficiency.

It works by using the host language to build a "driver" that launches kernels written in the Occa meta language, that looks like C. Occa takes care of compiling the source code built within the host driver and executing it. Occa provides memory transfer between host and kernels to make it easy to integrate high performance parallel kernels that run at the control of the host.

Features

  • Simple Go interface to OCCA
  • Support for all OCCA backends (Serial, OpenMP, CUDA, OpenCL, HIP, SYCL, Metal)
  • Memory management
  • Kernel compilation and execution
  • Zero-copy data transfers where possible

Requirements

  • Go 1.18 or later
  • OCCA library installed
  • CGO-compatible C compiler

Installation

Gocca was built to provide the Occa API Version 2.0.0 on github.

There are two methods in Gocca that provide version information about this wrapper and the installed version of Occa: GetOccaVersion(): Interrogates installed version of Occa GetGoccaVersion(): Interrogates the built version of Gocca

Install OCCA with GPU Support

First, install OCCA with your desired backend support:

# You need cmake installed on your system before this:
# do an "sudo apt update && sudo apt install -y cmake"
$ make occa-install
# You should see a confirmation that occa is installed like this:
# NOTE: Mac OSX ARM64 is currently not working with OCCA
$ occa info
    ========+======================+============================================
     CPU(s) | Processor Name       | AMD Ryzen Threadripper PRO 7965WX 24-Cores 
            | Memory               | 503.1 GB                                   
            | Clock Frequency      |
            | SIMD Instruction Set | SSE2                                       
            | SIMD Width           | 128 bits                                   
            | L1d Cache Size       | 768 KB                                     
            | L1i Cache Size       | 768 KB                                     
            | L2 Cache Size        |  24 MB                                     
            | L3 Cache Size        | 128 MB                                     
    ========+======================+============================================
     OpenCL | Platform 0           | NVIDIA CUDA                                
            |----------------------+--------------------------------------------
            | Device 0             | NVIDIA GeForce RTX 4070 SUPER              
            | Device Type          | gpu                                        
            | Compute Cores        | 56                                         
            | Global Memory        | 11.60 GB                                   
    ========+======================+============================================
     CUDA   | Device Name          | NVIDIA GeForce RTX 4070 SUPER              
            | Device ID            | 0                                          
            | Arch                 | sm_89                                      
            | Memory               | 11.60 GB                                   
    ========+======================+============================================

Set user environment variables

# The above install command will place these into your $HOME/.bashrc
$ export OCCA_DIR=/usr/local
$ export OCCA_CACHE_DIR=$HOME/.occa

Then install gocca:

$ go get github.com/notargets/gocca

Quick Start

# This will run a halo exchange application to verify functionality
# Take a look at the code in halo/mesh_halo_device_test.go
$ make test

Examples

See the examples directory for more usage examples, for instance the hello_world there compares CPU to GPU results and produces this:

OCCA CPU vs GPU Comparison
==========================

=== Running on Serial ===
  N=    1000:     21.492µs  (correct: true)
  N=   10000:       6.83µs  (correct: true)
  N=  100000:    186.244µs  (correct: true)
  N= 1000000:   1.604074ms  (correct: true)

=== Running on CUDA ===
  N=    1000:     46.191µs  (correct: true)
  N=   10000:      9.013µs  (correct: true)
  N=  100000:       7.04µs  (correct: true)
  N= 1000000:      7.081µs  (correct: true)

=== Trying OpenMP (Multi-threaded CPU) ===

=== Running on OpenMP ===
  N=    1000:   7.778554ms  (correct: true)
  N=   10000:    7.96681ms  (correct: true)
  N=  100000:   7.963294ms  (correct: true)
  N= 1000000:    5.08593ms  (correct: true)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

OCCA developers for the excellent parallel programming framework Inspired by other Go bindings projects like go-opencv

Documentation

Overview

Package gocca provides Go bindings for OCCA (Open Concurrent Compute Abstraction).

OCCA is a portable and vendor-neutral framework for parallel programming on heterogeneous platforms. It supports multiple backends including Serial, OpenMP, CUDA, OpenCL, HIP, SYCL, and Metal.

Basic usage:

device, err := gocca.NewDevice(`{"mode": "Serial"}`)
if err != nil {
    log.Fatal(err)
}
defer device.Free()

For more information about OCCA, see https://github.com/libocca/occa

Index

Constants

View Source
const (
	OccaMajorVersion = C.OCCA_MAJOR_VERSION
	OccaMinorVersion = C.OCCA_MINOR_VERSION
	OccaPatchVersion = C.OCCA_PATCH_VERSION
	OccaVersionStr   = C.OCCA_VERSION_STR

	// GoCCA version - automatically updated by git export-subst
	// $Format:Describe=%D$
	// $Format:CommitHash=%H$
	GoccaVersionInfo = "$Format:%d$"
	GoccaCommitHash  = "$Format:%h$"
)

Version constants from OCCA headers at compile time

Variables

View Source
var (
	DtypeNone   = &OCCADtype{dtype: C.getDtypeNone()}
	DtypeVoid   = &OCCADtype{dtype: C.getDtypeVoid()}
	DtypeByte   = &OCCADtype{dtype: C.getDtypeByte()}
	DtypeBool   = &OCCADtype{dtype: C.getDtypeBool()}
	DtypeChar   = &OCCADtype{dtype: C.getDtypeChar()}
	DtypeShort  = &OCCADtype{dtype: C.getDtypeShort()}
	DtypeInt    = &OCCADtype{dtype: C.getDtypeInt()}
	DtypeLong   = &OCCADtype{dtype: C.getDtypeLong()}
	DtypeFloat  = &OCCADtype{dtype: C.getDtypeFloat()}
	DtypeDouble = &OCCADtype{dtype: C.getDtypeDouble()}

	DtypeInt8   = &OCCADtype{dtype: C.getDtypeInt8()}
	DtypeUint8  = &OCCADtype{dtype: C.getDtypeUint8()}
	DtypeInt16  = &OCCADtype{dtype: C.getDtypeInt16()}
	DtypeUint16 = &OCCADtype{dtype: C.getDtypeUint16()}
	DtypeInt32  = &OCCADtype{dtype: C.getDtypeInt32()}
	DtypeUint32 = &OCCADtype{dtype: C.getDtypeUint32()}
	DtypeInt64  = &OCCADtype{dtype: C.getDtypeInt64()}
	DtypeUint64 = &OCCADtype{dtype: C.getDtypeUint64()}

	// OKL Primitives
	DtypeUchar2 = &OCCADtype{dtype: C.getDtypeUchar2()}
	DtypeUchar3 = &OCCADtype{dtype: C.getDtypeUchar3()}
	DtypeUchar4 = &OCCADtype{dtype: C.getDtypeUchar4()}

	DtypeChar2 = &OCCADtype{dtype: C.getDtypeChar2()}
	DtypeChar3 = &OCCADtype{dtype: C.getDtypeChar3()}
	DtypeChar4 = &OCCADtype{dtype: C.getDtypeChar4()}

	DtypeUshort2 = &OCCADtype{dtype: C.getDtypeUshort2()}
	DtypeUshort3 = &OCCADtype{dtype: C.getDtypeUshort3()}
	DtypeUshort4 = &OCCADtype{dtype: C.getDtypeUshort4()}

	DtypeShort2 = &OCCADtype{dtype: C.getDtypeShort2()}
	DtypeShort3 = &OCCADtype{dtype: C.getDtypeShort3()}
	DtypeShort4 = &OCCADtype{dtype: C.getDtypeShort4()}

	DtypeUint2 = &OCCADtype{dtype: C.getDtypeUint2()}
	DtypeUint3 = &OCCADtype{dtype: C.getDtypeUint3()}
	DtypeUint4 = &OCCADtype{dtype: C.getDtypeUint4()}

	DtypeInt2 = &OCCADtype{dtype: C.getDtypeInt2()}
	DtypeInt3 = &OCCADtype{dtype: C.getDtypeInt3()}
	DtypeInt4 = &OCCADtype{dtype: C.getDtypeInt4()}

	DtypeUlong2 = &OCCADtype{dtype: C.getDtypeUlong2()}
	DtypeUlong3 = &OCCADtype{dtype: C.getDtypeUlong3()}
	DtypeUlong4 = &OCCADtype{dtype: C.getDtypeUlong4()}

	DtypeLong2 = &OCCADtype{dtype: C.getDtypeLong2()}
	DtypeLong3 = &OCCADtype{dtype: C.getDtypeLong3()}
	DtypeLong4 = &OCCADtype{dtype: C.getDtypeLong4()}

	DtypeFloat2 = &OCCADtype{dtype: C.getDtypeFloat2()}
	DtypeFloat3 = &OCCADtype{dtype: C.getDtypeFloat3()}
	DtypeFloat4 = &OCCADtype{dtype: C.getDtypeFloat4()}

	DtypeDouble2 = &OCCADtype{dtype: C.getDtypeDouble2()}
	DtypeDouble3 = &OCCADtype{dtype: C.getDtypeDouble3()}
	DtypeDouble4 = &OCCADtype{dtype: C.getDtypeDouble4()}
)

Built-in data types

View Source
var (
	OCCA_UNDEFINED     = int(C.getOccaUndefined())
	OCCA_DEFAULT       = int(C.getOccaDefault())
	OCCA_NULL          = int(C.getOccaNull())
	OCCA_PTR           = int(C.getOccaPtr())
	OCCA_BOOL          = int(C.getOccaBool())
	OCCA_INT8          = int(C.getOccaInt8())
	OCCA_UINT8         = int(C.getOccaUint8())
	OCCA_INT16         = int(C.getOccaInt16())
	OCCA_UINT16        = int(C.getOccaUint16())
	OCCA_INT32         = int(C.getOccaInt32())
	OCCA_UINT32        = int(C.getOccaUint32())
	OCCA_INT64         = int(C.getOccaInt64())
	OCCA_UINT64        = int(C.getOccaUint64())
	OCCA_FLOAT         = int(C.getOccaFloat())
	OCCA_DOUBLE        = int(C.getOccaDouble())
	OCCA_STRUCT        = int(C.getOccaStruct())
	OCCA_STRING        = int(C.getOccaString())
	OCCA_DEVICE        = int(C.getOccaDevice())
	OCCA_KERNEL        = int(C.getOccaKernel())
	OCCA_KERNELBUILDER = int(C.getOccaKernelBuilder())
	OCCA_MEMORY        = int(C.getOccaMemory())
	OCCA_MEMORYPOOL    = int(C.getOccaMemoryPool())
	OCCA_STREAM        = int(C.getOccaStream())
	OCCA_STREAMTAG     = int(C.getOccaStreamTag())
	OCCA_DTYPE         = int(C.getOccaDtype())
	OCCA_SCOPE         = int(C.getOccaScope())
	OCCA_JSON          = int(C.getOccaJson())
)

Type flags

View Source
var (
	OccaAllBytes = uint64(C.getOccaAllBytes())
)

Global values

Functions

func Bool added in v0.9.1

func Bool(value bool) C.occaType

Bool creates an OCCA bool type

func Char added in v0.9.1

func Char(value int8) C.occaType

Char creates an OCCA char type

func CopyMemToMem added in v1.2.0

func CopyMemToMem(dest, src *OCCAMemory, bytes int64, destOffset, srcOffset int64, props *OCCAJson)

CopyMemToMem copies memory from one device memory to another

func CopyMemToPtr added in v1.2.0

func CopyMemToPtr(dest unsafe.Pointer, src *OCCAMemory, bytes int64, offset int64, props *OCCAJson)

CopyMemToPtr copies from device memory to host pointer

func CopyPtrToMem added in v1.2.0

func CopyPtrToMem(dest *OCCAMemory, src unsafe.Pointer, bytes int64, offset int64, props *OCCAJson)

CopyPtrToMem copies from host pointer to device memory

func Double added in v0.9.1

func Double(value float64) C.occaType

Double creates an OCCA double type

func DtypesAreEqual added in v0.9.1

func DtypesAreEqual(a, b *OCCADtype) bool

DtypesAreEqual checks if two data types are equal

func DtypesMatch added in v0.9.1

func DtypesMatch(a, b *OCCADtype) bool

DtypesMatch checks if two data types match

func Finish added in v0.9.1

func Finish()

Finish waits for all operations to complete on current device

func Float added in v0.9.1

func Float(value float32) C.occaType

Float creates an OCCA float type

func Free added in v0.9.1

func Free(value *C.occaType)

Free frees an OCCA type

func GetGoccaVersion added in v1.2.0

func GetGoccaVersion() string

GetGoccaVersion returns the GoCCA wrapper version

func GetMajorVersion added in v1.2.0

func GetMajorVersion() int

GetMajorVersion returns the OCCA major version number

func GetMinorVersion added in v1.2.0

func GetMinorVersion() int

GetMinorVersion returns the OCCA minor version number

func GetOccaVersion added in v1.2.0

func GetOccaVersion() string

GetOccaVersion returns the OCCA version this wrapper was compiled against

func GetPatchVersion added in v1.2.0

func GetPatchVersion() int

GetPatchVersion returns the OCCA patch version number

func GetVersionInfo added in v1.2.0

func GetVersionInfo() string

GetVersionInfo returns version information string

func HeaderVersion added in v1.2.0

func HeaderVersion() string

HeaderVersion returns the OCCA header version string (same as Version for compatibility)

func HeaderVersionNumber added in v1.2.0

func HeaderVersionNumber() string

HeaderVersionNumber returns the OCCA header version number (same as VersionNumber for compatibility)

func Int added in v0.9.1

func Int(value int) C.occaType

Int creates an OCCA int type

func Int8 added in v0.9.1

func Int8(value int8) C.occaType

Int8 creates an OCCA int8 type

func Int16 added in v0.9.1

func Int16(value int16) C.occaType

Int16 creates an OCCA int16 type

func Int32 added in v0.9.1

func Int32(value int32) C.occaType

Int32 creates an OCCA int32 type

func Int64 added in v0.9.1

func Int64(value int64) C.occaType

Int64 creates an OCCA int64 type

func IsDefault added in v0.9.1

func IsDefault(value C.occaType) bool

IsDefault checks if a value is default

func IsUndefined added in v0.9.1

func IsUndefined(value C.occaType) bool

IsUndefined checks if a value is undefined

func Long added in v0.9.1

func Long(value int64) C.occaType

Long creates an OCCA long type

func OverrideStderr added in v0.9.1

func OverrideStderr(err func(string))

OverrideStderr is a placeholder for OCCA stderr override Currently not implemented due to CGo callback limitations

func OverrideStdout added in v0.9.1

func OverrideStdout(out func(string))

OverrideStdout is a placeholder for OCCA stdout override Currently not implemented due to CGo callback limitations

func PrintModeInfo added in v0.9.1

func PrintModeInfo()

PrintModeInfo prints information about available modes

func PrintTypeInfo added in v0.9.1

func PrintTypeInfo(value C.occaType)

PrintTypeInfo prints information about an OCCA type

func Ptr added in v0.9.1

func Ptr(value unsafe.Pointer) C.occaType

Ptr creates an OCCA pointer type

func SetDevice added in v0.9.1

func SetDevice(device *OCCADevice)

SetDevice sets the current device

func SetDeviceFromString added in v0.9.1

func SetDeviceFromString(info string)

SetDeviceFromString sets the current device from a string

func SetStream added in v0.9.1

func SetStream(stream *OCCAStream)

SetStream sets the current stream

func Short added in v0.9.1

func Short(value int16) C.occaType

Short creates an OCCA short type

func StreamUnwrap added in v0.9.1

func StreamUnwrap(stream *OCCAStream) unsafe.Pointer

StreamUnwrap returns the underlying stream pointer

func String added in v0.9.1

func String(str string) C.occaType

String creates an OCCA string type

func Struct added in v0.9.1

func Struct(value unsafe.Pointer, bytes uint64) C.occaType

Struct creates an OCCA struct type

func TimeBetweenTags added in v0.9.1

func TimeBetweenTags(startTag, endTag *OCCAStreamTag) float64

TimeBetweenTags returns the time in seconds between two tags

func UChar added in v0.9.1

func UChar(value uint8) C.occaType

UChar creates an OCCA unsigned char type

func UInt added in v0.9.1

func UInt(value uint) C.occaType

UInt creates an OCCA unsigned int type

func UInt8 added in v0.9.1

func UInt8(value uint8) C.occaType

UInt8 creates an OCCA uint8 type

func UInt16 added in v0.9.1

func UInt16(value uint16) C.occaType

UInt16 creates an OCCA uint16 type

func UInt32 added in v0.9.1

func UInt32(value uint32) C.occaType

UInt32 creates an OCCA uint32 type

func UInt64 added in v0.9.1

func UInt64(value uint64) C.occaType

UInt64 creates an OCCA uint64 type

func ULong added in v0.9.1

func ULong(value uint64) C.occaType

ULong creates an OCCA unsigned long type

func UShort added in v0.9.1

func UShort(value uint16) C.occaType

UShort creates an OCCA unsigned short type

func Version added in v1.2.0

func Version() string

Version returns the OCCA version string (for api_completeness_test.go)

func VersionNumber added in v1.2.0

func VersionNumber() string

VersionNumber returns the OCCA version as a formatted string "major.minor.patch"

func WaitForTag added in v0.9.1

func WaitForTag(tag *OCCAStreamTag)

WaitForTag waits for a stream tag to be reached

Types

type OCCADevice

type OCCADevice struct {
	// contains filtered or unexported fields
}

func CreateDevice added in v1.2.0

func CreateDevice(props *OCCAJson) (*OCCADevice, error)

CreateDevice creates a new OCCA device from JSON properties (direct C API equivalent)

func CreateDeviceFromString added in v0.9.1

func CreateDeviceFromString(info string) (*OCCADevice, error)

CreateDeviceFromString creates a device from a string configuration

func GetDevice added in v0.9.1

func GetDevice() *OCCADevice

GetDevice returns the current device

func Host added in v0.9.1

func Host() *OCCADevice

Host returns the host device

func NewDevice

func NewDevice(deviceInfo string) (*OCCADevice, error)

NewDevice creates a new OCCA device with the given properties (string convenience method)

func (*OCCADevice) BuildKernel

func (d *OCCADevice) BuildKernel(filename, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernel builds a kernel from source file

func (*OCCADevice) BuildKernelFromBinary added in v0.9.1

func (d *OCCADevice) BuildKernelFromBinary(filename, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernelFromBinary builds a kernel from binary file

func (*OCCADevice) BuildKernelFromString added in v0.9.1

func (d *OCCADevice) BuildKernelFromString(source, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernelFromString builds a kernel from source string

func (*OCCADevice) CreateMemoryPool added in v0.9.1

func (d *OCCADevice) CreateMemoryPool(props *OCCAJson) *OCCAMemoryPool

CreateMemoryPool creates a new memory pool

func (*OCCADevice) CreateStream added in v0.9.1

func (d *OCCADevice) CreateStream(props *OCCAJson) *OCCAStream

CreateStream creates a new stream

func (*OCCADevice) Finish added in v0.9.1

func (d *OCCADevice) Finish()

Finish waits for all operations to complete

func (*OCCADevice) Free

func (d *OCCADevice) Free()

Free frees the device and unlocks the thread if it's locked

func (*OCCADevice) GetKernelProperties added in v0.9.1

func (d *OCCADevice) GetKernelProperties() *OCCAJson

GetKernelProperties returns kernel properties

func (*OCCADevice) GetMemoryProperties added in v0.9.1

func (d *OCCADevice) GetMemoryProperties() *OCCAJson

GetMemoryProperties returns memory properties

func (*OCCADevice) GetProperties added in v0.9.1

func (d *OCCADevice) GetProperties() *OCCAJson

GetProperties returns device properties

func (*OCCADevice) GetStream added in v0.9.1

func (d *OCCADevice) GetStream() *OCCAStream

GetStream returns the current stream

func (*OCCADevice) HasSeparateMemorySpace added in v0.9.1

func (d *OCCADevice) HasSeparateMemorySpace() bool

HasSeparateMemorySpace checks if device has separate memory space

func (*OCCADevice) IsInitialized added in v0.9.1

func (d *OCCADevice) IsInitialized() bool

IsInitialized checks if the device is initialized

func (*OCCADevice) IsThreadLocked added in v1.2.0

func (d *OCCADevice) IsThreadLocked() bool

IsThreadLocked returns whether this device has locked the OS thread

func (*OCCADevice) Malloc

func (d *OCCADevice) Malloc(bytes int64, src unsafe.Pointer, props *OCCAJson) *OCCAMemory

Malloc allocates memory on the device

func (*OCCADevice) MallocFloat32

func (d *OCCADevice) MallocFloat32(data []float32) *OCCAMemory

MallocFloat32 allocates memory for float32 slice

func (*OCCADevice) MallocFloat64 added in v0.9.1

func (d *OCCADevice) MallocFloat64(data []float64) *OCCAMemory

MallocFloat64 allocates memory for float64 slice

func (*OCCADevice) MallocInt32

func (d *OCCADevice) MallocInt32(data []int32) *OCCAMemory

MallocInt32 allocates memory for int32 slice

func (*OCCADevice) MallocInt64 added in v0.9.1

func (d *OCCADevice) MallocInt64(data []int64) *OCCAMemory

MallocInt64 allocates memory for int64 slice

func (*OCCADevice) MemoryAllocated added in v0.9.1

func (d *OCCADevice) MemoryAllocated() int64

MemoryAllocated returns the amount of memory allocated

func (*OCCADevice) MemorySize added in v0.9.1

func (d *OCCADevice) MemorySize() int64

MemorySize returns the device memory size

func (*OCCADevice) Mode added in v0.9.1

func (d *OCCADevice) Mode() string

Mode returns the device mode (e.g., "Serial", "OpenMP", "CUDA", etc.)

func (*OCCADevice) SetStream added in v0.9.1

func (d *OCCADevice) SetStream(stream *OCCAStream)

SetStream sets the current stream

func (*OCCADevice) TagStream added in v0.9.1

func (d *OCCADevice) TagStream() *OCCAStreamTag

TagStream tags the current position in the stream

func (*OCCADevice) TimeBetweenTags added in v0.9.1

func (d *OCCADevice) TimeBetweenTags(startTag, endTag *OCCAStreamTag) float64

TimeBetweenTags returns the time in seconds between two tags

func (*OCCADevice) TypedMalloc added in v0.9.1

func (d *OCCADevice) TypedMalloc(entries int64, dtype *OCCADtype, src unsafe.Pointer, props *OCCAJson) *OCCAMemory

TypedMalloc allocates typed memory on the device

func (*OCCADevice) TypedWrapMemory added in v0.9.1

func (d *OCCADevice) TypedWrapMemory(ptr unsafe.Pointer, entries int64, dtype *OCCADtype, props *OCCAJson) *OCCAMemory

TypedWrapMemory wraps existing typed memory

func (*OCCADevice) WaitForTag added in v0.9.1

func (d *OCCADevice) WaitForTag(tag *OCCAStreamTag)

WaitForTag waits for a stream tag to be reached

func (*OCCADevice) WrapMemory added in v0.9.1

func (d *OCCADevice) WrapMemory(ptr unsafe.Pointer, bytes int64, props *OCCAJson) *OCCAMemory

WrapMemory wraps existing memory

type OCCADim added in v0.9.1

type OCCADim struct {
	X, Y, Z uint64
}

type OCCADtype added in v0.9.1

type OCCADtype struct {
	// contains filtered or unexported fields
}

func CreateDtype added in v0.9.1

func CreateDtype(name string, bytes int) *OCCADtype

CreateDtype creates a new data type

func CreateDtypeTuple added in v0.9.1

func CreateDtypeTuple(dtype *OCCADtype, size int) *OCCADtype

CreateDtypeTuple creates a tuple data type

func DtypeFromJson added in v0.9.1

func DtypeFromJson(json *OCCAJson) *OCCADtype

DtypeFromJson creates a data type from JSON

func DtypeFromJsonString added in v0.9.1

func DtypeFromJsonString(jsonStr string) *OCCADtype

DtypeFromJsonString creates a data type from JSON string

func (*OCCADtype) AddField added in v0.9.1

func (d *OCCADtype) AddField(field string, fieldType *OCCADtype)

AddField adds a field to the data type

func (*OCCADtype) Bytes added in v0.9.1

func (d *OCCADtype) Bytes() int

Bytes returns the size of the data type in bytes

func (*OCCADtype) Free added in v0.9.1

func (d *OCCADtype) Free()

Free frees the data type

func (*OCCADtype) IsRegistered added in v0.9.1

func (d *OCCADtype) IsRegistered() bool

IsRegistered checks if the data type is registered

func (*OCCADtype) Name added in v0.9.1

func (d *OCCADtype) Name() string

Name returns the name of the data type

func (*OCCADtype) RegisterType added in v0.9.1

func (d *OCCADtype) RegisterType()

RegisterType registers the data type

func (*OCCADtype) ToJson added in v0.9.1

func (d *OCCADtype) ToJson() *OCCAJson

ToJson converts the data type to JSON

type OCCAJson added in v0.9.1

type OCCAJson struct {
	// contains filtered or unexported fields
}

func CreateJson added in v0.9.1

func CreateJson() *OCCAJson

CreateJson creates a new JSON object

func DeviceProperties added in v0.9.1

func DeviceProperties() *OCCAJson

DeviceProperties returns properties of the current device

func JsonParse added in v0.9.1

func JsonParse(jsonStr string) *OCCAJson

JsonParse parses a JSON string

func JsonRead added in v0.9.1

func JsonRead(filename string) *OCCAJson

JsonRead reads JSON from a file

func Settings added in v0.9.1

func Settings() *OCCAJson

Settings returns global OCCA settings

func (*OCCAJson) ArrayClear added in v0.9.1

func (j *OCCAJson) ArrayClear()

ArrayClear clears the JSON array

func (*OCCAJson) ArrayGet added in v0.9.1

func (j *OCCAJson) ArrayGet(index int) interface{}

ArrayGet gets a value from JSON array

func (*OCCAJson) ArrayInsert added in v0.9.1

func (j *OCCAJson) ArrayInsert(index int, value interface{}) error

ArrayInsert inserts a value into JSON array

func (*OCCAJson) ArrayPop added in v0.9.1

func (j *OCCAJson) ArrayPop()

ArrayPop pops a value from JSON array

func (*OCCAJson) ArrayPush added in v0.9.1

func (j *OCCAJson) ArrayPush(value interface{}) error

ArrayPush pushes a value to JSON array

func (*OCCAJson) ArraySize added in v0.9.1

func (j *OCCAJson) ArraySize() int

ArraySize returns the size of JSON array

func (*OCCAJson) CastToArray added in v0.9.1

func (j *OCCAJson) CastToArray()

CastToArray casts JSON to array

func (*OCCAJson) CastToBoolean added in v0.9.1

func (j *OCCAJson) CastToBoolean()

CastToBoolean casts JSON to boolean

func (*OCCAJson) CastToNumber added in v0.9.1

func (j *OCCAJson) CastToNumber()

CastToNumber casts JSON to number

func (*OCCAJson) CastToObject added in v0.9.1

func (j *OCCAJson) CastToObject()

CastToObject casts JSON to object

func (*OCCAJson) CastToString added in v0.9.1

func (j *OCCAJson) CastToString()

CastToString casts JSON to string

func (*OCCAJson) Dump added in v0.9.1

func (j *OCCAJson) Dump(indent int) string

Dump returns the JSON as a string

func (*OCCAJson) Free added in v0.9.1

func (j *OCCAJson) Free()

Free frees the JSON object

func (*OCCAJson) GetBoolean added in v0.9.1

func (j *OCCAJson) GetBoolean() bool

GetBoolean returns the boolean value

func (*OCCAJson) GetNumber added in v0.9.1

func (j *OCCAJson) GetNumber(typeFlag int) interface{}

GetNumber returns the number value

func (*OCCAJson) GetString added in v0.9.1

func (j *OCCAJson) GetString() string

GetString returns the string value

func (*OCCAJson) IsArray added in v0.9.1

func (j *OCCAJson) IsArray() bool

IsArray checks if JSON value is an array

func (*OCCAJson) IsBoolean added in v0.9.1

func (j *OCCAJson) IsBoolean() bool

IsBoolean checks if JSON value is a boolean

func (*OCCAJson) IsNumber added in v0.9.1

func (j *OCCAJson) IsNumber() bool

IsNumber checks if JSON value is a number

func (*OCCAJson) IsObject added in v0.9.1

func (j *OCCAJson) IsObject() bool

IsObject checks if JSON value is an object

func (*OCCAJson) IsString added in v0.9.1

func (j *OCCAJson) IsString() bool

IsString checks if JSON value is a string

func (*OCCAJson) ObjectGet added in v0.9.1

func (j *OCCAJson) ObjectGet(key string, defaultValue interface{}) interface{}

ObjectGet gets a value from JSON object

func (*OCCAJson) ObjectHas added in v0.9.1

func (j *OCCAJson) ObjectHas(key string) bool

ObjectHas checks if JSON object has a key

func (*OCCAJson) ObjectSet added in v0.9.1

func (j *OCCAJson) ObjectSet(key string, value interface{}) error

ObjectSet sets a value in JSON object

func (*OCCAJson) Write added in v0.9.1

func (j *OCCAJson) Write(filename string)

Write writes JSON to a file

type OCCAKernel

type OCCAKernel struct {
	// contains filtered or unexported fields
}

func BuildKernel added in v0.9.1

func BuildKernel(filename, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernel builds a kernel from source file

func BuildKernelFromBinary added in v0.9.1

func BuildKernelFromBinary(filename, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernelFromBinary builds a kernel from binary file

func BuildKernelFromString added in v0.9.1

func BuildKernelFromString(source, kernelName string, props *OCCAJson) (*OCCAKernel, error)

BuildKernelFromString builds a kernel from source string

func (*OCCAKernel) BinaryFilename added in v0.9.1

func (k *OCCAKernel) BinaryFilename() string

BinaryFilename returns the binary filename

func (*OCCAKernel) ClearArgs added in v0.9.1

func (k *OCCAKernel) ClearArgs()

ClearArgs clears all kernel arguments

func (*OCCAKernel) Free

func (k *OCCAKernel) Free()

Free frees the kernel

func (*OCCAKernel) FullHash added in v0.9.1

func (k *OCCAKernel) FullHash() string

FullHash returns the full kernel hash

func (*OCCAKernel) GetDevice added in v0.9.1

func (k *OCCAKernel) GetDevice() *OCCADevice

GetDevice returns the device associated with the kernel

func (*OCCAKernel) GetProperties added in v0.9.1

func (k *OCCAKernel) GetProperties() *OCCAJson

GetProperties returns kernel properties

func (*OCCAKernel) Hash added in v0.9.1

func (k *OCCAKernel) Hash() string

Hash returns the kernel hash

func (*OCCAKernel) IsInitialized added in v0.9.1

func (k *OCCAKernel) IsInitialized() bool

IsInitialized checks if the kernel is initialized

func (*OCCAKernel) MaxDims added in v0.9.1

func (k *OCCAKernel) MaxDims() int

MaxDims returns the maximum dimensions

func (*OCCAKernel) MaxInnerDims added in v0.9.1

func (k *OCCAKernel) MaxInnerDims() OCCADim

MaxInnerDims returns the maximum inner dimensions

func (*OCCAKernel) MaxOuterDims added in v0.9.1

func (k *OCCAKernel) MaxOuterDims() OCCADim

MaxOuterDims returns the maximum outer dimensions

func (*OCCAKernel) Name added in v0.9.1

func (k *OCCAKernel) Name() string

Name returns the kernel name

func (*OCCAKernel) PushArg added in v0.9.1

func (k *OCCAKernel) PushArg(arg interface{}) error

PushArg pushes an argument to the kernel

func (*OCCAKernel) Run

func (k *OCCAKernel) Run(args ...interface{})

For backward compatibility or if you prefer panic over error return

func (*OCCAKernel) RunFromArgs added in v0.9.1

func (k *OCCAKernel) RunFromArgs()

RunFromArgs runs the kernel with previously pushed arguments

func (*OCCAKernel) RunWithArgs

func (k *OCCAKernel) RunWithArgs(args ...interface{}) error

RunWithArgs runs the kernel with arbitrary arguments using occaKernelRunWithArgs

func (*OCCAKernel) SetRunDims added in v0.9.1

func (k *OCCAKernel) SetRunDims(outerDims, innerDims OCCADim)

SetRunDims sets the run dimensions

func (*OCCAKernel) SourceFilename added in v0.9.1

func (k *OCCAKernel) SourceFilename() string

SourceFilename returns the source filename

type OCCAMemory

type OCCAMemory struct {
	// contains filtered or unexported fields
}

func Malloc added in v0.9.1

func Malloc(bytes int64, src unsafe.Pointer, props *OCCAJson) *OCCAMemory

Malloc allocates memory on the current device

func TypedMalloc added in v0.9.1

func TypedMalloc(entries int64, dtype *OCCADtype, src unsafe.Pointer, props *OCCAJson) *OCCAMemory

TypedMalloc allocates typed memory on the current device

func TypedWrapMemory added in v0.9.1

func TypedWrapMemory(ptr unsafe.Pointer, entries int64, dtype *OCCADtype, props *OCCAJson) *OCCAMemory

TypedWrapMemory wraps existing typed memory

func WrapMemory added in v0.9.1

func WrapMemory(ptr unsafe.Pointer, bytes int64, props *OCCAJson) *OCCAMemory

WrapMemory wraps existing memory

func (*OCCAMemory) Clone added in v0.9.1

func (m *OCCAMemory) Clone() *OCCAMemory

Clone creates a copy of the memory

func (*OCCAMemory) CopyDeviceToDevice

func (dst *OCCAMemory) CopyDeviceToDevice(dstOffset int64, src *OCCAMemory, srcOffset int64, bytes int64)

CopyDeviceToDevice performs an efficient device-to-device memory copy

func (*OCCAMemory) CopyDeviceToDeviceWithProps added in v0.9.1

func (dst *OCCAMemory) CopyDeviceToDeviceWithProps(dstOffset int64, src *OCCAMemory, srcOffset int64, bytes int64, props *OCCAJson)

CopyDeviceToDeviceWithProps performs device-to-device copy with properties

func (*OCCAMemory) CopyFrom

func (m *OCCAMemory) CopyFrom(src unsafe.Pointer, bytes int64)

CopyFrom copies data from host memory to device memory

func (*OCCAMemory) CopyFromFloat32 added in v0.9.1

func (m *OCCAMemory) CopyFromFloat32(data []float32)

CopyFromFloat32 copies float32 slice to device memory

func (*OCCAMemory) CopyFromFloat64 added in v0.9.1

func (m *OCCAMemory) CopyFromFloat64(data []float64)

CopyFromFloat64 copies float64 slice to device memory

func (*OCCAMemory) CopyFromInt32 added in v0.9.1

func (m *OCCAMemory) CopyFromInt32(data []int32)

CopyFromInt32 copies int32 slice to device memory

func (*OCCAMemory) CopyFromInt64 added in v0.9.1

func (m *OCCAMemory) CopyFromInt64(data []int64)

CopyFromInt64 copies int64 slice to device memory

func (*OCCAMemory) CopyFromWithOffset added in v0.9.1

func (m *OCCAMemory) CopyFromWithOffset(src unsafe.Pointer, bytes int64, offset int64)

CopyFromWithOffset copies data from host memory to device memory with offset

func (*OCCAMemory) CopyFromWithProps added in v0.9.1

func (m *OCCAMemory) CopyFromWithProps(src unsafe.Pointer, bytes int64, offset int64, props *OCCAJson)

CopyFromWithProps copies data from host memory to device memory with properties

func (*OCCAMemory) CopyTo

func (m *OCCAMemory) CopyTo(dst unsafe.Pointer, bytes int64)

CopyTo copies data from device memory to host memory

func (*OCCAMemory) CopyToFloat32

func (m *OCCAMemory) CopyToFloat32(data []float32)

CopyToFloat32 copies memory to float32 slice

func (*OCCAMemory) CopyToFloat64 added in v0.9.1

func (m *OCCAMemory) CopyToFloat64(data []float64)

CopyToFloat64 copies memory to float64 slice

func (*OCCAMemory) CopyToInt32 added in v0.9.1

func (m *OCCAMemory) CopyToInt32(data []int32)

CopyToInt32 copies memory to int32 slice

func (*OCCAMemory) CopyToInt64 added in v0.9.1

func (m *OCCAMemory) CopyToInt64(data []int64)

CopyToInt64 copies memory to int64 slice

func (*OCCAMemory) CopyToWithOffset added in v0.9.1

func (m *OCCAMemory) CopyToWithOffset(dst unsafe.Pointer, bytes int64, offset int64)

CopyToWithOffset copies data from device memory to host memory with offset

func (*OCCAMemory) CopyToWithProps added in v0.9.1

func (m *OCCAMemory) CopyToWithProps(dst unsafe.Pointer, bytes int64, offset int64, props *OCCAJson)

CopyToWithProps copies data from device memory to host memory with properties

func (*OCCAMemory) Detach added in v0.9.1

func (m *OCCAMemory) Detach()

Detach detaches the memory

func (*OCCAMemory) Free

func (m *OCCAMemory) Free()

Free frees the device memory

func (*OCCAMemory) GetDevice added in v0.9.1

func (m *OCCAMemory) GetDevice() *OCCADevice

GetDevice returns the device associated with the memory

func (*OCCAMemory) GetProperties added in v0.9.1

func (m *OCCAMemory) GetProperties() *OCCAJson

GetProperties returns memory properties

func (*OCCAMemory) IsInitialized added in v0.9.1

func (m *OCCAMemory) IsInitialized() bool

IsInitialized checks if the memory is initialized

func (*OCCAMemory) Ptr added in v0.9.1

func (m *OCCAMemory) Ptr() unsafe.Pointer

Ptr returns the underlying memory pointer

func (*OCCAMemory) Size added in v0.9.1

func (m *OCCAMemory) Size() uint64

Size returns the size of the memory in bytes

func (*OCCAMemory) Slice added in v0.9.1

func (m *OCCAMemory) Slice(offset, bytes int64) *OCCAMemory

Slice creates a slice of the memory

type OCCAMemoryPool added in v0.9.1

type OCCAMemoryPool struct {
	// contains filtered or unexported fields
}

func CreateMemoryPool added in v0.9.1

func CreateMemoryPool(props *OCCAJson) *OCCAMemoryPool

CreateMemoryPool creates a new memory pool

func (*OCCAMemoryPool) Alignment added in v0.9.1

func (p *OCCAMemoryPool) Alignment() uint64

Alignment returns the memory alignment

func (*OCCAMemoryPool) Free added in v0.9.1

func (p *OCCAMemoryPool) Free()

Free frees the memory pool

func (*OCCAMemoryPool) GetDevice added in v0.9.1

func (p *OCCAMemoryPool) GetDevice() *OCCADevice

GetDevice returns the device associated with the memory pool

func (*OCCAMemoryPool) GetProperties added in v0.9.1

func (p *OCCAMemoryPool) GetProperties() *OCCAJson

GetProperties returns memory pool properties

func (*OCCAMemoryPool) IsInitialized added in v0.9.1

func (p *OCCAMemoryPool) IsInitialized() bool

IsInitialized checks if the memory pool is initialized

func (*OCCAMemoryPool) NumReservations added in v0.9.1

func (p *OCCAMemoryPool) NumReservations() uint64

NumReservations returns the number of reservations

func (*OCCAMemoryPool) Reserve added in v0.9.1

func (p *OCCAMemoryPool) Reserve(bytes uint64) *OCCAMemory

Reserve reserves memory from the pool

func (*OCCAMemoryPool) Reserved added in v0.9.1

func (p *OCCAMemoryPool) Reserved() uint64

Reserved returns the amount of reserved memory

func (*OCCAMemoryPool) Resize added in v0.9.1

func (p *OCCAMemoryPool) Resize(bytes uint64)

Resize resizes the memory pool

func (*OCCAMemoryPool) SetAlignment added in v0.9.1

func (p *OCCAMemoryPool) SetAlignment(alignment uint64)

SetAlignment sets the memory alignment

func (*OCCAMemoryPool) ShrinkToFit added in v0.9.1

func (p *OCCAMemoryPool) ShrinkToFit()

ShrinkToFit shrinks the memory pool to fit current reservations

func (*OCCAMemoryPool) Size added in v0.9.1

func (p *OCCAMemoryPool) Size() uint64

Size returns the total size of the memory pool

func (*OCCAMemoryPool) TypedReserve added in v0.9.1

func (p *OCCAMemoryPool) TypedReserve(entries uint64, dtype *OCCADtype) *OCCAMemory

TypedReserve reserves typed memory from the pool

type OCCAStream added in v0.9.1

type OCCAStream struct {
	// contains filtered or unexported fields
}

func CreateStream added in v0.9.1

func CreateStream(props *OCCAJson) *OCCAStream

CreateStream creates a new stream with optional properties

func GetStream added in v0.9.1

func GetStream() *OCCAStream

GetStream returns the current stream

func (*OCCAStream) Free added in v0.9.1

func (s *OCCAStream) Free()

Free frees the stream

type OCCAStreamTag added in v0.9.1

type OCCAStreamTag struct {
	// contains filtered or unexported fields
}

func TagStream added in v0.9.1

func TagStream() *OCCAStreamTag

TagStream tags the current position in the stream

Directories

Path Synopsis
examples
halo
mesh_halo2.go - Production code
mesh_halo2.go - Production code
hello_world command

Jump to

Keyboard shortcuts

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