-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
486 lines (423 loc) · 22.3 KB
/
Makefile
File metadata and controls
486 lines (423 loc) · 22.3 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
#* =============================================================================
#* CATOPY - CUDA Accelerated Tensor Operations
#* =============================================================================
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
PURPLE = \033[35m
CYAN = \033[36m
WHITE = \033[37m
BOLD = \033[1m
RESET = \033[0m
#* Variables del proyecto
PROJECT_NAME = cato
BUILD_DIR = build
PROFILING_PATH = tests/profiling/evidences
VENV_ACTIVATE = . .venv/bin/activate
#* =============================================================================
#* COMANDOS PRINCIPALES
#* =============================================================================
.PHONY: help all clean clean-all build install test test-unit test-cuda test-coverage test-watch
#* Comando por defecto - muestra ayuda
help:
@echo "$(BOLD)$(CYAN)============================================$(RESET)"
@echo "$(BOLD)$(CYAN) CATOPY - Makefile de Desarrollo$(RESET)"
@echo "$(BOLD)$(CYAN)============================================$(RESET)"
@echo ""
@echo "$(BOLD)$(GREEN)Comandos disponibles:$(RESET)"
@echo ""
@echo "$(BOLD)$(YELLOW) all$(RESET) - Ejecuta todo el flujo: configurar + compilar + instalar"
@echo "$(BOLD)$(YELLOW) test-all$(RESET) - Ejecuta todo + tests unitarios"
@echo "$(BOLD)$(YELLOW) install-dependencies$(RESET) - Instala dependencias del sistema (spdlog, CUDA, etc.)"
@echo "$(BOLD)$(YELLOW) config$(RESET) - Configura el proyecto con meson (solo primera vez o cambios de config)"
@echo "$(BOLD)$(YELLOW) build$(RESET) - Compila el código con ninja (después de cambios de código)"
@echo "$(BOLD)$(YELLOW) install$(RESET) - Instala el módulo compilado con uv pip"
@echo "$(BOLD)$(YELLOW) install-all$(RESET) - Instala todas las dependencias opcionales (test, dev, cuda)"
@echo "$(BOLD)$(YELLOW) test$(RESET) - Prueba el módulo instalado"
@echo ""
@echo "$(BOLD)$(CYAN)Testing por Tecnología:$(RESET)"
@echo "$(BOLD)$(YELLOW) test-frontend$(RESET) - Tests unitarios Python (pytest)"
@echo "$(BOLD)$(YELLOW) test-backend$(RESET) - Tests unitarios C++/CUDA"
@echo "$(BOLD)$(YELLOW) test-profiling$(RESET) - Tests de rendimiento Python"
@echo "$(BOLD)$(YELLOW) test-integration$(RESET) - Tests de integración Robot Framework"
@echo "$(BOLD)$(YELLOW) test-all$(RESET) - Todos los tests organizados"
@echo ""
@echo "$(BOLD)$(CYAN)Testing Especializado:$(RESET)"
@echo "$(BOLD)$(YELLOW) test-unit$(RESET) - Alias para test-frontend"
@echo "$(BOLD)$(YELLOW) test-cuda$(RESET) - Tests que requieren CUDA"
@echo "$(BOLD)$(YELLOW) test-coverage$(RESET) - Reporte de cobertura"
@echo "$(BOLD)$(YELLOW) test-fast$(RESET) - Tests rápidos (solo frontend)"
@echo "$(BOLD)$(YELLOW) test-watch$(RESET) - Tests en modo watch"
@echo "$(BOLD)$(YELLOW) test-file$(RESET) - Tests de archivo específico"
@echo ""
@echo "$(BOLD)$(CYAN)Benchmarking:$(RESET)"
@echo "$(BOLD)$(YELLOW) benchmark$(RESET) - Ejecuta todos los benchmarks"
@echo "$(BOLD)$(YELLOW) benchmark-operations$(RESET) - Benchmarks de operaciones básicas"
@echo "$(BOLD)$(YELLOW) benchmark-mathematical$(RESET) - Benchmarks de operaciones matemáticas"
@echo "$(BOLD)$(YELLOW) benchmark-clean$(RESET) - Limpia outputs de benchmarks"
@echo ""
@echo "$(BOLD)$(CYAN)Profiling:$(RESET)"
@echo "$(BOLD)$(YELLOW) profile-quick$(RESET) - Profiling rápido (operaciones básicas)"
@echo "$(BOLD)$(YELLOW) profile-full$(RESET) - Profiling completo (todas las trazas)"
@echo "$(BOLD)$(YELLOW) profile-memory$(RESET) - Profiling enfocado en memoria"
@echo "$(BOLD)$(YELLOW) profile-memory-transfer$(RESET) - Profiling específico para transferencias HOST↔GPU"
@echo "$(BOLD)$(YELLOW) profile-auto-open$(RESET) - Profiling + abre Nsight Systems automáticamente"
@echo "$(BOLD)$(YELLOW) profile-quick-open$(RESET) - Profiling rápido + abre Nsight Systems"
@echo "$(BOLD)$(YELLOW) profile-full-open$(RESET) - Profiling completo + abre Nsight Systems"
@echo "$(BOLD)$(YELLOW) profile-open$(RESET) - Abre último reporte de profiling"
@echo "$(BOLD)$(YELLOW) profile-list$(RESET) - Lista reportes disponibles"
@echo "$(BOLD)$(YELLOW) profile-clean$(RESET) - Limpia reportes de profiling"
@echo ""
@echo "$(BOLD)$(CYAN)Utilidades:$(RESET)"
@echo "$(BOLD)$(YELLOW) clean$(RESET) - Limpia archivos de build y residuos de Python"
@echo "$(BOLD)$(YELLOW) clean-all$(RESET) - Limpieza super agresiva (incluye .venv/)"
@echo "$(BOLD)$(YELLOW) rebuild$(RESET) - Limpia y recompila todo"
@echo "$(BOLD)$(YELLOW) quick$(RESET) - Compila + verifica (cambios frecuentes)"
@echo "$(BOLD)$(YELLOW) check$(RESET) - Solo compila (verificar que compila)"
@echo "$(BOLD)$(YELLOW) info$(RESET) - Muestra información del proyecto"
@echo ""
@echo "$(BOLD)$(BLUE)Flujo típico de desarrollo:$(RESET)"
@echo " 1. Primera vez en el sistema → make install-dependencies"
@echo " 2. Instalar dependencias opcionales → make install-all"
@echo " 3. Cambias código fuente → make build"
@echo " 4. Cambias configuración → make config"
@echo " 5. Quieres probar → make install"
@echo " 6. Ejecutar tests → make test-frontend"
@echo " 7. Todo desde cero → make all"
@echo " 8. Todo + tests → make test-all"
@echo " 9. Profiling → make profile-memory-transfer"
@echo " 10. Profiling + Nsight → make profile-auto-open"
@echo " 11. Desarrollo completo → make dev-profile"
@echo ""
#* Comando principal - ejecuta todo el flujo
all: config build install
@echo "$(BOLD)$(GREEN)Todo completado exitosamente!$(RESET)"
@echo "$(CYAN)El módulo $(BOLD)$(PROJECT_NAME)$(RESET)$(CYAN) está listo para usar.$(RESET)"
#* Comando completo con tests
test-all: config build install test-frontend test-backend test-profiling
@echo "$(BOLD)$(GREEN)Todo completado exitosamente con tests!$(RESET)"
@echo "$(CYAN)El módulo $(BOLD)$(PROJECT_NAME)$(RESET)$(CYAN) está listo y probado.$(RESET)"
#& =============================================================================
#& INSTALACIÓN DE DEPENDENCIAS DEL SISTEMA
#& =============================================================================
#* Instala todas las dependencias del sistema necesarias para el proyecto
install-dependencies:
@echo "$(BOLD)$(BLUE)Instalando dependencias del sistema...$(RESET)"
@echo "$(CYAN)Este paso instala spdlog, Google Test, CUDA y otras dependencias del sistema$(RESET)"
@echo "$(YELLOW)Se requiere sudo para instalar paquetes del sistema$(RESET)"
@sudo apt update
@sudo apt install -y libspdlog-dev libgtest-dev libgmock-dev
@echo "$(BOLD)$(GREEN)Dependencias del sistema instaladas$(RESET)"
@echo "$(CYAN)Ahora puedes ejecutar 'make config' para configurar el proyecto$(RESET)"
#& =============================================================================
#& CONFIGURACIÓN DEL PROYECTO
#& =============================================================================
#* Configura el proyecto con meson (solo cuando cambias configuración)
config: install-dependencies
@echo "$(BOLD)$(BLUE)Configurando proyecto con meson...$(RESET)"
@echo "$(CYAN)Este paso detecta compiladores, dependencias y genera archivos de configuración$(RESET)"
@$(VENV_ACTIVATE) && meson $(BUILD_DIR)
@echo "$(BOLD)$(GREEN)Configuración completada$(RESET)"
#& =============================================================================
#& COMPILACIÓN DEL CÓDIGO
#& =============================================================================
#* Compila el código con ninja (después de cada cambio de código)
build:
@echo "$(BOLD)$(BLUE)Compilando código con ninja...$(RESET)"
@echo "$(CYAN)Este paso compila todo el código C++/CUDA y genera el módulo Python$(RESET)"
@$(VENV_ACTIVATE) && ninja -C $(BUILD_DIR)
@echo "$(BOLD)$(GREEN)Compilación completada$(RESET)"
#& =============================================================================
#& INSTALACIÓN Y PRUEBAS
#& =============================================================================
#* Instala el módulo compilado
install:
@echo "$(BOLD)$(BLUE)Instalando módulo compilado...$(RESET)"
@echo "$(CYAN)Este paso instala el módulo compilado en tu entorno Python$(RESET)"
@$(VENV_ACTIVATE) && uv pip install .
@echo "$(BOLD)$(GREEN)Instalación completada$(RESET)"
@echo "$(CYAN)El módulo $(BOLD)$(PROJECT_NAME)$(RESET)$(CYAN) está disponible globalmente en tu entorno virtual$(RESET)"
#* Instala todas las dependencias opcionales (test, dev, cuda)
install-all:
@echo "$(BOLD)$(BLUE)Instalando todas las dependencias opcionales...$(RESET)"
@echo "$(CYAN)Esto incluye dependencias de test, desarrollo y CUDA$(RESET)"
@$(VENV_ACTIVATE) && uv pip install pytest pytest-cov pytest-xdist coverage numpy matplotlib pandas psutil
@echo "$(BOLD)$(GREEN)Todas las dependencias instaladas$(RESET)"
@echo "$(CYAN)Ahora puedes ejecutar tests, benchmarks y profiling$(RESET)"
#& =============================================================================
#& LIMPIEZA Y MANTENIMIENTO
#& =============================================================================
#* Limpia archivos de build y residuos de Python
clean:
@echo "$(BOLD)$(YELLOW) Limpiando archivos de build y residuos de Python...$(RESET)"
@echo "$(CYAN)Eliminando directorio de build...$(RESET)"
@rm -rf $(BUILD_DIR)
@echo "$(CYAN)Eliminando archivos Python cache...$(RESET)"
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -name "*.pyc" -delete 2>/dev/null || true
@find . -name "*.pyo" -delete 2>/dev/null || true
@find . -name "*.pyd" -delete 2>/dev/null || true
@echo "$(CYAN)Eliminando archivos de distribución...$(RESET)"
@rm -rf dist/ build/ *.egg-info/ .eggs/
@echo "$(CYAN)Eliminando archivos de cobertura...$(RESET)"
@rm -rf .coverage htmlcov/ .pytest_cache/
@echo "$(BOLD)$(GREEN) Limpieza completa completada$(RESET)"
#* Limpieza super agresiva (incluye entorno virtual)
clean-all: clean
@echo "$(BOLD)$(RED) LIMPIEZA SUPER AGRESIVA - INCLUYE ENTORNO VIRTUAL$(RESET)"
@echo "$(YELLOW)¿Estás seguro? Esto eliminará TODO, incluyendo .venv/$(RESET)"
@read -p "Presiona 'y' para confirmar: " confirm; \
if [ "$$confirm" = "y" ]; then \
echo "$(CYAN)Eliminando entorno virtual...$(RESET)"; \
rm -rf .venv/; \
echo "$(CYAN)Eliminando archivos de configuración...$(RESET)"; \
rm -rf .mesonpy/ .pytest_cache/ .coverage*; \
echo "$(BOLD)$(GREEN) Limpieza super agresiva completada$(RESET)"; \
echo "$(YELLOW) Necesitarás ejecutar 'uv sync' para recrear el entorno$(RESET)"; \
else \
echo "$(YELLOW)Limpieza cancelada$(RESET)"; \
fi
#* Reconstruye todo desde cero
rebuild: clean all
@echo "$(BOLD)$(GREEN)Reconstrucción completada$(RESET)"
#& =============================================================================
#& COMANDOS DE DESARROLLO RÁPIDO
#& =============================================================================
#* Compila e instala rápidamente (para cambios de código frecuentes)
quick: build install
@echo "$(BOLD)$(GREEN)Cambios aplicados rápidamente!$(RESET)"
#* Solo compila (para verificar que compila)
check: build
@echo "$(BOLD)$(GREEN)Código compila correctamente$(RESET)"
#& =============================================================================
#& INFORMACIÓN DEL PROYECTO
#& =============================================================================
#* Muestra información del proyecto
info:
@echo "$(BOLD)$(CYAN)============================================$(RESET)"
@echo "$(BOLD)$(CYAN) INFORMACIÓN DEL PROYECTO$(RESET)"
@echo "$(BOLD)$(CYAN)============================================$(RESET)"
@echo "$(BOLD)Nombre:$(RESET) $(PROJECT_NAME)"
@echo "$(BOLD)Directorio de build:$(RESET) $(BUILD_DIR)"
@echo "$(BOLD)Entorno virtual:$(RESET) .venv/"
@echo "$(BOLD)Compilador CUDA:$(RESET) nvcc"
@echo "$(BOLD)Build system:$(RESET) meson + ninja"
@echo "$(BOLD)Package manager:$(RESET) uv"
@echo ""
#& =============================================================================
#& NOTAS IMPORTANTES
#& =============================================================================
#*
#* FLUJO DE DESARROLLO:
#* 1. make install-dependencies → Solo la primera vez (instala spdlog, CUDA, etc.)
#* 2. make install-all → Instala dependencias opcionales (test, dev, cuda)
#* 3. make config → Solo la primera vez o cambios de configuración
#* 4. make build → Después de cada cambio de código
#* 5. make install → Para probar el módulo
#* 6. make all → Para hacer todo desde cero
#
#* CUÁNDO USAR CADA COMANDO:
#* - install-dependencies: Primera vez en el sistema o cambio de dependencias
#* - install-all: Primera vez o cuando quieres tests/benchmarks/profiling
#* - config: Cambias meson.build, pyproject.toml, o agregas/quitas archivos
#* - build: Cambias código fuente (.cu, .cpp, .hpp, .cuh)
#* - install: Quieres probar el módulo en Python
#
#* PROBLEMAS COMUNES:
#* - Si build falla → Verifica que config se ejecutó correctamente
#* - Si install falla → Verifica que build se ejecutó correctamente
#* - Si hay errores de dependencias → Ejecuta make config
#* - Si tests/benchmarks fallan → Ejecuta make install-all
#
#* =============================================================================
#& ===== PROFILING TARGETS =====================================================
.PHONY: profile profile-quick profile-full profile-memory profile-kernels profile-memory-transfer profile-auto-open
#* Create profiling directory
profiling:
mkdir -p $(PROFILING_PATH)
@echo "Created profiling directory: $(PROFILING_PATH)"
#* Quick profiling (basic CUDA operations)
profile-quick: profiling
@echo "Quick profiling (basic CUDA operations)..."
nsys profile --stats=true --trace=cuda,nvtx,osrt \
--output=$(PROFILING_PATH)/profile_quick_$(shell date +%Y%m%d_%H%M%S) \
python tests/profiling/test_basic_profiling.py
#* Full profiling (all available traces)
profile-full: profiling
@echo "Full profiling (all available traces)..."
nsys profile --stats=true --trace=cuda,nvtx,osrt,cudnn,cublas \
--cuda-memory-usage=true --cuda-graph-trace=node \
--cudabacktrace=all --backtrace=dwarf \
--sample=process-tree --cpuctxsw=process-tree \
--output=$(PROFILING_PATH)/profile_full_$(shell date +%Y%m%d_%H%M%S) \
python tests/profiling/test_complete_profiling.py
#* Memory-focused profiling
profile-memory: profiling
@echo "Memory-focused profiling..."
nsys profile --stats=true --trace=cuda,nvtx,osrt \
--cuda-memory-usage=true --cuda-um-cpu-page-faults=true \
--cuda-um-gpu-page-faults=true \
--output=$(PROFILING_PATH)/profile_memory_$(shell date +%Y%m%d_%H%M%S) \
python tests/profiling/test_memory_profiling.py
#* Memory transfer profiling (SPECIFIC FOR MEMORY TRANSFER VISUALIZATION)
profile-memory-transfer: profiling
@echo "Memory Transfer Profiling (focused on HOST↔GPU transfers)..."
@echo "This will show:"
@echo " - cudaMemcpy operations (HOST→GPU, GPU→HOST)"
@echo " - Memory allocation patterns"
@echo " - Transfer timing differences"
@echo " - Lazy copy behavior"
nsys profile --stats=true --trace=cuda,nvtx,osrt \
--cuda-memory-usage=true \
--cuda-um-cpu-page-faults=true \
--cuda-um-gpu-page-faults=true \
--sample=cpu --cpuctxsw=process-tree \
--output=$(PROFILING_PATH)/profile_memory_transfer_$(shell date +%Y%m%d_%H%M%S) \
python tests/profiling/test_memory_transfer_visualization.py
#* Kernel profiling (when we have CUDA kernels)
profile-kernels: profiling
@echo "Kernel profiling..."
nsys profile --stats=true --trace=cuda,nvtx,osrt \
--cuda-memory-usage=true \
--output=$(PROFILING_PATH)/profile_kernels_$(shell date +%Y%m%d_%H%M%S) \
python tests/profiling/test_kernel_profiling.py
#* AUTOMATIC WORKFLOW: Profile + Open Nsight Systems
profile-auto-open: profile-memory-transfer
@echo "Profiling completed! Opening Nsight Systems automatically..."
@make profile-open
#* AUTOMATIC WORKFLOW: Quick Profile + Open
profile-quick-open: profile-quick
@echo "Quick profiling completed! Opening Nsight Systems automatically..."
@make profile-open
#* AUTOMATIC WORKFLOW: Full Profile + Open
profile-full-open: profile-full
@echo "Full profiling completed! Opening Nsight Systems automatically..."
@make profile-open
#* Open latest profiling report
profile-open:
@echo "Opening latest profiling report..."
@latest_report=$$(ls -t $(PROFILING_PATH)/*.nsys-rep | head -1); \
if [ -n "$$latest_report" ]; then \
echo "Opening: $$latest_report"; \
echo "🔍 Look for these key operations in the timeline:"; \
echo " - cudaMemcpy (HOST→GPU): Vector transfers to GPU"; \
echo " - cudaMemcpy (GPU→HOST): Vector transfers back to HOST"; \
echo " - Memory allocations: GPU buffer creation"; \
echo " - NVTX markers: Test function boundaries"; \
/usr/local/bin/nsys-ui "$$latest_report" & \
else \
echo "No profiling reports found. Run 'make profile-memory-transfer' first."; \
fi
#* List all profiling reports
profile-list:
@echo "Available profiling reports:"
@ls -la $(PROFILING_PATH)/*.nsys-rep 2>/dev/null || echo "No reports found"
#* Clean profiling reports
profile-clean:
@echo "$(BOLD)$(YELLOW)Limpiando reportes de profiling...$(RESET)"
rm -rf $(PROFILING_PATH)/*.nsys-rep $(PROFILING_PATH)/*.sqlite
@echo "$(BOLD)$(GREEN)Reportes de profiling limpiados$(RESET)"
#& =============================================================================
#& TESTING ORGANIZADO POR CAPAS
#& =============================================================================
.PHONY: test-frontend test-backend test-profiling test-integration test-all test-unit test-cuda test-coverage test-watch test-fast test-file
#* Frontend tests (Python bindings) - Incluye coverage
test-frontend:
@echo "$(BOLD)$(BLUE)Ejecutando tests frontend (Python bindings)...$(RESET)"
@$(VENV_ACTIVATE) && python -m pytest tests/frontend/ -v --tb=short
@echo "$(BOLD)$(GREEN)Tests frontend completados$(RESET)"
#* Backend tests (C++/CUDA)
test-backend:
@echo "$(BOLD)$(BLUE)Ejecutando tests backend (C++/CUDA)...$(RESET)"
@echo "$(CYAN)Compilando y ejecutando tests unitarios del KernelLaunchOptimizer$(RESET)"
@cd build && meson test test_kernel_launch_optimizer
@echo "$(BOLD)$(GREEN)Tests backend completados$(RESET)"
#* Profiling tests (rendimiento Python)
test-profiling:
@echo "$(BOLD)$(BLUE)Ejecutando tests de profiling...$(RESET)"
@$(VENV_ACTIVATE) && python -m pytest tests/profiling/ -v --tb=short
@echo "$(BOLD)$(GREEN)Tests de profiling completados$(RESET)"
#* Integration tests (Robot Framework)
test-integration:
@echo "$(BOLD)$(BLUE)Ejecutando tests de integración...$(RESET)"
@echo "$(CYAN)Tests de integración con Robot Framework (futuro)$(RESET)"
@echo "$(YELLOW)Comando no implementado aún$(RESET)"
#* Tests unitarios (alias para frontend)
test-unit: test-frontend
@echo "$(CYAN)test-unit es un alias para test-frontend$(RESET)"
#* Tests que requieren CUDA
test-cuda:
@echo "$(BOLD)$(BLUE)Executing CUDA tests...$(RESET)"
@echo "$(BOLD)$(RED)NOPE, NOT Yet, I'm working on it$(RESET)"
#* Tests con reporte de cobertura
test-coverage:
@echo "$(BOLD)$(BLUE)Ejecutando tests con cobertura...$(RESET)"
@echo "$(CYAN)Limpiando datos de cobertura previos...$(RESET)"
@$(VENV_ACTIVATE) && coverage erase
@$(VENV_ACTIVATE) && python -m pytest tests/frontend/ -v --cov=tests --cov-branch --cov-report=html --cov-report=term-missing --cov-config=.coveragerc
@echo "$(BOLD)$(GREEN)Reporte de cobertura generado$(RESET)"
@echo "$(CYAN)Abre htmlcov/index.html para ver el reporte completo$(RESET)"
#* Tests en modo watch
test-watch:
@echo "$(BOLD)$(BLUE)Ejecutando tests en modo watch...$(RESET)"
@echo "$(YELLOW)Presiona Ctrl+C para detener$(RESET)"
@$(VENV_ACTIVATE) && python -m pytest tests/frontend/ -v --tb=short --watch
#* Tests rápidos (solo frontend, sin CUDA)
test-fast:
@echo "$(BOLD)$(BLUE)⚡ Ejecutando tests rápidos...$(RESET)"
@$(VENV_ACTIVATE) && python -m pytest tests/frontend/ -v -m "not cuda" --tb=short
@echo "$(BOLD)$(GREEN)Tests rápidos completados$(RESET)"
#* Tests específicos por archivo
test-file:
@echo "$(BOLD)$(BLUE)Ejecutando tests específicos...$(RESET)"
@if [ -z "$(FILE)" ]; then \
echo "$(RED)Error: Especifica el archivo con FILE=path/to/test.py$(RESET)"; \
echo "$(YELLOW)Ejemplo: make test-file FILE=tests/frontend/test_basic_functionality.py$(RESET)"; \
exit 1; \
fi
@$(VENV_ACTIVATE) && python -m pytest $(FILE) -v --tb=short
@echo "$(BOLD)$(GREEN)Tests del archivo completados$(RESET)"
#* Todos los tests organizados (alias para test-all principal)
test-all-organized: test-frontend test-backend test-profiling
@echo "$(BOLD)$(GREEN)Todos los tests organizados completados!$(RESET)"
#& ===== BENCHMARK TARGETS =====
.PHONY: benchmark benchmark-operations benchmark-mathematical benchmark-all benchmark-clean
#* Run all benchmarks
benchmark-all:
@echo "$(BOLD)$(BLUE)Ejecutando suite completa de benchmarks...$(RESET)"
@echo "$(CYAN)Esto incluye operaciones básicas, matemáticas y comparaciones con NumPy$(RESET)"
@$(VENV_ACTIVATE) && python tests/benchmarks/run_all_benchmarks.py
@echo "$(BOLD)$(GREEN)Benchmarks completados$(RESET)"
#* Run basic operations benchmarks
benchmark-operations:
@echo "$(BOLD)$(BLUE)Ejecutando benchmarks de operaciones básicas...$(RESET)"
@echo "$(CYAN)Comparando caVector vs NumPy vs PyTorch vs Python built-in$(RESET)"
@$(VENV_ACTIVATE) && python tests/benchmarks/benchmark_operations.py
@echo "$(BOLD)$(GREEN)Benchmarks de operaciones completados$(RESET)"
#* Run mathematical operations benchmarks
benchmark-mathematical:
@echo "$(BOLD)$(BLUE)Ejecutando benchmarks de operaciones matemáticas...$(RESET)"
@echo "$(CYAN)Comparando funciones trigonométricas, exponenciales y estadísticas$(RESET)"
@$(VENV_ACTIVATE) && python tests/benchmarks/benchmark_mathematical.py
@echo "$(BOLD)$(GREEN)Benchmarks matemáticos completados$(RESET)"
#* Clean benchmark outputs
benchmark-clean:
@echo "$(BOLD)$(YELLOW)Limpiando outputs de benchmarks...$(RESET)"
@rm -rf tests/benchmarks/output/
@rm -f benchmark_*.png benchmark_*.md
@echo "$(BOLD)$(GREEN)Outputs de benchmarks limpiados$(RESET)"
#* Alias for benchmark-all
benchmark: benchmark-all
@echo "$(CYAN)benchmark es un alias para benchmark-all$(RESET)"
#& ===== DEVELOPMENT WORKFLOW =====
.PHONY: dev-test dev-profile dev-benchmark
# Development testing workflow
dev-test: build test-all
@echo "Development testing completed!"
# Development profiling workflow
dev-profile: build profile-full profile-open
@echo "Development profiling completed!"
# Development benchmarking workflow
dev-benchmark: build benchmark-all
@echo "Development benchmarking completed!"