Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Last active December 16, 2015 22:39
Show Gist options
  • Save snipsnipsnip/5508557 to your computer and use it in GitHub Desktop.
Save snipsnipsnip/5508557 to your computer and use it in GitHub Desktop.
なんか落ちる (GoでOpenCLテスト)
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