2
2
3
3
CSC = csc
4
4
CSI = csi
5
+ CHICKEN_INSTALL = chicken-install
6
+ CHICKEN_PROFILE = chicken-profile
7
+ TEST_NEW_EGG = test-new-egg
5
8
9
+ CLARG =
6
10
LEVEL = -O4
7
- FLAGS = -d0 -C -O2 -C -pipe
11
+ DEBUG = -d0
12
+ override FLAGS += -C -O2 -C -pipe
8
13
9
14
VERSION = $(shell csi -b version.scm -p "(matrico-version) ")
10
15
11
16
DIM = 1000
12
17
13
- .PHONY : benchmark, linpack
18
+ .PHONY : linpack, matmul
14
19
15
20
default :
16
- $(CSC ) -shared -emit-import-library matrico $(LEVEL ) $(FLAGS ) matrico.scm
21
+ $(CSC ) -shared -emit-import-library matrico $(LEVEL ) $(DEBUG ) $( FLAGS ) matrico.scm
17
22
18
23
test :
19
24
$(CSI ) tests/run.scm
20
25
21
26
test_egg_local :
22
- tar cvzf matrico-$(VERSION ) .tar.gz \
23
- ../matrico/AUTHORS ../matrico/CITATION.cff ../matrico/LICENSE ../matrico/README.md \
24
- ../matrico/matrico.egg ../matrico/matrico.release-info ../matrico/matrico-logo.svg \
25
- ../matrico/matrico.scm ../matrico/RUNME.scm ../matrico/version.scm \
26
- ../matrico/src/dense.scm ../matrico/src/f64vector.scm ../matrico/src/fpmath.scm ../matrico/src/matrix.scm ../matrico/src/mx.scm ../matrico/src/utils.scm \
27
- ../matrico/tests/check.scm ../matrico/tests/run.scm ../matrico/tests/test-f64vector.scm ../matrico/tests/test-fpmath.scm ../matrico/tests/test-matrico.scm ../matrico/tests/test-utils.scm
28
- python3 -m http.server &
29
- test-new-egg matrico http://0.0.0.0:8000/matrico.release-info
27
+ tar cvzf matrico-$(VERSION ) .tar.gz --transform ' s,^,matrico/,' \
28
+ AUTHORS CITATION.cff LICENSE README.md \
29
+ matrico.egg matrico.release-info matrico-logo.svg \
30
+ matrico.scm RUNME.scm version.scm \
31
+ src/dense.scm src/f64vector.scm src/fpmath.scm src/matrix.scm src/mx.scm src/utils.scm \
32
+ tests/check.scm tests/run.scm tests/test-f64vector.scm tests/test-fpmath.scm tests/test-matrico.scm tests/test-utils.scm
33
+ python3 -m http.server --bind 127.0.0.1 &
34
+ sleep 1
35
+ $(TEST_NEW_EGG) matrico http://0.0.0.0:8000/matrico.release-info
36
+ pkill -9 -f 'python3 -m http.server'
30
37
31
38
test_egg_remote :
32
- test-new-egg matrico https://raw.githubusercontent.com/gramian/matrico/main/matrico.release-info
39
+ $( TEST_NEW_EGG ) matrico https://raw.githubusercontent.com/gramian/matrico/main/matrico.release-info
33
40
34
41
test_install :
35
- CHICKEN_INSTALL_REPOSITORY=" /tmp/matrico" chicken-install -test
36
- CHICKEN_REPOSITORY_PATH=" ` chicken-install -repository` :/tmp/matrico" $(CSI ) -e " (import matrico) (matrico-help)"
37
-
38
- benchmark :
39
- @rm -f benchmark.txt
40
- make benchset DIM=125
41
- make benchset DIM=250
42
- make benchset DIM=500
43
- make benchset DIM=1000
44
- @cat benchmark.txt
45
-
46
- benchset :
47
- @echo " ## $( DIM) :" >> benchmark.txt
48
- make benchrun LEVEL=' -O0'
49
- make benchrun LEVEL=' -O1'
50
- make benchrun LEVEL=' -O2'
51
- make benchrun LEVEL=' -O3'
52
- make benchrun LEVEL=' -O4'
53
- make benchrun LEVEL=' -O5'
54
-
55
- benchrun :
42
+ CHICKEN_INSTALL_REPOSITORY=" /tmp/matrico" $(CHICKEN_INSTALL ) -test
43
+ CHICKEN_REPOSITORY_PATH=" ` $( CHICKEN_INSTALL) -repository` :/tmp/matrico" $(CSI ) -e " (import matrico) (matrico-cite)"
44
+
45
+ iprofile :
46
+ make matmul LEVEL=' -O4' FLAGS=' -profile' DIM=1000
47
+ ls -1 PROFILE.* | sort -n | head -n1 | $(CHICKEN_PROFILE )
48
+
49
+ sprofile :
50
+ make matmul LEVEL=' -O4' DEBUG=' -d3' DIM=1000 CLARG=' -:P1000'
51
+ ls -1 PROFILE.* | sort -n | head -n1 | $(CHICKEN_PROFILE )
52
+
53
+ matmul:LEVEL =-O5
54
+ matmul :
56
55
@echo " (include \" matrico.scm\" ) \
57
56
(import matrico) \
58
- (time (mx-gram (mx-random $( DIM) $( DIM) -1.0 1.0))) \
59
- (exit)" | $( CSC) $( LEVEL) $( FLAGS) - -o /tmp/benchmark
60
- @/tmp/benchmark 2>> benchmark.txt
57
+ (import (chicken time)) \
58
+ (define A (mx-random $( DIM) $( DIM) -1.0 1.0)) \
59
+ (define B (mx-random $( DIM) $( DIM) -1.0 1.0)) \
60
+ (define t0 (current-seconds)) \
61
+ (define C (time (mx-dot* A B))) \
62
+ (define t1 (current-seconds)) \
63
+ (print " Megaflops:" # \space (/ (* $(DIM) $(DIM) $(DIM)) (* (- t1 t0) 1000.0 1000.0))) \
64
+ (newline) \
65
+ (exit)" | $( CSC) $( LEVEL) $( FLAGS) - -o /tmp/matmul
66
+ @/tmp/matmul $(CLARG ) 2> matmul.txt
67
+ @cat matmul.txt
61
68
69
+ linpack:LEVEL =-O5
62
70
linpack :
63
71
@echo " (include \" matrico.scm\" ) \
64
72
(import matrico) \
@@ -68,12 +76,16 @@ linpack:
68
76
(define t0 (current-seconds)) \
69
77
(define solver (time (mx-solver A))) \
70
78
(define t1 (current-seconds)) \
71
- (print " Megaflops/s :" # \space (/ (* $(DIM) $(DIM) $(DIM)) (* (- t1 t0) 1000.0 1000.0))) \
79
+ (print " Megaflops:" # \space (/ (* $(DIM) $(DIM) $(DIM)) (* (- t1 t0) 1000.0 1000.0))) \
72
80
(print " Residual:" # \space (mx-norm (mx- (solver b) 1.0) 2)) \
73
- (exit)" | $( CSC) -O5 $( FLAGS) - -o /tmp/linpack
74
- @/tmp/linpack 2> linpack.txt
81
+ (newline) \
82
+ (exit)" | $( CSC) $( LEVEL) $( FLAGS) - -o /tmp/linpack
83
+ @/tmp/linpack $(CLARG ) 2> linpack.txt
75
84
@cat linpack.txt
76
85
77
86
clean :
78
- rm -f benchmark.txt linpack.txt matrico.so matrico.import.scm matrico-$(VERSION ) .tar.gz
87
+ rm -f test.csv test.mx linpack.txt matmul.txt \
88
+ matrico.so matrico.import.scm matrico.import.so matrico.static.o \
89
+ matrico.build.sh matrico.install.sh matrico.link matrico.static.so \
90
+ matrico-$(VERSION ) .tar.gz
79
91
0 commit comments