cuda

command
v0.0.0-...-a20b597 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2015 License: GPL-3.0, BSD-3-Clause Imports: 7 Imported by: 0

README

CUDA bindings for Go
--------------------

This package provides Go bindings for nVIDIA CUDA.
Access is provided to the low-level functionality,
together with high-level (more idiomatic Go) functions.

Low-level usage example:

	import "cuda"

	runtime.LockOSThread()              // cuda contexts are tied to OS threads
	pointer := cuda.Malloc(4 * 1024)    // low-level memory allocation
	cuda.Free(pointer)                  // low level free


High-level usage example:

	import "cuda"

	runtime.LockOSThread()                   // cuda contexts are tied to OS threads
	deviceArray := cuda.NewArray(1024, 4)    // space for 1024 float32's
	hostArray := make([]float32, 1024)
	cuda.Copy(deviceArray, hostArray)        // copy from host to device
	cuda.Copy(hostArray, deviceArray)        // copy from device to host
	deviceArray.Free()


CUDA error statuses are checked automatically and passed to panic() when not successful.
Also, return values are returned directly, and not via a pointer passed as function argument.
E.g.:

The C code:
	void *ptr;
	cudaError_t error = cudaMalloc(&ptr, 1024);
	if(error != cudaSuccess){
		fprintf(stderr, cudaErrorString(error))
		abort()
	}

Becomes in Go:

	ptr := cuda.Malloc(1024)


Installation
------------

* To use this package, the CUDA SDK must be installed.
  It has been tested with CUDA 4.0 on Linux. See:
	http://developer.nvidia.com/object/cuda_3_2_downloads.html

* Have a look at cuda/Makefile.
  The Makefile assumes that the header files (cuda.h and friends) are located in:
  	/usr/local/cuda/include.
  and that the libraries (cudart.so and friends) are locted in:
	/usr/local/cuda/lib  /usr/local/cuda/lib64
  Check that this applicable for your system and change these paths if neccesarey.

* Finally:
	cd cuda/
	make install


Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Go bindings for the CUDA CUFFT API.
Go bindings for the CUDA CUFFT API.
Go bindings for the CUDA CURAND API.
Go bindings for the CUDA CURAND API.
Go bindings for the CUDA driver API.
Go bindings for the CUDA driver API.
CUDA runtime bindings for Go.
CUDA runtime bindings for Go.

Jump to

Keyboard shortcuts

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