<commit_before>#!/usr/bin/python
import os
import sys
from math import sqrt
from matplotlib import pyplot
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from datetime import datetime


def timesFromFile(fileName):
    return [float(line) for line in open(fileName)]

def avg(xs):
    return sum(xs) / len(xs)

def plotSpeedUp(threadTimes, fileName):
    xticks = range(1, len(threadTimes)+1)

    alltimes = threadTimes.values()

    oneThreadAvgTime = avg(threadTimes[1])

    allSpeedUps = [[oneThreadAvgTime / t for t in ts] for ts in alltimes]

    avgSpeedUps = [avg(ts) for ts in allSpeedUps]

    fig = pyplot.figure(figsize=(20, 10))

    pyplot.plot(xticks, avgSpeedUps, '-', c="grey")


    pyplot.boxplot(allSpeedUps)

    pyplot.xticks(xticks, threadTimes.keys())

    ax = fig.add_subplot(1,1,1)

    ax.xaxis.set_major_locator(MultipleLocator(4))
    ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
    ax.xaxis.set_minor_locator(MultipleLocator(1))

    ax.yaxis.set_major_locator(MultipleLocator(2))
    ax.yaxis.set_minor_locator(MultipleLocator(0.5))

    ax.xaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)
    ax.yaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)

    ax.xaxis.grid(True,'major',linestyle='-', color='0.5', linewidth=1)


    ax.set_axisbelow(True)

    pyplot.ylim(0)

    pyplot.title('MatMul (SMP, 1000x1000)')
    pyplot.xlabel('OMP_NUM_THREADS')
    pyplot.ylabel('SpeedUp')
    pyplot.show()
    pyplot.savefig(fileName, dpi=80)


def plotBurnDown(threadTimes, fileName):
    xticks = range(1, len(threadTimes)+1)

    alltimes = threadTimes.values()

    oneThreadAvgTime = avg(threadTimes[1])

    allSpeedUps = [[oneThreadAvgTime / t / threads for t in ts] for threads, ts in threadTimes.items()]

    avgSpeedUps = [avg(ts) for ts in allSpeedUps]

    fig = pyplot.figure(figsize=(20, 10))

    pyplot.plot(xticks, avgSpeedUps, '-', c="grey")


    pyplot.boxplot(allSpeedUps)

    pyplot.xticks(xticks, threadTimes.keys())

    ax = fig.add_subplot(1,1,1)

    ax.xaxis.set_major_locator(MultipleLocator(4))
    ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
    ax.xaxis.set_minor_locator(MultipleLocator(1))

    ax.yaxis.set_major_locator(MultipleLocator(0.5))
    ax.yaxis.set_minor_locator(MultipleLocator(0.1))

    ax.xaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)
    ax.yaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)

    ax.xaxis.grid(True,'major',linestyle='-', color='0.5', linewidth=1)


    ax.set_axisbelow(True)

    pyplot.ylim(0)

    pyplot.title('MatMul (SMP, 1000x1000)')
    pyplot.xlabel('OMP_NUM_THREADS')
    pyplot.ylabel('Burndown (SpeedUp / Thread)')
    pyplot.show()
    pyplot.savefig(fileName, dpi=80)



file_dir = sys.argv[1]
iterations = int(sys.argv[2]) if (len(sys.argv)>2) else 100
warmups = iterations / 10
matrixSize = 1000


def timeFile(smpHosts, cudaHosts, ext = ".txt"):
    hostsString = ",".join(smpHosts) + "-" + ",".join(cudaHosts)
    return os.path.join(file_dir, "matmul_cluster_{0}_{1}{2}".format(hostsString, matrixSize, ext))

def commandLine(smpHosts, cudaHosts):
    hostLine =  "-host {0} -np 1 ./build/src/main/dwarf_mine -m {1} -c matrix -w {3} -n {4} --time_output {5} "\
                "--left_rows {2} --common_rows_columns {2} --right_columns {2}"

    timeFileName = timeFile(smpHosts, cudaHosts)
    smpLines = [hostLine.format(host, "smp", matrixSize, warmups, iterations, timeFileName) for host in smpHosts]
    cudaLines = [hostLine.format(host, "cuda", matrixSize, warmups, iterations, timeFileName) for host in cudaHosts]

    mpirunArgs = " : ".join(smpLines + cudaLines)

    return "mpirun --tag-output %s" % mpirunArgs


def main():<commit_msg>rename label in ClusterBenchmark script<commit_after>#!/usr/bin/python
import os
import sys
from math import sqrt
from matplotlib import pyplot
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from datetime import datetime


