-
Notifications
You must be signed in to change notification settings - Fork 2
/
sample.go
28 lines (23 loc) · 860 Bytes
/
sample.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
package main
import (
"fmt"
"ocl"
)
func main() {
kernelSrc := "__kernel void hello(void) {}"
fmt.Printf("go OpenCL example\n")
platformsNum := ocl.PlatformsNumber()
fmt.Printf("Platforms in system %d\n", platformsNum)
platforms := ocl.Platforms(platformsNum)
for i := 0; i < len(platforms); i++ {
fmt.Printf("%d :: %s\n", i, platforms[i].Info(ocl.CL_PLATFORM_PROFILE))
fmt.Printf(" :: %s\n", platforms[i].Info(ocl.CL_PLATFORM_VERSION))
fmt.Printf(" :: %s\n", platforms[i].Info(ocl.CL_PLATFORM_NAME))
fmt.Printf(" :: %s\n", platforms[i].Info(ocl.CL_PLATFORM_VENDOR))
fmt.Printf(" :: %s\n", platforms[i].Info(ocl.CL_PLATFORM_EXTENSIONS))
}
ctx := ocl.CreateContext(&platforms[0], ocl.CL_DEVICE_TYPE_GPU)
program := ocl.CreateProgram(ctx, []string{kernelSrc})
helloKernel := ocl.CreateKernel(program, "hello")
helloKernel.Foo()
}