Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://doi.org/10.5201/ipol.2022.215
11 April 2026, 15:45:18 UTC
  • Code
  • Branches (0)
  • Releases (2)
  • Visits
    • Branches
    • Releases
      • 2
      • 2
      • 1
    • c530314
    • /
    • paraws
    • /
    • bench_paraws.py
    Raw File Download

    To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
    Select below a type of object currently browsed in order to display its associated SWHID and permalink.

    • content
    • directory
    • snapshot
    • release
    origin badgecontent badge
    swh:1:cnt:91a9cfafb0058d29322ba840710e752f88647491
    origin badgedirectory badge
    swh:1:dir:bb309b6c220124321a1ac969488a1621c674679d
    origin badgesnapshot badge
    swh:1:snp:78d18a3e9f4a56ecaf1e6817d370abae618d0a7c
    origin badgerelease badge
    swh:1:rel:f3a4320e8346f38185539583336571c1b856fc47

    This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
    Select below a type of object currently browsed in order to generate citations for them.

    • content
    • directory
    • snapshot
    • release
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    bench_paraws.py
    import subprocess
    import matplotlib as mpl
    mpl.use('Agg')
    import matplotlib.pyplot as plt
    #from matplotlib2tikz import save as tikz_save
    import os
    import numpy as np
    from sys import stdout
    import pdb
    
    def mean(numbers):
        return float(sum(numbers))/max(len(numbers),1)
    
    def exec_paraws (N, nbr_threads):
        os.environ['OMP_NUM_THREADS'] = str(nbr_threads)
        try:
          output_str = subprocess.check_output(["./paraws","-A","-x",str(N),"-y",str(N),"-z",str(N),"-C", "-w"])
          output = float(output_str)
        except:
          output = -1
        return output
    
    def exec_hqws (N, nbr_threads):
        os.environ['OMP_NUM_THREADS'] = str(nbr_threads)
        try:
          output_str = subprocess.check_output(["./paraws", "-B","-x",str(N),"-y",str(N),"-z",str(N),"-C", "-w"])
          output = float(output_str)
        except:
          output = -1
        return output
    
    def exec_both (N, nbr_threads):
        os.environ['OMP_NUM_THREADS'] = str(nbr_threads)
        try:
          output_str = subprocess.check_output(["./paraws","-AB","-x",str(N),"-y",str(N),"-z",str(N),"-C", "-w"])
          output = [float(s) for s in output_str.split()]
        except:
          output = [-1,-1]
        return output
    
    def plot_time (T1, T2, S):
        plt.title ('Time evaluation')
        plt.xlabel('Size (N*N)')
        plt.ylabel('Time (s)')
        plt.plot(S,T1)
        plt.plot(S,T2)
        plt.savefig ('time.pdf')
    #   tikz_save ('time.tikz', show_info=False)
        plt.clf()
    
    def plot_speed_up (S, T, N):
        plt.title ('Speed-up measure for matrix of size ' + str(N) + '*' + str(N))
        plt.xlabel('Number of threads')
        plt.ylabel('Speed-up')
        plt.plot(T,S)
        plt.savefig ('speedup.pdf')
    #   tikz_save ('speedup.tikz', show_info=False)
        plt.clf()
    
    def plot_efficiency (E, T, N):
        plt.title ('Efficiency measure for matrix of size ' + str(N) + '*' + str(N))
        plt.xlabel('Number of threads')
        plt.ylabel('Efficiency')
        plt.plot(T,E)
        plt.savefig ('efficiency.pdf')
    #   tikz_save ('efficiency.tikz', show_info=False)
        plt.clf()
    
    def print_progress (current, total, i, nbr_iter, time1, time2):
      percent_done = int(current) * 100. /total
      done = int (50*current / int(total))
      stdout.write ("\r [%s%s][%d/%d] (%d/%d) paraws: %3.3f, hqws: %3.3f%s" % ('=' * done, ' ' * (50 - done), current, total, i, nbr_iter, time1, time2, ' '*10))
      stdout.flush ()
    
    nbr_threads_max = 32
    nbr_runs = 10
    
    time_paraws = []
    time_hqws = []
    size = [i*100+100 for i in range(10)]
    stdout.write ("Size bench\n")
    for N in size:
        out_paraws = []
        out_hqws = []
    
        for i in range(nbr_runs):
          output = exec_both(N, nbr_threads_max)
          out_paraws.append (output[0])
          out_hqws.append (output[1])
          print_progress (N, 1000, i, nbr_runs, out_paraws[-1], out_hqws[-1])
        output = [mean([x for x in out_paraws if x>0]), mean([x for x in out_hqws if x>0])]
        time_paraws.append (output[0])
        time_hqws.append (output[1])
    stdout.write ("\n")
    plot_time(time_paraws, time_hqws,size)
    
    size = np.array (size)
    time_paraws = np.array (time_paraws)
    time_hqws = np.array (time_hqws)
    np.save ('size.npy', size)
    np.save ('time_paraws.npy', time_hqws)
    np.save ('time_hqws.npy', time_paraws)
    
    N = 800
    threads = range(1,nbr_threads_max+1)
    time2 = []
    stdout.write ("Multithread bench\n")
    for t in threads:
        output_bench = []
        for i in range(nbr_runs):
          output_bench.append (exec_paraws(N, t))
          print_progress (t, nbr_threads_max, i, nbr_runs, output_bench[-1], 0)
        output = mean([x for x in output_bench if x>0])
        time2.append (output)
    stdout.write ("\n")
    speedup = [time2[0]/time2[i] for i in range(len(time2))]
    plot_speed_up (speedup,threads,N)
    
    efficiency = [speedup[i]/(i+1) for i in range(len(speedup))]
    plot_efficiency(efficiency,threads,N)
    
    threads = np.array (threads)
    speedup = np.array (speedup)
    efficiency = np.array (efficiency)
    
    np.save ('threads.npy', threads)
    np.save ('speedup.npy', speedup)
    np.save ('efficiency.npy', efficiency)
    
    

    back to top

    Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
    The source code of Software Heritage itself is available on our development forge.
    The source code files archived by Software Heritage are available under their own copyright and licenses.
    Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API