-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (36 loc) · 884 Bytes
/
main.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
package main
/*
#cgo CFLAGS: -I.
#cgo LDFLAGS: -L. -lkernel
#cgo windows LDFLAGS:-LC:/bin
#cgo windows CFLAGS: -IC:/include
#include "kernel.h"
*/
import "C"
import "fmt"
func addWithCuda(c [][]C.float, a [][]C.float, b [][]C.float, size int, widthThread int) {
C.addWithCuda(c, a, b, C.uint(size), C.uint(widthThread))
}
func main() {
//cStr := C.CString("test string")
//C.sendMessage(cStr)
//defer C.free(unsafe.Pointer(cStr))
const x = 1000
const y = 1000
a := make([][]C.float, x)
b := make([][]C.float, x)
c := make([][]C.float, x)
for i := 0; i < x; i++ {
a[i] = make([]C.float, y)
b[i] = make([]C.float, y)
for j := 0; j < y; j++ {
a[i][j] = C.float(1.3923)
b[i][j] = C.float(2.4930)
}
}
// Add vectors in parallel.
addWithCuda(c, a, b, x, y)
fmt.Println(float64(a[9][0]))
fmt.Println(float64(b[9][0]))
fmt.Println(float64(c[9][0]))
}