<jupyter_start><jupyter_text>Gallery of processor cache effects<jupyter_code>import matplotlib.pyplot as plt
from matplotlib import cm
%matplotlib inline
import numpy as np<jupyter_output><empty_output><jupyter_text>Cache hierarchy<jupyter_code>hierarchy_timings = np.genfromtxt('cache_hierarchy.txt', delimiter=',', unpack=True, names=True)
plt.figure(figsize=(12.0, 8.0))
plt.semilogx(hierarchy_timings['array_size'], hierarchy_timings['time'], basex=2)
plt.xticks(np.logspace(7, 24, num=18, base=2))
plt.xlabel('array size')
plt.ylabel('time');<jupyter_output><empty_output><jupyter_text>Cache lines<jupyter_code>timings = np.genfromtxt('cache_lines.txt', delimiter=',', names=True, unpack=True)
plt.figure(figsize=(12.0, 8.0))
plt.loglog(timings['stride'], timings['time'], basex=2, basey=2)
plt.xlabel(r'K')
plt.ylabel(r'time');<jupyter_output><empty_output><jupyter_text>Cache associativity<jupyter_code>associativity_timings = np.genfromtxt('cache_associativity.txt', delimiter=',', names=True, unpack=True)
len(set(associativity_timings['array_size'])), len(set(associativity_timings['step']))
timing_map = associativity_timings['time'].reshape((64, 4999))
plt.figure(figsize=(10, 12))
plt.imshow(timing_map[:,: 1200], origin='lower', cmap=cm.coolwarm, aspect=10)
plt.xlabel('step size (8 bytes)')
plt.ylabel('array size (8 byte elements)')
plt.xticks([x for x in range(0, 1100, 128)])
plt.yticks([x for x in range(0, 64, 8)]);
plt.figure(figsize=(10, 12))
plt.imshow(timing_map[52:,: 270], origin='lower', cmap=cm.coolwarm, aspect=20)
plt.xlabel('step size')
plt.ylabel('array size');
associativity_bytes_timings = np.genfromtxt('cache_associativity_bytes.txt', delimiter=',', names=True, unpack=True)
timing_map = associativity_bytes_timings['time'].reshape((64, 5000))
np.min(timing_map), np.median(timing_map), np.max(timing_map)
plt.figure(figsize=(10, 12))
plt.imshow(timing_map[:,: 1200], origin='lower', cmap=cm.coolwarm, aspect=10, interpolation='none')
plt.xlabel('step size (8 bytes)')
plt.ylabel('array size (8 byte elements)')
plt.xticks([x for x in range(0, 1100, 128)])
plt.yticks([x for x in range(0, 64, 8)]);
plt.figure(figsize=(10, 12))
plt.imshow(timing_map[24:56,: 300], origin='lower', cmap=cm.coolwarm, aspect=5, interpolation='none')
plt.xlabel('step size')
plt.ylabel('array size')
plt.xticks([x for x in range(0, 300, 16)]);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18090452261306533, 'fraction_numerical': 0.04522613065326633, 'mean_word_length': 9.908675799086758, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '320825', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1024, 'n_tokens_neox': 908, 'n_words': 160, 'path': 'Optimization/GalleryProcessorCacheEffects/gallery.ipynb', 'repo_name': 'Gjacquenot/training-material', 'size': '2388'}