diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json
index bf8a836..5dbbbb9 100644
--- a/.obsidian/workspace.json
+++ b/.obsidian/workspace.json
@@ -18,8 +18,23 @@
"icon": "lucide-image",
"title": "Pasted image 20241211115747"
}
+ },
+ {
+ "id": "6fd893cabd53f492",
+ "type": "leaf",
+ "state": {
+ "type": "markdown",
+ "state": {
+ "file": "conflict-files-obsidian-git.md",
+ "mode": "source",
+ "source": false
+ },
+ "icon": "lucide-file",
+ "title": "conflict-files-obsidian-git"
+ }
}
- ]
+ ],
+ "currentTab": 1
}
],
"direction": "vertical"
@@ -172,24 +187,25 @@
"obsidian-git:Open Git source control": false
}
},
- "active": "a4eac8e6613b153b",
+ "active": "6fd893cabd53f492",
"lastOpenFiles": [
- "TERCERO/ATR1/Teoría_2425.md",
- "TERCERO/ATR1/images/Pasted image 20241211120536.png",
- "TERCERO/ATR1/images/Pasted image 20241211115841.png",
"TERCERO/ATR1/images/Pasted image 20241211115747.png",
+ "conflict-files-obsidian-git.md",
+ "TERCERO/SPD/images/arriba.png",
+ "TERCERO/SPD/images/abajo.png",
+ "TERCERO/SPD/images/Pasted image 20241209194450.png",
+ "TERCERO/SPD/images/Pasted image 20241209194420.png",
+ "TERCERO/SPD/images/Pasted image 20241209181348.png",
+ "TERCERO/SPD/images/Pasted image 20241209180114.png",
+ "TERCERO/SPD/images/Pasted image 20241209175932.png",
+ "TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 20.00.56_ae187147.jpg",
+ "TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.58.16_359536b7.jpg",
+ "TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.56.10_a7e685e5.jpg",
+ "TERCERO/ATR1/Teoría_2425.md",
"SEGUNDO/RC/Teoría_2324.md",
"TERCERO/IA/Teoría_2425.md",
"TERCERO/SPD/Teoría_2425.md",
"TERCERO/SS/SS 24-25.md",
- "TERCERO/SPD/images/Pasted image 20241202214411.png",
- "TERCERO/SPD/images/Pasted image 20241202214354.png",
- "TERCERO/SPD/images/Pasted image 20241202214247.png",
- "TERCERO/SPD/images/Pasted image 20241202214242.png",
- "TERCERO/SPD/images/Pasted image 20241202214114.png",
- "TERCERO/SPD/images/Pasted image 20241202214112.png",
- "TERCERO/SPD/images/Pasted image 20241202213603.png",
- "conflict-files-obsidian-git.md",
"Untitled.md",
"TERCERO/ATR1/Resolución 1 Parcial ATR1.md",
"TERCERO/ATR1/Ejercicios.md",
diff --git a/TERCERO/SPD/Teoría_2425.md b/TERCERO/SPD/Teoría_2425.md
index 2b6761a..0702168 100644
--- a/TERCERO/SPD/Teoría_2425.md
+++ b/TERCERO/SPD/Teoría_2425.md
@@ -145,7 +145,129 @@ graph TD;
7[Linkado y .exe nativo] --> 10[CPU]
9[Ensamblador nativo] --> 10[CPU]
```
-# TEMA 3: Instruction Level Parallelism (ILP)
+# TEMA 2: ILP basado en planificación estática
+## 1. Introducción
+Se realiza la **planificación** (o **scheduling**) para reordenar las instrucciones con el objetivo de evitar los bloqueos de datos. Teniendo en cuenta el concepto de dependencia, se puede modelar un programa como un grafo de dependencias reales (RAW), pero existe un **límite de CPI (data-flow-limit)**:
+- Sólo se ven las fases de ALU y EX/ME.
+- Las otras (ID, ID, WB) se realizan en paralelo.
+![[Pasted image 20241209181348.png]]
+## 2. Desenrollado de bucles
+Los bucles suelen ocupar más del 90% del $t_{CPU}$.
+```c
+double s, x[M], y[M]; int i;
+for(i = 0; i < M; i++)
+{
+ y[i] = x[i] * s;
+}
+```
+Si el bucle es paralelizable (iteraciones independientes) se puede "desenrollar":
+```c
+for(i = 0; i < M % 3; i++) // módulo para las iteraciones bajas (pequeñas)
+{
+ y[i] = x[i] * s;
+}
+
+for( ; i < M; i++)
+{
+ y[i] = x[i] * s;
+ y[i + 1] = x[i + 1] * s;
+ y[i + 2] = x[i + 2] * s;
+}
+```
+En bajo nivel (el segundo bucle) quedaría algo como:
+```riscv
+bucle: LD F2, 0(R1)
+ MULTD F4, F2, F24 ; F24 contiene el valor de s
+ SD (R3)0, F4 ; se guarda en y[i]
+ LD F2, 8(R1)
+ MULTD F4, F2, F24
+ SD (R3)8, F4 ; se guarda en y[i + 1]
+ LD F2, 16(R1)
+ MULTD F4, F2, F24 ; se guarda en y[i + 2]
+ SD (R3)16, F4
+;------------------------------------------------------
+ ADDI R1, R1, 8*3
+ ADDI R3, R3, 8*3
+ SLTI R7, R1, fin_array_x
+ BNEZ R7, bucle
+```
+Donde por encima de la línea están las **instrucciones útiles** y por debajo las de **overhead**. En el bucle usamos renombrado de registros para evitar las dependencias **WAW** y **WAR**. Usamos la notacion prima ( $'$ ) por simplicidad:
+```riscv
+bucle: LD F2, 0(R1)
+ MULTD F4, F2, F24 ; F24 contiene el valor de s
+ SD (R3)0, F4 ; se guarda en y[i]
+
+ LD F2', 8(R1)
+ MULTD F4', F2', F24
+ SD (R3)8, F4' ; se guarda en y[i + 1]
+
+ LD F2'', 16(R1)
+ MULTD F4'', F2'', F24 ; se guarda en y[i + 2]
+ SD (R3)16, F4''
+;------------------------------------------------------
+ ADDI R1, R1, 8*3
+ ADDI R3, R3, 8*3
+ SLTI R7, R1, fin_array_x
+ BNEZ R7, bucle
+```
+Por último se entrelazan las instrucciones de las distintas iteraciones
+```riscv
+bucle: LD F2, 0(R1)
+ LD F2', 8(R1)
+ LD F2'', 16(R1)
+
+ MULTD F4, F2, F24 ; F24 contiene el valor de s
+ MULTD F4', F2', F24
+ MULTD F4'', F2'', F24 ; se guarda en y[i + 2]
+
+ SD (R3)0, F4 ; se guarda en y[i]
+ SD (R3)8, F4' ; se guarda en y[i + 1]
+ SD (R3)16, F4''
+;------------------------------------------------------
+ ADDI R1, R1, 8*3
+ ADDI R3, R3, 8*3
+ SLTI R7, R1, fin_array_x
+ BNEZ R7, bucle
+```
+
NOTA
Al reducir el nº de instrucciones, el CPI no es buena medida de rendimiento. Lo que sí se puede usar es el ciclos por elemento del vector procesado
+#### Conclusiones
+- Se **reducen las instrucciones de overhead**
+- Se **reescribe el código** para hacerlo más rápido
+- Se aumenta la **planificación estática al reducir el % de saltos**.
+- Se necesitan **más registros** (en RISC hay).
+Formas de escribir un sumatorio


+## 3. Software Pipelining
+![[Pasted image 20241209194450.png]]
+NOTA
Si se usa el desenrollado, quedarían varias instrucciones por iteración.
+## 4. Instrucciones predicativas
+- **Simples:** se basa en la condición definida por un registro `Rcond`
+ `CMOVZ Rd, Rf, Rcond`
+ `CMOVNZ Rd, Rf, Rcond`
+- **Universales:** toda instrucción puede llevar un predicado delante
+ `[Cond] Instr. (operandos)`
+ El único problema es que todas se decodifican o emiten ( y las falsas se abortan ).
+## 5. Planificación de trazas
+Se reordena saltando entre bloques de la traza de ejecución. Se usa mucho en CPUs VLIW.
+![[Imagen de WhatsApp 2024-12-09 a las 19.56.10_a7e685e5.jpg|400]]
+## 6. Procesadores VLIW
+**VLIW:** Very Long Instruction Word
+Instrucciones de 64, 128 ó 256 bits. No tiene técnicas dinámicas, se depende **masivamente** del compilador y su planificación estática.
+![[Imagen de WhatsApp 2024-12-09 a las 19.58.16_359536b7.jpg|600]]
+$CPI = 1 + CPI_{mem}+CPI_{control}$
+#### Ejemplo: TMS320C6713
+![[Imagen de WhatsApp 2024-12-09 a las 20.00.56_ae187147.jpg]]
+Eficiencia del IAXPY:
+$$
+\begin{equation}
+\text{\% de slots rellenos}=\frac{5+3}{(8\times 3)\text{ slots}}=\frac{8}{24}=33\%
+\end{equation}
+$$
+$$
+\begin{equation}
+\text{SWP + desenr. 2 iter.}=\frac{5\times 2 +3}{(8\times 3)\text{ slots}}=\frac{13}{24}
+\end{equation}
+$$
+# TEMA 3: ILP basado en planificación dinámica
## 1. Técnicas de planificación dinámicas
### $t_{CPU}=N_{instr}\times CPI\times T_{CLK}$
@@ -394,3 +516,11 @@ Se suele usar el esquema **Scatter-Gather**
### Reducciones: MPI_Reduce
`int MPI_Reduce(const void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)`
## 4. Caracterización de aplicaciones
+Es difícil analizar si una app es paralelizable porque hay muchos factores que intervienen:
+- Cómo se escribe el algoritmo
+- Distribución de los datos
+- Sincronización eficiente
+- Ocultación de acceso a memoria, red, etc.
+ ![[Pasted image 20241209175932.png]]
+#### Esquema Broadcast-Scatter-Gather
+![[Pasted image 20241209180114.png]]
diff --git a/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.56.10_a7e685e5.jpg b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.56.10_a7e685e5.jpg
new file mode 100644
index 0000000..b08d379
Binary files /dev/null and b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.56.10_a7e685e5.jpg differ
diff --git a/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.58.16_359536b7.jpg b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.58.16_359536b7.jpg
new file mode 100644
index 0000000..402201f
Binary files /dev/null and b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 19.58.16_359536b7.jpg differ
diff --git a/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 20.00.56_ae187147.jpg b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 20.00.56_ae187147.jpg
new file mode 100644
index 0000000..adc2f8f
Binary files /dev/null and b/TERCERO/SPD/images/Imagen de WhatsApp 2024-12-09 a las 20.00.56_ae187147.jpg differ
diff --git a/TERCERO/SPD/images/Pasted image 20241209175932.png b/TERCERO/SPD/images/Pasted image 20241209175932.png
new file mode 100644
index 0000000..9e3fbfe
Binary files /dev/null and b/TERCERO/SPD/images/Pasted image 20241209175932.png differ
diff --git a/TERCERO/SPD/images/Pasted image 20241209180114.png b/TERCERO/SPD/images/Pasted image 20241209180114.png
new file mode 100644
index 0000000..dd0fc62
Binary files /dev/null and b/TERCERO/SPD/images/Pasted image 20241209180114.png differ
diff --git a/TERCERO/SPD/images/Pasted image 20241209181348.png b/TERCERO/SPD/images/Pasted image 20241209181348.png
new file mode 100644
index 0000000..e10c19b
Binary files /dev/null and b/TERCERO/SPD/images/Pasted image 20241209181348.png differ
diff --git a/TERCERO/SPD/images/Pasted image 20241209194420.png b/TERCERO/SPD/images/Pasted image 20241209194420.png
new file mode 100644
index 0000000..41656e5
Binary files /dev/null and b/TERCERO/SPD/images/Pasted image 20241209194420.png differ
diff --git a/TERCERO/SPD/images/Pasted image 20241209194450.png b/TERCERO/SPD/images/Pasted image 20241209194450.png
new file mode 100644
index 0000000..3b4870c
Binary files /dev/null and b/TERCERO/SPD/images/Pasted image 20241209194450.png differ
diff --git a/TERCERO/SPD/images/abajo.png b/TERCERO/SPD/images/abajo.png
new file mode 100644
index 0000000..c4185f1
Binary files /dev/null and b/TERCERO/SPD/images/abajo.png differ
diff --git a/TERCERO/SPD/images/arriba.png b/TERCERO/SPD/images/arriba.png
new file mode 100644
index 0000000..cf3618a
Binary files /dev/null and b/TERCERO/SPD/images/arriba.png differ
diff --git a/conflict-files-obsidian-git.md b/conflict-files-obsidian-git.md
new file mode 100644
index 0000000..d8bbd4f
--- /dev/null
+++ b/conflict-files-obsidian-git.md
@@ -0,0 +1,17 @@
+# Conflicts
+Please resolve them and commit them using the commands `Git: Commit all changes` followed by `Git: Push`
+(This file will automatically be deleted before commit)
+[[#Additional Instructions]] available below file list
+
+- Not a file: .obsidian/workspace.json
+
+# Additional Instructions
+I strongly recommend to use "Source mode" for viewing the conflicted files. For simple conflicts, in each file listed above replace every occurrence of the following text blocks with the desired text.
+
+```diff
+<<<<<<< HEAD
+ File changes in local repository
+=======
+ File changes in remote repository
+>>>>>>> origin/main
+```
\ No newline at end of file