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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="gpu-sm-architecture"></div>
|
| 2 |
+
|
| 3 |
+
<style>
|
| 4 |
+
.gpu-sm-architecture {
|
| 5 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 6 |
+
position: relative;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
.gpu-sm-architecture .diagram-container {
|
| 11 |
+
width: 100%;
|
| 12 |
+
height: auto;
|
| 13 |
+
position: relative;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
.gpu-sm-architecture .sm-label {
|
| 18 |
+
font-size: 14px;
|
| 19 |
+
font-weight: 700;
|
| 20 |
+
fill: white;
|
| 21 |
+
text-anchor: middle;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.gpu-sm-architecture .component-label {
|
| 25 |
+
font-size: 11px;
|
| 26 |
+
font-weight: 600;
|
| 27 |
+
fill: white;
|
| 28 |
+
text-anchor: middle;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.gpu-sm-architecture .core-label {
|
| 32 |
+
font-size: 9px;
|
| 33 |
+
font-weight: 600;
|
| 34 |
+
fill: white;
|
| 35 |
+
text-anchor: middle;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.gpu-sm-architecture .ellipsis-text {
|
| 39 |
+
font-size: 24px;
|
| 40 |
+
font-weight: bold;
|
| 41 |
+
fill: var(--muted-color);
|
| 42 |
+
text-anchor: middle;
|
| 43 |
+
}
|
| 44 |
+
</style>
|
| 45 |
+
|
| 46 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.2.5/svg.min.js"></script>
|
| 47 |
+
<script>
|
| 48 |
+
(() => {
|
| 49 |
+
// Prevent multiple executions
|
| 50 |
+
if (window.gpuSmArchitectureInitialized) return;
|
| 51 |
+
window.gpuSmArchitectureInitialized = true;
|
| 52 |
+
|
| 53 |
+
const bootstrap = () => {
|
| 54 |
+
const scriptEl = document.currentScript;
|
| 55 |
+
let container = scriptEl ? scriptEl.previousElementSibling : null;
|
| 56 |
+
if (!(container && container.classList && container.classList.contains('gpu-sm-architecture'))) {
|
| 57 |
+
const cs = Array.from(document.querySelectorAll('.gpu-sm-architecture')).filter(el => !(el.dataset && el.dataset.mounted === 'true'));
|
| 58 |
+
container = cs[cs.length - 1] || null;
|
| 59 |
+
}
|
| 60 |
+
if (!container) return;
|
| 61 |
+
if (container.dataset) {
|
| 62 |
+
if (container.dataset.mounted === 'true') return;
|
| 63 |
+
container.dataset.mounted = 'true';
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
// Get colors from ColorPalettes
|
| 67 |
+
const getColors = () => {
|
| 68 |
+
try {
|
| 69 |
+
if (window.ColorPalettes && typeof window.ColorPalettes.getColors === 'function') {
|
| 70 |
+
return window.ColorPalettes.getColors('categorical', 5);
|
| 71 |
+
}
|
| 72 |
+
} catch (_) { }
|
| 73 |
+
return ['#64748b', '#94a3b8', '#cbd5e1', '#e2e8f0', '#f1f5f9'];
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
const colors = getColors();
|
| 77 |
+
|
| 78 |
+
// Background colors - gray tones like training compass
|
| 79 |
+
const bgColors = {
|
| 80 |
+
sm: 'var(--surface-bg)', // Dark mode ready SM background
|
| 81 |
+
control: colors[1], // Keep categorical colors for components
|
| 82 |
+
registers: colors[2],
|
| 83 |
+
cores: colors[3],
|
| 84 |
+
cache: colors[4]
|
| 85 |
+
};
|
| 86 |
+
|
| 87 |
+
// Create diagram container
|
| 88 |
+
const diagramContainer = document.createElement('div');
|
| 89 |
+
diagramContainer.className = 'diagram-container';
|
| 90 |
+
container.appendChild(diagramContainer);
|
| 91 |
+
|
| 92 |
+
// Create responsive SVG with fixed internal dimensions
|
| 93 |
+
const containerWidth = diagramContainer.clientWidth || 1200;
|
| 94 |
+
const smHeight = 375; // Fixed internal height
|
| 95 |
+
const containerHeight = smHeight + 20; // Fixed internal height
|
| 96 |
+
const draw = SVG().addTo(diagramContainer).size('100%', containerHeight).viewbox(0, 0, containerWidth, containerHeight);
|
| 97 |
+
|
| 98 |
+
// SM dimensions - scaled to fit container width
|
| 99 |
+
const totalWidth = containerWidth - 40; // Leave 20px margin on each side
|
| 100 |
+
const smWidth = (totalWidth - 80) / 3; // Total width minus spacings, divided by 3 SMs
|
| 101 |
+
const normalSpacing = 20; // Normal spacing between blocks
|
| 102 |
+
const ellipsisSpacing = 80; // Much larger spacing for ellipsis
|
| 103 |
+
|
| 104 |
+
// Perfect centering
|
| 105 |
+
const startX = 0; // Fixed margin from left edge
|
| 106 |
+
const startY = 0; // Small top margin instead of centering vertically
|
| 107 |
+
|
| 108 |
+
// Create 3 SM blocks with different spacing
|
| 109 |
+
let currentX = startX;
|
| 110 |
+
for (let i = 0; i < 3; i++) {
|
| 111 |
+
const x = currentX;
|
| 112 |
+
const y = startY;
|
| 113 |
+
|
| 114 |
+
// Adjust spacing based on position
|
| 115 |
+
if (i === 0) {
|
| 116 |
+
// After 1st SM: normal spacing (no ellipsis)
|
| 117 |
+
currentX += smWidth + normalSpacing;
|
| 118 |
+
} else if (i === 1) {
|
| 119 |
+
// After 2nd SM: large spacing (with ellipsis)
|
| 120 |
+
currentX += smWidth + ellipsisSpacing;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// Create SM group
|
| 124 |
+
const smGroup = draw.group().id(`sm-${i}`);
|
| 125 |
+
|
| 126 |
+
// SM background
|
| 127 |
+
const smBg = smGroup.rect(smWidth, smHeight)
|
| 128 |
+
.fill(bgColors.sm)
|
| 129 |
+
.stroke({ color: 'var(--border-color)', width: 1.5 })
|
| 130 |
+
.radius(12)
|
| 131 |
+
.move(x, y);
|
| 132 |
+
|
| 133 |
+
// SM label
|
| 134 |
+
smGroup.text('SM')
|
| 135 |
+
.font({ size: 28, weight: 'bold' })
|
| 136 |
+
.fill('var(--text-color)')
|
| 137 |
+
.center(x + smWidth / 2, y + 35);
|
| 138 |
+
|
| 139 |
+
// Control Unit
|
| 140 |
+
const controlY = y + 70;
|
| 141 |
+
smGroup.rect(smWidth - 30, 35)
|
| 142 |
+
.fill(bgColors.control)
|
| 143 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 144 |
+
.radius(8)
|
| 145 |
+
.move(x + 15, controlY);
|
| 146 |
+
smGroup.text('Control')
|
| 147 |
+
.font({ size: 16, weight: '600' })
|
| 148 |
+
.fill('white')
|
| 149 |
+
.center(x + smWidth / 2, controlY + 17.5);
|
| 150 |
+
|
| 151 |
+
// Registers
|
| 152 |
+
const registersY = controlY + 50;
|
| 153 |
+
smGroup.rect(smWidth - 30, 35)
|
| 154 |
+
.fill(bgColors.registers)
|
| 155 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 156 |
+
.radius(8)
|
| 157 |
+
.move(x + 15, registersY);
|
| 158 |
+
smGroup.text('Registers')
|
| 159 |
+
.font({ size: 16, weight: '600' })
|
| 160 |
+
.fill('white')
|
| 161 |
+
.center(x + smWidth / 2, registersY + 17.5);
|
| 162 |
+
|
| 163 |
+
// Cores container
|
| 164 |
+
const coresY = registersY + 50;
|
| 165 |
+
const coresWidth = smWidth - 30;
|
| 166 |
+
const coresHeight = 82.5; // Slightly increased height
|
| 167 |
+
const coresPerRow = 4;
|
| 168 |
+
const coresRows = 2;
|
| 169 |
+
const coreSpacing = 8;
|
| 170 |
+
|
| 171 |
+
// Calculate core size to fill available width
|
| 172 |
+
const availableWidth = coresWidth - (coresPerRow - 1) * coreSpacing - 20; // 20px padding
|
| 173 |
+
const coreSize = availableWidth / coresPerRow;
|
| 174 |
+
|
| 175 |
+
// Cores background
|
| 176 |
+
smGroup.rect(coresWidth, coresHeight)
|
| 177 |
+
.fill('rgba(0,0,0,0.05)')
|
| 178 |
+
.radius(8)
|
| 179 |
+
.stroke({ color: 'var(--border-color)', width: 1.5 })
|
| 180 |
+
.move(x + 15, coresY);
|
| 181 |
+
|
| 182 |
+
// Create 8 cores (4x2 grid) - fill full width
|
| 183 |
+
const startCoreX = x + 15 + 10; // Left padding
|
| 184 |
+
const startCoreY = coresY + 10; // Top padding
|
| 185 |
+
|
| 186 |
+
for (let row = 0; row < coresRows; row++) {
|
| 187 |
+
for (let col = 0; col < coresPerRow; col++) {
|
| 188 |
+
const coreX = startCoreX + col * (coreSize + coreSpacing);
|
| 189 |
+
const coreY = startCoreY + row * (coreSize + coreSpacing);
|
| 190 |
+
|
| 191 |
+
smGroup.rect(coreSize, coreSize)
|
| 192 |
+
.fill(bgColors.cores)
|
| 193 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 194 |
+
.radius(4)
|
| 195 |
+
.move(coreX, coreY);
|
| 196 |
+
|
| 197 |
+
smGroup.text('Core')
|
| 198 |
+
.font({ size: 10, weight: '600' })
|
| 199 |
+
.fill('white')
|
| 200 |
+
.center(coreX + coreSize / 2, coreY + coreSize / 2);
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
// Constant Cache
|
| 205 |
+
const cacheY = coresY + coresHeight + 15;
|
| 206 |
+
smGroup.rect(smWidth - 30, 35)
|
| 207 |
+
.fill(bgColors.cache)
|
| 208 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 209 |
+
.radius(8)
|
| 210 |
+
.move(x + 15, cacheY);
|
| 211 |
+
smGroup.text('Constant Cache')
|
| 212 |
+
.font({ size: 16, weight: '600' })
|
| 213 |
+
.fill('white')
|
| 214 |
+
.center(x + smWidth / 2, cacheY + 17.5);
|
| 215 |
+
|
| 216 |
+
// Shared Memory and L1 Cache (side by side with line breaks)
|
| 217 |
+
const memoryY = cacheY + 50;
|
| 218 |
+
const memoryWidth = (smWidth - 40) / 2;
|
| 219 |
+
|
| 220 |
+
// Shared Memory (left side)
|
| 221 |
+
smGroup.rect(memoryWidth, 40)
|
| 222 |
+
.fill(bgColors.cache)
|
| 223 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 224 |
+
.radius(8)
|
| 225 |
+
.move(x + 15, memoryY);
|
| 226 |
+
smGroup.text('Shared')
|
| 227 |
+
.font({ size: 12, weight: '600' })
|
| 228 |
+
.fill('white')
|
| 229 |
+
.center(x + 15 + memoryWidth / 2, memoryY + 12);
|
| 230 |
+
smGroup.text('Memory')
|
| 231 |
+
.font({ size: 12, weight: '600' })
|
| 232 |
+
.fill('white')
|
| 233 |
+
.center(x + 15 + memoryWidth / 2, memoryY + 28);
|
| 234 |
+
|
| 235 |
+
// L1 Cache (right side)
|
| 236 |
+
smGroup.rect(memoryWidth, 40)
|
| 237 |
+
.fill(bgColors.cache)
|
| 238 |
+
.stroke({ color: 'rgba(0,0,0,0.2)', width: 1 })
|
| 239 |
+
.radius(8)
|
| 240 |
+
.move(x + 15 + memoryWidth + 10, memoryY);
|
| 241 |
+
smGroup.text('L1')
|
| 242 |
+
.font({ size: 12, weight: '600' })
|
| 243 |
+
.fill('white')
|
| 244 |
+
.center(x + 15 + memoryWidth + 10 + memoryWidth / 2, memoryY + 12);
|
| 245 |
+
smGroup.text('Cache')
|
| 246 |
+
.font({ size: 12, weight: '600' })
|
| 247 |
+
.fill('white')
|
| 248 |
+
.center(x + 15 + memoryWidth + 10 + memoryWidth / 2, memoryY + 28);
|
| 249 |
+
|
| 250 |
+
// Add ellipsis between SMs (only between 2nd and 3rd)
|
| 251 |
+
if (i === 1) {
|
| 252 |
+
draw.text('...')
|
| 253 |
+
.font({ size: 42, weight: 'bold' })
|
| 254 |
+
.fill('var(--muted-color)')
|
| 255 |
+
.center(x + smWidth + ellipsisSpacing / 2, y + smHeight / 2);
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
};
|
| 260 |
+
|
| 261 |
+
if (document.readyState === 'loading') {
|
| 262 |
+
document.addEventListener('DOMContentLoaded', bootstrap, { once: true });
|
| 263 |
+
} else {
|
| 264 |
+
bootstrap();
|
| 265 |
+
}
|
| 266 |
+
})();
|
| 267 |
+
</script>
|