-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
42 lines (33 loc) · 919 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 LDFLAGS: -framework Foundation -framework Metal -framework MetalPerformanceShaders -framework CoreGraphics -L/opt/homebrew/opt/openblas/lib -L/usr/local/opt/openblas/lib -L/usr/lib -lopenblas
*/
import "C"
import (
_ "embed"
"flag"
"fmt"
"os"
"strconv"
)
const DEFAULT_INCREMENT = 100
//go:embed mm.metal
var source string
func main() {
incrValue := DEFAULT_INCREMENT
fastFlag := flag.Bool("fast", false, "Enable fast mode")
gpuOnlyFlag := flag.Bool("gpu-only", false, "Use GPU only")
incrFlag := flag.String("incr", "", "Incremental integer value")
flag.Parse()
if *incrFlag != "" {
v, err := strconv.Atoi(*incrFlag)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: Invalid value for --incr: %s\n", *incrFlag)
os.Exit(1)
}
incrValue = v
}
Compile(source)
// Run benchmarking
TimeMultiplication(*fastFlag, *gpuOnlyFlag, incrValue)
}