def timesFromFile(fileName):
    return [float(line) for line in open(fileName)]

def avg(xs):
    return sum(xs) / len(xs)

def plotSpeedUp(threadTimes, fileName):
    xticks = range(1, len(threadTimes)+1)

    alltimes = threadTimes.values()

    oneThreadAvgTime = avg(threadTimes[1])

    allSpeedUps = [[oneThreadAvgTime / t for t in ts] for ts in alltimes]

    avgSpeedUps = [avg(ts) for ts in allSpeedUps]

    fig = pyplot.figure(figsize=(20, 10))

    pyplot.plot(xticks, avgSpeedUps, '-', c="grey")


    pyplot.boxplot(allSpeedUps)

    pyplot.xticks(xticks, threadTimes.keys())

    ax = fig.add_subplot(1,1,1)

    ax.xaxis.set_major_locator(MultipleLocator(4))
    ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
    ax.xaxis.set_minor_locator(MultipleLocator(1))

    ax.yaxis.set_major_locator(MultipleLocator(2))
    ax.yaxis.set_minor_locator(MultipleLocator(0.5))

    ax.xaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)
    ax.yaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)

    ax.xaxis.grid(True,'major',linestyle='-', color='0.5', linewidth=1)


    ax.set_axisbelow(True)

    pyplot.ylim(0)

    pyplot.title('MatMul (SMP, 1000x1000)')
    pyplot.xlabel('MPI processes')
    pyplot.ylabel('SpeedUp')
    pyplot.show()
    pyplot.savefig(fileName, dpi=80)


def plotBurnDown(threadTimes, fileName):
    xticks = range(1, len(threadTimes)+1)

    alltimes = threadTimes.values()

    oneThreadAvgTime = avg(threadTimes[1])

    allSpeedUps = [[oneThreadAvgTime / t / threads for t in ts] for threads, ts in threadTimes.items()]

    avgSpeedUps = [avg(ts) for ts in allSpeedUps]

    fig = pyplot.figure(figsize=(20, 10))

    pyplot.plot(xticks, avgSpeedUps, '-', c="grey")


    pyplot.boxplot(allSpeedUps)

    pyplot.xticks(xticks, threadTimes.keys())

    ax = fig.add_subplot(1,1,1)

    ax.xaxis.set_major_locator(MultipleLocator(4))
    ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
    ax.xaxis.set_minor_locator(MultipleLocator(1))

    ax.yaxis.set_major_locator(MultipleLocator(0.5))
    ax.yaxis.set_minor_locator(MultipleLocator(0.1))

    ax.xaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)
    ax.yaxis.grid(True,'minor',linestyle='-', color='0.95', linewidth=1)

    ax.xaxis.grid(True,'major',linestyle='-', color='0.5', linewidth=1)


    ax.set_axisbelow(True)

    pyplot.ylim(0)

    pyplot.title('MatMul (SMP, 1000x1000)')
    pyplot.xlabel('MPI processes')
    pyplot.ylabel('Burndown (SpeedUp / Thread)')
    pyplot.show()
    pyplot.savefig(fileName, dpi=80)



file_dir = sys.argv[1]
iterations = int(sys.argv[2]) if (len(sys.argv)>2) else 100
warmups = iterations / 10
matrixSize = 1000


def timeFile(smpHosts, cudaHosts, ext = ".txt"):
    hostsString = ",".join(smpHosts) + "-" + ",".join(cudaHosts)
    return os.path.join(file_dir, "matmul_cluster_{0}_{1}{2}".format(hostsString, matrixSize, ext))

def commandLine(smpHosts, cudaHosts):
    hostLine =  "-host {0} -np 1 ./build/src/main/dwarf_mine -m {1} -c matrix -w {3} -n {4} --time_output {5} "\
                "--left_rows {2} --common_rows_columns {2} --right_columns {2}"

    timeFileName = timeFile(smpHosts, cudaHosts)
    smpLines = [hostLine.format(host, "smp", matrixSize, warmups, iterations, timeFileName) for host in smpHosts]
    cudaLines = [hostLine.format(host, "cuda", matrixSize, warmups, iterations, timeFileName) for host in cudaHosts]

    mpirunArgs = " : ".join(smpLines + cudaLines)

    return "mpirun --tag-output %s" % mpirunArgs


def main():
{'fraction_non_alphanumeric': 0.15150713907985194, 'fraction_numerical': 0.02617662612374405, 'mean_word_length': 4.206469373709567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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}}
{'dir': 'git-commits-cleaned', 'id': '2729429', 'n_tokens_mistral': 3013, 'n_tokens_neox': 2810, 'n_words': 503}