<jupyter_start><jupyter_text>Comparison of dgemm calls performed within HPL and in a calibration<jupyter_code>import io
import os
import zipfile
import pandas
import yaml
import datetime
import re
from plotnine import *
import plotnine
plotnine.options.figure_size = (12, 8)
import warnings
warnings.simplefilter(action='ignore') # removing annoying warning
import json

def read_csv(archive_name, csv_name, columns=None, filter_func=lambda x: x):
    archive = zipfile.ZipFile(archive_name)
    df = pandas.read_csv(io.BytesIO(filter_func(archive.read(csv_name))), names=columns)
    df.columns = df.columns.str.strip()
    df['jobid'] = int(get_yaml(archive_name, 'info.yaml')['jobid'])
    df['index'] = range(len(df))
    return df

def get_yaml(archive_name, yaml_name):
    archive = zipfile.ZipFile(archive_name)
    return yaml.load(io.BytesIO(archive.read(yaml_name)))
archive = 'dgemm_prediction/10/grenoble_2019-10-16_1889002.zip'

def read_archive(archive_name, exp_id):
    blas_col = ['file', 'line', 'function', 'rank', 'timestamp', 'duration', 'm', 'n', 'k', 'lda', 'ldb', 'ldc', 'layout', 'transA', 'transB']
    df = read_csv(archive_name, 'trace_blas_%d.csv' % exp_id, columns=blas_col)
    print('Read trace n°%d from %s: %6d lines' % (exp_id, archive_name, len(df)))
    df['start'] = df.timestamp
    df['end'] = df.timestamp + df.duration
    df = df[['file', 'line', 'index', 'jobid', 'function', 'start', 'end', 'rank', 'm', 'n', 'k', 'lda', 'ldb', 'ldc', 'layout', 'transA', 'transB', 'duration']]
    df['function'] = df['function'].str.strip()
    df['exp_id'] = exp_id
    return df

traces = read_archive(archive, 0)

traces = traces[(traces['function'] == 'dgemm') & (traces['rank'] == 0)].reset_index(drop=True)
traces.m = traces.m.astype(int)
traces.n = traces.n.astype(int)
traces.k = traces.k.astype(int)
print(len(traces))
traces.head()
traces['mnk'] = traces.m * traces.n * traces.k
traces['special'] = (traces.m == 2048) & (traces.n == 2048) & (traces.k == 2048)
traces['gflops'] = 2*traces.mnk / traces['duration'] * 1e-9
plot = ggplot(traces[traces.duration > 0.1], aes(x='start', y='gflops', color='special')) + geom_point() + theme_bw()
plot = plot + xlab('Timestamp') + ylab('Performance in HPL (Gflop/s)') + ggtitle('DGEMM performane in HPL on rank 0 (for calls longer than 0.1s)')
plot<jupyter_output><empty_output><jupyter_text>Monitoring<jupyter_code>def get_monitoring(archive_name, csv_name, tag):
    df = read_csv(archive_name, csv_name)
    for col in ['start', 'stop']:
        df[col] = pandas.to_datetime(df[col])
    first = df['start'].min()
    df['start'] -= first
    df['stop'] -= first
    df['tag'] = tag
    return df
temperature = pandas.concat([
    get_monitoring(archive, 'monitoring_temp.csv', tag='HPL'),
])
temperature.head()
plot = ggplot(temperature, aes(x='start', y='temperature', color='factor(sensor_id)')) + geom_point() + theme_bw()
plot = plot + xlab('Timestamp') + ylab('Temperature (°C)') + labs(color='CPU') + ggtitle('Evolution of the temperature when running HPL')
plot
frequency = pandas.concat([
    get_monitoring(archive, 'monitoring_freq.csv', tag='HPL'),
])
frequency['frequency'] *= 1e-9
frequency.head()
frequency['cpu_id'] = frequency['core_id'] % 2
frequency = frequency[frequency['core_id'] < 32]  # removing the hyperthread cores
plot = ggplot(frequency, aes(x='start', y='frequency', color='factor(cpu_id)')) + geom_point() + theme_bw()
plot = plot + xlab('Timestamp') + ylab('Frequency (GHz)') + labs(color='CPU') + ggtitle('Evolution of the frequency when running HPL')
plot
special_dgemm = traces[traces.special]
start = special_dgemm[special_dgemm.start > 100].start.min()
stop = special_dgemm[special_dgemm.end < 160].end.max()
print('Second special dgemm phase: %.2fs - %.2fs' % (start, stop))
start_window = pandas.to_timedelta(start-20, unit='s')
stop_window = pandas.to_timedelta(stop+20, unit='s')
start = pandas.to_timedelta(start, unit='s')
stop = pandas.to_timedelta(stop, unit='s')
plot = ggplot(frequency[(frequency.start >= start_window) & (frequency.start <= stop_window) & (frequency.tag == 'HPL')], aes(x='start', y='frequency', color='factor(cpu_id)')) 
plot = plot + geom_point() + theme_bw() +  facet_wrap('tag', labeller='label_both')
plot = plot + geom_vline(xintercept=start, linetype='dashed') + geom_vline(xintercept=stop, linetype='dashed')
plot = plot + xlab('Timestamp') + ylab('Frequency (GHz)') + labs(color='CPU')
plot + ggtitle('CPU frequencies when HPL performs our special dgemm calls')
cols = ['m', 'n', 'k', 'lda', 'ldb', 'ldc']
dump = traces[(traces['rank'] == 0)].sort_values(by='index', axis=0)[['function'] + cols]
for c in cols:
    dump[c] = dump[c].astype(int)
dump.to_csv('/tmp/exp_hpl.csv', index=False, header=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18468280467445744, 'fraction_numerical': 0.01293823038397329, 'mean_word_length': 5.916305916305916, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '604533', 'license': 'MIT', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1728, 'n_words': 369, 'path': 'dahu/hpl/hpl_trace_dgemm_frequency.ipynb', 'repo_name': 'Ezibenroc/calibration_analysis', 'size': '4792'}