-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (91 loc) · 3.75 KB
/
Makefile
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# matrico Makefile
TAR = tar # homebrew: gtar
SED = sed # homebrew: gsed
CSC = csc
CSI = csi
CHICKEN_INSTALL = chicken-install
CHICKEN_PROFILE = chicken-profile
TEST_NEW_EGG = test-new-egg # homebrew: /opt/homebrew/Cellar/chicken/5.4.0/bin/test-new-egg
CLARG =
LEVEL = -O3
DEBUG = -d0
override FLAGS += -strict-types -C -O2 -C -pipe
VERSION = $(shell csi -b version.scm -p "(matrico-version)")
DIM = 1000
.PHONY: mips, linpack, matmul
default:
$(CSC) -shared -emit-import-library matrico $(LEVEL) $(DEBUG) $(FLAGS) matrico.scm
test:
$(CSI) tests/run.scm
test_egg_local:
$(TAR) cvzf matrico-$(VERSION).tar.gz --transform 's,^,matrico/,' \
AUTHORS CITATION.cff LICENSE README.md \
matrico.egg matrico.release-info res/matrico-logo.svg \
matrico.scm RUNME.sh version.scm \
src/dense.scm src/f64vector.scm src/fpmath.scm src/matrix.scm src/mx.scm src/utils.scm \
tests/check.scm tests/run.scm tests/test-f64vector.scm tests/test-fpmath.scm tests/test-matrico.scm tests/test-utils.scm
python3 -m http.server --bind 127.0.0.1 &
sleep 1
$(SED) -e '3 c\(uri targz \"http://0.0.0.0:8000/{egg-name}-{egg-release}.tar.gz\")' matrico.release-info > matrico-dev.release-info
$(TEST_NEW_EGG) matrico http://0.0.0.0:8000/matrico-dev.release-info
pkill -9 -f 'python3 -m http.server'
rm matrico-dev.release-info
test_egg_remote:
$(TEST_NEW_EGG) matrico https://raw.githubusercontent.com/gramian/matrico/main/matrico.release-info
test_install:
CHICKEN_INSTALL_REPOSITORY="/tmp/matrico" $(CHICKEN_INSTALL) -test
CHICKEN_REPOSITORY_PATH="/tmp/matrico:`$(CHICKEN_INSTALL) -repository`" $(CSI) -e "(import matrico) (matrico 'citation)"
iprofile:
make linpack LEVEL='-O3' FLAGS='-profile' DIM=1000
ls -1 PROFILE.* | sort -n | head -n1 | $(CHICKEN_PROFILE)
sprofile:
make linpack LEVEL='-O4' DEBUG='-d3' DIM=1000 CLARG='-:P1000'
ls -1 PROFILE.* | sort -n | head -n1 | $(CHICKEN_PROFILE)
mips:LEVEL=-O5
mips:
@echo "(include \"matrico.scm\") \
(import matrico) \
(print "BogoMips:" #\space (matrico 'benchmark)) \
(newline) \
(exit)" | $(CSC) $(LEVEL) $(FLAGS) - -o /tmp/mips
@/tmp/mips
matmul:LEVEL=-O5
matmul:
@echo "(include \"matrico.scm\") \
(import matrico) \
(import (chicken time)) \
(define A (mx-random $(DIM) $(DIM) -1.0 1.0)) \
(define B (mx-random $(DIM) $(DIM) -1.0 1.0)) \
(define t0 (current-process-milliseconds)) \
(define C (time (mx-dot* A B))) \
(define t1 (current-process-milliseconds)) \
(print "Megaflops:" #\space (inexact->exact (floor (/ (* $(DIM) $(DIM) $(DIM)) (* (- t1 t0) 1000.0))))) \
(newline) \
(exit)" | $(CSC) $(LEVEL) $(FLAGS) - -o /tmp/matmul
@/tmp/matmul $(CLARG) 2> matmul.txt
@cat matmul.txt
linpack:LEVEL=-O5
linpack:
@echo "(include \"matrico.scm\") \
(import matrico) \
(import (chicken time)) \
(define A (mx-random $(DIM) $(DIM) -1.0 1.0)) \
(define b (mx-rowsum A)) \
(define t0 (current-process-milliseconds)) \
(define solver (time (mx-solver A))) \
(define t1 (current-process-milliseconds)) \
(print "Megaflops:" #\space (inexact->exact (floor (/ (* $(DIM) $(DIM) $(DIM)) (* (- t1 t0) 1000.0))))) \
(print "Residual:" #\space (mx-norm (mx- (solver b) 1.0) 2)) \
(newline) \
(exit)" | $(CSC) $(LEVEL) $(FLAGS) - -o /tmp/linpack
@/tmp/linpack $(CLARG) 2> linpack.txt
@cat linpack.txt
heat:
csi -b demos/heat.scm
flame:
csi -b demos/flame.scm
clean:
rm -f test.csv test.mx linpack.txt matmul.txt \
matrico.so *.import.scm *.import.so matrico.static.o \
matrico.build.sh matrico.install.sh matrico.link matrico.static.so \
matrico-$(VERSION).tar.gz PROFILE.* heat.csv flame.csv