blaspy 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ include README.md
2
+
3
+ include *.c
4
+ include *.h
5
+ include Makefile
blaspy-0.0.4/Makefile ADDED
@@ -0,0 +1,101 @@
1
+ # Makefile de BLApy.
2
+ #
3
+ # Filosofía de flags (mismo criterio documentado en bla_gemm.c y en el
4
+ # README, sección de diseño): -O3 SIEMPRE, pero SIN -march=native por
5
+ # defecto -- la detección de SIMD es en runtime (ver bla_simd.c), así
6
+ # que un binario compilado acá funciona igual en cualquier CPU x86_64
7
+ # donde se instale después, no solo en la máquina donde se compiló.
8
+ # Esto es intencional y calca la misma decisión que numerx documenta
9
+ # en su propio setup.py.
10
+ #
11
+ # Si querés exprimir el último 5-10% en TU máquina puntual (a costa de
12
+ # portabilidad), corré: make native
13
+ #
14
+ CC := gcc
15
+ CFLAGS := -O3 -Wall -Wextra -std=c11
16
+ LDLIBS := -lm
17
+
18
+ LIB_SRCS := bla_gemm.c bla_microkernel.c bla_level1.c bla_level2.c bla_simd.c \
19
+ bla_level1_f32.c bla_gemm_f32.c bla_microkernel_f32.c bla_level2_f32.c
20
+ LIB_OBJS := $(LIB_SRCS:.c=.o)
21
+
22
+ .PHONY: all test bench clean native lib test-arm64
23
+
24
+ all: lib test
25
+
26
+ lib: libbla.so
27
+
28
+ libbla.so: $(LIB_SRCS) bla.h bla_internal.h bla_microkernel.h bla_microkernel_f32.h
29
+ $(CC) $(CFLAGS) -fPIC -shared $(LIB_SRCS) $(LDLIBS) -o $@
30
+ cp $@ python/$@
31
+
32
+ native: CFLAGS += -march=native
33
+ native: clean lib
34
+ @echo "Compilado con -march=native -- este .so es específico de ESTA CPU, no lo distribuyas."
35
+
36
+ test: test_level1 test_gemv test_ger test_gemm test_gemm_trans test_level1_f32 test_gemm_f32 test_gemv_f32
37
+ @echo "--- nivel 1 ---"
38
+ ./test_level1
39
+ @echo "--- gemv (nivel 2) ---"
40
+ ./test_gemv
41
+ @echo "--- ger (nivel 2) ---"
42
+ ./test_ger
43
+ @echo "--- gemm (nivel 3) ---"
44
+ ./test_gemm
45
+ @echo "--- gemm_tn / gemm_nt (nivel 3, añadido en 0.0.2) ---"
46
+ ./test_gemm_trans
47
+ @echo "--- sdot/saxpy/sscal, float32 nivel 1 (sdot en 0.0.3, saxpy/sscal en 0.0.4) ---"
48
+ ./test_level1_f32
49
+ @echo "--- sgemm, float32 nivel 3 (añadido en 0.0.3) ---"
50
+ ./test_gemm_f32
51
+ @echo "--- sgemv, float32 nivel 2 (añadido en 0.0.4) ---"
52
+ ./test_gemv_f32
53
+
54
+ test_level1: tests/test_level1.c bla_level1.c bla_simd.c bla.h
55
+ $(CC) $(CFLAGS) -I. tests/test_level1.c bla_level1.c bla_simd.c $(LDLIBS) -o $@
56
+
57
+ test_gemv: tests/test_gemv.c bla_level2.c bla_level1.c bla_simd.c bla.h
58
+ $(CC) $(CFLAGS) -I. tests/test_gemv.c bla_level2.c bla_level1.c bla_simd.c $(LDLIBS) -o $@
59
+
60
+ test_ger: tests/test_ger.c bla_level2.c bla_level1.c bla_simd.c bla.h
61
+ $(CC) $(CFLAGS) -I. tests/test_ger.c bla_level2.c bla_level1.c bla_simd.c $(LDLIBS) -o $@
62
+
63
+ test_gemm: tests/test_gemm.c bla_gemm.c bla_microkernel.c bla_simd.c bla.h
64
+ $(CC) $(CFLAGS) -I. tests/test_gemm.c bla_gemm.c bla_microkernel.c bla_simd.c $(LDLIBS) -o $@
65
+
66
+ test_gemm_trans: tests/test_gemm_trans.c bla_gemm.c bla_microkernel.c bla_simd.c bla.h
67
+ $(CC) $(CFLAGS) -I. tests/test_gemm_trans.c bla_gemm.c bla_microkernel.c bla_simd.c $(LDLIBS) -o $@
68
+
69
+ test_level1_f32: tests/test_level1_f32.c bla_level1_f32.c bla_simd.c bla.h
70
+ $(CC) $(CFLAGS) -I. tests/test_level1_f32.c bla_level1_f32.c bla_simd.c $(LDLIBS) -o $@
71
+
72
+ test_gemm_f32: tests/test_gemm_f32.c bla_gemm_f32.c bla_microkernel_f32.c bla_simd.c bla.h
73
+ $(CC) $(CFLAGS) -I. tests/test_gemm_f32.c bla_gemm_f32.c bla_microkernel_f32.c bla_simd.c $(LDLIBS) -o $@
74
+
75
+ test_gemv_f32: tests/test_gemv_f32.c bla_level2_f32.c bla_level1_f32.c bla_simd.c bla.h
76
+ $(CC) $(CFLAGS) -I. tests/test_gemv_f32.c bla_level2_f32.c bla_level1_f32.c bla_simd.c $(LDLIBS) -o $@
77
+
78
+ # Corre la misma suite de tests, pero en un binario ARM64 real (vía
79
+ # cross-compiler + QEMU user-mode) -- ver tests/run_arm64_tests.sh
80
+ # para el detalle y requisitos. Uso:
81
+ # make test-arm64 ARM_TOOLCHAIN=/ruta/al/toolchain ARM_QEMU=/ruta/a/qemu-aarch64
82
+ test-arm64:
83
+ tests/run_arm64_tests.sh "$(ARM_TOOLCHAIN)" "$(ARM_QEMU)"
84
+
85
+ bench: lib
86
+ python3 bench/compare_numerx.py
87
+
88
+ # Mide bla_gemm forzando cada nivel SIMD (avx512/avx2/sse2/none), sin
89
+ # necesitar hardware distinto -- ver bench/bla_simd_forced.c. Este
90
+ # binario usa bla_gemm.c/bla_microkernel.c/bla_level1.c/bla_level2.c
91
+ # REALES (el mismo código que libbla.so), solo con la detección de
92
+ # CPU reemplazada por la variable de entorno BLA_FORCE_SIMD.
93
+ bench-forced: bench/bench_forced.c bench/bla_simd_forced.c bla_gemm.c bla_microkernel.c bla_level1.c bla_level2.c
94
+ $(CC) $(CFLAGS) -I. bench/bench_forced.c bla_gemm.c bla_microkernel.c bla_level1.c bla_level2.c bench/bla_simd_forced.c $(LDLIBS) -o $@
95
+ @echo "--- avx512 ---"; BLA_FORCE_SIMD=avx512 ./$@
96
+ @echo "--- avx2 ---"; BLA_FORCE_SIMD=avx2 ./$@
97
+ @echo "--- sse2 ---"; BLA_FORCE_SIMD=sse2 ./$@
98
+ @echo "--- none ---"; BLA_FORCE_SIMD=none ./$@
99
+
100
+ clean:
101
+ rm -f *.o *.so python/*.so test_level1 test_gemv test_ger test_gemm test_gemm_trans test_level1_f32 test_gemm_f32 test_gemv_f32 bench-forced