Skip to content
Snippets Groups Projects
Select Git revision
  • ea00979e46fde936b5ac13e33004dad7e2edbaab
  • master default protected
  • zoom-mesh-considerations
  • improve-snap-to-ic
  • darwin/sink_tasks_refactored
  • karapiperis/Bcomoving_as_a2_Bphysical
  • FS_VP_m2_allGrad
  • fstasys/VEP_Fm2
  • zoom_merge protected
  • split-space-split
  • reyz/gear_preSN_feedback
  • reyz/debug
  • darwin/gear_preSN_fbk_merge
  • darwin/gear_chemistry_fluxes
  • gas-splitting
  • stars_sidm_iact
  • karapiperis/plasma_beta_rms_in_tensile_instability_correction_taper_function
  • darwin/gear_mechanical_feedback
  • karapiperis/consistent_treatment_of_vsig_in_MHD
  • examples-GravityTests-HydroStatic-halo-issue
  • fof_props
  • v2025.10 protected
  • v2025.04 protected
  • v2025.01 protected
  • v1.0.0 protected
  • v0.9.0 protected
  • v0.8.5 protected
  • v0.8.4 protected
  • v0.8.3 protected
  • v0.8.2 protected
  • v0.8.1 protected
  • v0.8.0 protected
  • v0.7.0 protected
  • v0.6.0 protected
  • v0.5.0 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0-pre protected
  • v0.1 protected
  • v0.0 protected
41 results

process_plot_taskthreadpools

Blame
  • process_plot_taskthreadpools 3.15 KiB
    #!/bin/bash
    #
    # Usage:
    #  process_plot_taskthreadpools nprocess time-range-ms
    #
    # Description:
    #  Process all the tasks thread and threadpool info in the current directory
    #  creating graphs for steps and threads.
    #
    #  The input files are created by a run using the "-y interval" and 
    #  "-Y interval" flags, with the same interval. The output files
    #  from these stages will be named "thread_info-step<n>.dat" 
    #  and "threadpool_info-step<n>.dat" in the current directory.
    #  All located files will be processed using "nprocess" concurrent
    #  processes and all plots will have the given time range. An output
    #  HTML file "threadtaskpools.html" will be created to view all the plots.
    #
    # This file is part of SWIFT:
    #
    #  Copyright (C) 2017 Peter W. Draper (p.w.draper@durham.ac.uk)
    #  All Rights Reserved.
    #
    #  This program is free software: you can redistribute it and/or modify
    #  it under the terms of the GNU Lesser General Public License as published
    #  by the Free Software Foundation, either version 3 of the License, or
    #  (at your option) any later version.
    #
    #  This program is distributed in the hope that it will be useful,
    #  but WITHOUT ANY WARRANTY; without even the implied warranty of
    #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #  GNU General Public License for more details.
    #
    #  You should have received a copy of the GNU Lesser General Public License
    #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    #  Handle command-line
    if test "$2" == ""; then
        echo "Usage: $0 nprocess time-range-ms"
        exit 1
    fi
    NPROCS=$1
    TIMERANGE=$2
    
    #  Locate script.
    SCRIPTHOME=$(dirname "$0")
    
    #  Find all thread info files. Use version sort to get into correct order.
    taskfiles=$(ls -v thread_info-step*.dat)
    if test $? != 0; then
        echo "Failed to find any thread info files"
        exit 1
    fi
    
    #  Construct the expected names of the threadpool files and merge.
    list=""
    for f in $taskfiles; do
        s=$(echo $f| sed 's,thread_info-step\(.*\).dat,\1,')
        p="threadpool_info-step${s}.dat"
        if ! test -f "$p"; then
            exit "Cannot find threadpool file: $p, that matches $f"
        fi
        list="$list $f $p $s"
    done
    
    echo "Processing thread info files..."
    echo $list | xargs -P $NPROCS -n 3 /bin/bash -c "${SCRIPTHOME}/process_plot_taskthreadpools_helper $TIMERANGE \$0 \$1 \$2 "
    
    output="taskpool.html"
    echo "Writing output $output file"
    #  Construct document - serial.
    cat <<EOF > $output
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>SWIFT task and threadpool graphs</title>
      </head>
      <body>
      <h1>SWIFT task and threadpool graphs</h1>
    EOF
    
    echo $list | xargs -n 3 | while read f p s; do
        cat <<EOF >> $output
    <h2>Step $s</h2>
    EOF
        cat <<EOF >> $output
    <a href="taskpoolstep${s}r${i}.html"><img src="taskstep${s}r${i}.png" width=400px/></a>
    <a href="taskpoolstep${s}r${i}.html"><img src="poolstep${s}r${i}.png" width=400px/></a>
    EOF
        cat <<EOF > taskpoolstep${s}r${i}.html
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <body>
    <img src="taskstep${s}r${i}.png">
    <img src="poolstep${s}r${i}.png">
    </body>
    </html>
    EOF
    
    done
    
    cat <<EOF >> $output
      </body>
    </html>
    EOF
    
    echo "Finished"
    
    exit