forked from mumax/3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
50 lines (43 loc) · 2.22 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package curand
//#include <curand.h>
import "C"
import (
"fmt"
)
type Status int
const (
SUCCESS Status = C.CURAND_STATUS_SUCCESS // No errors
VERSION_MISMATCH Status = C.CURAND_STATUS_VERSION_MISMATCH // Header file and linked library version do not match
NOT_INITIALIZED Status = C.CURAND_STATUS_NOT_INITIALIZED // Generator not initialized
ALLOCATION_FAILED Status = C.CURAND_STATUS_ALLOCATION_FAILED // Memory allocation failed
TYPE_ERROR Status = C.CURAND_STATUS_TYPE_ERROR // Generator is wrong type
OUT_OF_RANGE Status = C.CURAND_STATUS_OUT_OF_RANGE // Argument out of range
LENGTH_NOT_MULTIPLE Status = C.CURAND_STATUS_LENGTH_NOT_MULTIPLE // Length requested is not a multple of dimension
LAUNCH_FAILURE Status = C.CURAND_STATUS_LAUNCH_FAILURE // Kernel launch failure
PREEXISTING_FAILURE Status = C.CURAND_STATUS_PREEXISTING_FAILURE // Preexisting failure on library entry
INITIALIZATION_FAILED Status = C.CURAND_STATUS_INITIALIZATION_FAILED // Initialization of CUDA failed
ARCH_MISMATCH Status = C.CURAND_STATUS_ARCH_MISMATCH // Architecture mismatch, GPU does not support requested feature
INTERNAL_ERROR Status = C.CURAND_STATUS_INTERNAL_ERROR // Internal library error
)
func (s Status) String() string {
if str, ok := statusStr[s]; ok {
return str
} else {
return fmt.Sprint("CURAND ERROR NUMBER ", int(s))
}
}
var statusStr = map[Status]string{
SUCCESS: "CURAND_STATUS_SUCCESS",
VERSION_MISMATCH: "CURAND_STATUS_VERSION_MISMATCH",
NOT_INITIALIZED: "CURAND_STATUS_NOT_INITIALIZED",
ALLOCATION_FAILED: "CURAND_STATUS_ALLOCATION_FAILED",
TYPE_ERROR: "CURAND_STATUS_TYPE_ERROR",
OUT_OF_RANGE: "CURAND_STATUS_OUT_OF_RANGE",
LENGTH_NOT_MULTIPLE: "CURAND_STATUS_LENGTH_NOT_MULTIPLE",
LAUNCH_FAILURE: "CURAND_STATUS_LAUNCH_FAILURE",
PREEXISTING_FAILURE: "CURAND_STATUS_PREEXISTING_FAILURE",
INITIALIZATION_FAILED: "CURAND_STATUS_INITIALIZATION_FAILED",
ARCH_MISMATCH: "CURAND_STATUS_ARCH_MISMATCH",
INTERNAL_ERROR: "CURAND_STATUS_INTERNAL_ERROR",
}
// Documentation was taken from the curand headers.