Last active
December 16, 2015 22:39
-
-
Save snipsnipsnip/5508557 to your computer and use it in GitHub Desktop.
なんか落ちる (GoでOpenCLテスト)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// #include "CL/opencl.h" | |
// #cgo LDFLAGS: -lOpenCL | |
import "C" | |
import ( | |
"log" | |
"unsafe" | |
) | |
func main() { | |
var id C.cl_platform_id | |
err := C.clGetPlatformIDs(1, &id, nil) | |
if err != C.CL_SUCCESS { | |
log.Fatal("GetPlatformIDs Error code %d", err) | |
} | |
c := C.clCreateContextFromType(&[]C.cl_context_properties{ | |
C.CL_CONTEXT_PLATFORM, | |
C.cl_context_properties(uintptr(unsafe.Pointer(id))), | |
0, | |
}[0], C.CL_DEVICE_TYPE_GPU, nil, nil, &err) | |
if err != C.CL_SUCCESS { | |
log.Fatal("createContext Error code %d", err) | |
} | |
defer C.clReleaseContext(c) | |
log.Println(c, err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment