Преглед изворни кода

Add paje statistics tools from Luka

Samuel Thibault пре 11 година
родитељ
комит
bdf84975d3

+ 1 - 0
AUTHORS

@@ -22,6 +22,7 @@ Cyril Roelandt <cyril.roelandt@inria.fr>
 Anthony Roy <theanthony33@gmail.com>
 Corentin Salingue <corentin.salingue@gmail.com>
 Marc Sergent <marc.sergent@inria.fr>
+Luka Stanisic <luka.stanisic@imag.fr>
 Ludovic Stordeur <ludovic.stordeur@inria.fr>
 François Tessier <francois.tessier@inria.fr>
 Samuel Thibault <samuel.thibault@labri.fr>

+ 4 - 0
configure.ac

@@ -2423,6 +2423,8 @@ AC_CONFIG_COMMANDS([executable-scripts], [
   chmod +x tools/starpu_codelet_profile
   chmod +x tools/starpu_codelet_histo_profile
   chmod +x tools/starpu_workers_activity
+  chmod +x tools/starpu_paje_draw_histogram
+  chmod +x tools/starpu_paje_state_stats
   chmod +x doc/doxygen/doxygen_filter.sh
 ])
 
@@ -2450,6 +2452,8 @@ AC_OUTPUT([
 	tools/starpu_codelet_profile
 	tools/starpu_codelet_histo_profile
 	tools/starpu_workers_activity
+	tools/starpu_paje_draw_histogram
+	tools/starpu_paje_state_stats
 	socl/Makefile
 	socl/src/Makefile
 	socl/examples/Makefile

+ 40 - 0
doc/doxygen/chapters/13offline_performance_tools.doxy

@@ -313,6 +313,46 @@ histogram of the codelet execution time distribution.
 \image html distrib_data_histo.png
 \image latex distrib_data_histo.eps "" width=\textwidth
 
+\section TraceStatistics Trace statistics
+
+More than just codelet performance, it is interesting to get statistics over all
+kinds of StarPU states (allocations, data transfers, etc.). This is particularly
+useful to check what may have gone wrong in the accurracy of the simgrid
+simulation.
+
+This requires the <c>R</c> statistical tool, with the plyr, ggplot2 and
+data.table packages. If your system distribution does not have packages for
+these, one can fetch them from CRAN:
+
+\verbatim
+$ R
+> install.packages("plyr")
+> install.packages("ggplot2")
+> install.packages("data.table")
+\endverbatim
+
+One can then get textual or .csv statistics over the trace states:
+
+\verbatim
+$ starpu_paje_state_stats -v native.trace simgrid.trace
+"Value"         "Events_native.csv" "Duration_native.csv" "Events_simgrid.csv" "Duration_simgrid.csv"
+"Callback"      220                 0.075978              220                  0
+"chol_model_11" 10                  565.176               10                   572.8695
+"chol_model_21" 45                  9184.828              45                   9170.719
+"chol_model_22" 165                 64712.07              165                  64299.203
+$ starpu_paje_state_stats native.trace simgrid.trace
+\endverbatim
+
+And one can plot histograms of execution times, of several states for instance:
+\verbatim
+$ starpu_paje_draw_histogram -n chol_model_11,chol_model_21,chol_model_22 native.trace simgrid.trace
+\endverbatim
+
+and see the resulting pdf file:
+
+\image html paje_draw_histogram.png
+\image latex paje_draw_histogram.eps "" width=\textwidth
+
 \section TheoreticalLowerBoundOnExecutionTime Theoretical Lower Bound On Execution Time
 
 StarPU can record a trace of what tasks are needed to complete the

Разлика између датотеке није приказан због своје велике величине
+ 2997 - 0
doc/doxygen/chapters/paje_draw_histogram.eps


BIN
doc/doxygen/chapters/paje_draw_histogram.png


+ 16 - 9
tools/Makefile.am

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2009-2013  Université de Bordeaux 1
+# Copyright (C) 2009-2014  Université de Bordeaux 1
 # Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
 #
 # StarPU is free software; you can redistribute it and/or modify
@@ -122,7 +122,9 @@ endif
 dist_bin_SCRIPTS +=			\
 	starpu_workers_activity		\
 	starpu_codelet_histo_profile	\
-	starpu_codelet_profile
+	starpu_codelet_profile		\
+	starpu_paje_draw_histogram	\
+	starpu_paje_state_stats
 
 if STARPU_HAVE_WINDOWS
 STARPU_MSVC_dir		 =	$(bindir)
@@ -146,25 +148,28 @@ starpu_perfmodel_plot.1: starpu_perfmodel_plot$(EXEEXT)
 	help2man --no-discard-stderr -N --output=$@ ./$<
 starpu_lp2paje.1: starpu_lp2paje$(EXEEXT)
 	help2man --no-discard-stderr -N --output=$@ ./$<
-starpu_workers_activity.1: starpu_workers_activity$(EXEEXT)
+starpu_workers_activity.1: starpu_workers_activity
 	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
-starpu_codelet_profile.1: starpu_codelet_profile$(EXEEXT)
+starpu_codelet_profile.1: starpu_codelet_profile
 	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
-starpu_codelet_histo_profile.1: starpu_codelet_histo_profile$(EXEEXT)
+starpu_codelet_histo_profile.1: starpu_codelet_histo_profile
+	chmod +x $<
+	help2man --no-discard-stderr -N --output=$@ ./$<
+starpu_paje_draw_histogram.1: starpu_paje_draw_histogram
+	chmod +x $<
+	help2man --no-discard-stderr -N --output=$@ ./$<
+starpu_paje_state_stats.1: starpu_paje_state_stats
 	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
 
 if STARPU_USE_FXT
 starpu_fxt_tool.1: starpu_fxt_tool$(EXEEXT)
-	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
 starpu_fxt_stats.1: starpu_fxt_stats$(EXEEXT)
-	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
 starpu_fxt_data_trace.1: starpu_fxt_data_trace$(EXEEXT)
-	chmod +x $<
 	help2man --no-discard-stderr -N --output=$@ ./$<
 endif
 
@@ -176,7 +181,9 @@ dist_man1_MANS =\
 	starpu_lp2paje.1	\
 	starpu_workers_activity.1 \
 	starpu_codelet_profile.1 \
-	starpu_codelet_histo_profile.1
+	starpu_codelet_histo_profile.1 \
+	starpu_paje_draw_histogram.1 \
+	starpu_paje_state_stats.1
 
 if STARPU_USE_FXT
 dist_man1_MANS +=\

+ 110 - 0
tools/starpu_paje_draw_histogram.R

@@ -0,0 +1,110 @@
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+# 
+# Copyright (C) 2014  Imag
+# 
+# StarPU 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 2.1 of the License, or (at
+# your option) any later version.
+# 
+# StarPU 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 Lesser General Public License in COPYING.LGPL for more details.
+
+
+# R script that is giving statistical analysis of the paje trace
+
+# Can be called from the command line with:
+# Rscript $this_script $range1 $range2 $name $outputfile $inputfiles
+
+# Package containing ddply function
+library(plyr)
+library(ggplot2)
+library(data.table)
+
+# Function for reading .csv file
+read_df <- function(file,range1,range2) {
+  df<-read.csv(file, header=FALSE, strip.white=TRUE)
+  names(df) <- c("Nature","ResourceId","Type","Start","End","Duration", "Depth", "Value")
+  df = df[!(names(df) %in% c("Nature","Type", "Depth"))]
+  df$Origin<-file
+
+# Changing names if needed:
+  df$Value <- as.character(df$Value)
+  df$Value <- ifelse(df$Value == "F", "Freeing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "A", "Allocating", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "W", "WritingBack", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "No", "Nothing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "I", "Initializing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "D", "Deinitializing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Fi", "FetchingInput", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Po", "PushingOutput", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "C", "Callback", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "B", "Overhead", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Sl", "Sleeping", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "P", "Progressing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "U", "Unpartitioning", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Ar", "AllocatingReuse", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "R", "Reclaiming", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Co", "DriverCopy", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "CoA", "DriverCopyAsync", as.character(df$Value))
+
+# Considering only the states with a given name
+  if (name != "All")
+    df<-df[df$Value %in% name[[1]],]
+  
+# Aligning to begin time from 0
+  m <- min(df$Start)
+  df$Start <- df$Start - m
+  df$End <- df$Start+df$Duration
+
+# Taking only the states inside a given range
+  df <- df[df$Start>=range1 & df$End<=range2,]
+
+# Return data frame
+  df
+}
+
+#########################################
+#########################################
+# Main
+#########################################
+# Reading command line arguments
+args <- commandArgs(trailingOnly = TRUE)
+range1<-as.numeric(args[1])
+if (range1==-1)
+  range1<-Inf
+range2<-as.numeric(args[2])
+if (range2==-1)
+  range2<-Inf
+name<-strsplit(args[3], ",")
+
+# Reading first file
+filename<-args[4]
+df<-read_df(filename,range1,range2)
+
+i=5
+while (i <= length(args))
+  {
+# Reading next input file
+    filename<-args[i]
+    dft<-read_df(filename,range1,range2)
+
+    df<-rbindlist(list(df,dft))
+    
+    i <- i+1
+  }
+
+# Error: if there is no results for a given range and state
+if (nrow(df)==0)
+  stop("Result is empty!")
+
+# Plotting histograms
+plot <- ggplot(df, aes(x=Duration, fill=..count..)) + geom_histogram(binwidth = diff(range(df$Duration))/30)
+plot <- plot + theme_bw()  + scale_fill_gradient(high = "#132B43", low = "#56B1F7") + ggtitle("Histograms for state distribution") + ylab("Count") + xlab("Time [ms]") + theme(legend.position="none") + facet_grid(Origin~Value,scales = "free_y")
+plot
+
+# End
+write("Done producing a histogram plot. Open Rplots.pdf located in this folder to see the results", stdout())

+ 136 - 0
tools/starpu_paje_draw_histogram.in

@@ -0,0 +1,136 @@
+#!/bin/bash
+
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+# 
+# Copyright (C) 2014  Imag
+# 
+# StarPU 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 2.1 of the License, or (at
+# your option) any later version.
+# 
+# StarPU 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 Lesser General Public License in COPYING.LGPL for more details.
+
+# Script for giving statistical analysis of the paje trace
+
+set -e # fail fast
+
+# File names
+basename="$PWD"
+r_script="$(dirname $(which $0))/starpu_paje_draw_histogram.R"
+r_input=""
+
+# Command line arguments
+range="0:-1"
+name="All"
+verbose=0
+inputfiles=""
+
+help_script()
+{
+cat << EOF
+Give statistical analysis of the paje trace
+
+$0 [ options ] paje.trace [paje.trace2 ...]
+
+Options:
+   -r      To fix range x1:x2 ("-1" for infinity)
+   -n      To choose a certain state
+   -v      Print output to command line
+   -h      Show this message
+
+Examples:
+
+$0 -n chol_model_22 example.native.trace
+
+$0 -r 100:300 -n FetchingInput,Overhead -v example.native.trace example.simgrid.trace
+
+Report bugs to <@PACKAGE_BUGREPORT@>
+EOF
+}
+
+if [ "$1" = "--version" ] ; then
+    echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
+    exit 0
+fi
+
+if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
+    help_script
+    exit 0
+fi
+
+while getopts "r:n:vh" opt; do
+  case $opt in
+     r)
+      range="$OPTARG"
+      ;;
+     n)
+      name="$OPTARG"
+      ;;
+     v)
+      verbose=1
+      ;;
+     h)
+      help_script
+      exit 4
+      ;;
+    \?)
+      echo "Invalid option: -$OPTARG"
+      help_script
+      exit 3
+      ;;
+  esac
+done
+
+# Reading files that need to be analyzed
+shift $((OPTIND - 1))
+inputfiles=$@
+if [[ $# < 1 ]]; then
+    echo "Error!"
+    help_script
+    exit 2
+fi
+
+# Getting range
+range1=$(eval echo $range | cut -d: -f1)
+range2=$(eval echo $range | cut -d: -f2)
+
+#####################################
+# Transforming input files into .csv
+for file in $inputfiles; do
+    if [ ! -s $file ]
+	then
+	echo "Error: file $file does not exist!"
+	exit 5
+    fi
+# Sorting traces
+    head -1000 $file  > start.trace
+    tail --lines=+1001 $file  > end.trace
+    sort -n -s --key=2,2 end.trace > endSorted.trace
+    cat start.trace endSorted.trace > outputSorted.trace
+
+# Transferring to .csv
+    pj_dump -n outputSorted.trace > $file.csv
+    perl -i -ne 'print if /^State/' $file.csv
+
+    r_input=$(eval echo "$r_input $file.csv")
+done
+
+#####################################
+# Running R file to get actual results
+Rscript $r_script $range1 $range2 $name $r_input
+
+# Directly opening .pdf result
+if [[ $verbose == 1 ]]; then
+    evince Rplots.pdf
+fi
+
+# Cleanup: delete temporary files
+rm -f outputSorted.trace
+rm -f start.trace
+rm -f end.trace
+rm -f endSorted.trace

+ 123 - 0
tools/starpu_paje_state_stats.R

@@ -0,0 +1,123 @@
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+# 
+# Copyright (C) 2014  Imag
+# 
+# StarPU 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 2.1 of the License, or (at
+# your option) any later version.
+# 
+# StarPU 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 Lesser General Public License in COPYING.LGPL for more details.
+
+
+# R script that is giving statistical analysis of the paje trace
+
+# Can be called from the command line with:
+# Rscript $this_script $range1 $range2 $name $outputfile $inputfiles
+
+# Package containing ddply function
+library(plyr)
+
+# Function for reading .csv file
+read_df <- function(file,range1,range2) {
+  df<-read.csv(file, header=FALSE, strip.white=TRUE)
+  names(df) <- c("Nature","ResourceId","Type","Start","End","Duration", "Depth", "Value")
+  df = df[!(names(df) %in% c("Nature","Type", "Depth"))]
+
+# Changing names if needed:
+  df$Value <- as.character(df$Value)
+  df$Value <- ifelse(df$Value == "F", "Freeing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "A", "Allocating", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "W", "WritingBack", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "No", "Nothing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "I", "Initializing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "D", "Deinitializing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Fi", "FetchingInput", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Po", "PushingOutput", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "C", "Callback", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "B", "Overhead", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Sl", "Sleeping", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "P", "Progressing", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "U", "Unpartitioning", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Ar", "AllocatingReuse", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "R", "Reclaiming", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "Co", "DriverCopy", as.character(df$Value))
+  df$Value <- ifelse(df$Value == "CoA", "DriverCopyAsync", as.character(df$Value))
+
+# Considering only the states with a given name
+  if (name != "All")
+    df<-df[df$Value %in% name[[1]],]
+  
+# Aligning to begin time from 0
+  m <- min(df$Start)
+  df$Start <- df$Start - m
+  df$End <- df$Start+df$Duration
+
+# Taking only the states inside a given range
+  df <- df[df$Start>=range1 & df$End<=range2,]
+
+# Return data frame
+  df
+}
+
+#########################################
+#########################################
+# Main
+#########################################
+# Reading command line arguments
+args <- commandArgs(trailingOnly = TRUE)
+range1<-as.numeric(args[1])
+if (range1==-1)
+  range1<-Inf
+range2<-as.numeric(args[2])
+if (range2==-1)
+  range2<-Inf
+name<-strsplit(args[3], ",")
+outputfile<-args[4]
+
+# Reading first file
+filename<-args[5]
+df<-read_df(filename,range1,range2)
+
+# Getting summary of the first file
+dfout<-ddply(df, c("Value"), summarize, Events_ = length(as.numeric(Duration)), Duration_ = sum(as.numeric(Duration)))
+names(dfout)<-c("Value",sprintf("Events_%s",filename),sprintf("Duration_%s",filename))
+
+i=6
+while (i <= length(args))
+  {
+# Reading next input file
+    filename<-args[i]
+    df<-read_df(filename,range1,range2)
+
+# Getting summary of the next file
+    dp<-ddply(df, c("Value"), summarize, Events_ = length(as.numeric(Duration)), Duration_ = sum(as.numeric(Duration)))
+    names(dp)<-c("Value",sprintf("Events_%s",filename),sprintf("Duration_%s",filename))
+
+# Merging results into one single data frame
+    if (nrow(dp)>0)
+      {
+        if (nrow(dfout)>0)
+          dfout<-merge(dfout,dp, by = "Value", all=TRUE)
+        else
+          dfout<-dp
+      }
+    
+    i <- i+1
+  }
+
+# Cosmetics: change NA to 0
+dfout[is.na(dfout)] <- 0
+
+# Error: if there is no results for a given range and state
+if (nrow(dfout)==0)
+  stop("Result is empty!")
+
+# Write results into the new .csv file
+write.table(dfout, file=outputfile, row.names=FALSE, sep = ", ")
+
+

+ 137 - 0
tools/starpu_paje_state_stats.in

@@ -0,0 +1,137 @@
+#!/bin/bash
+
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+# 
+# Copyright (C) 2014  Imag
+# 
+# StarPU 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 2.1 of the License, or (at
+# your option) any later version.
+# 
+# StarPU 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 Lesser General Public License in COPYING.LGPL for more details.
+
+# Script for giving statistical analysis of the paje trace
+
+set -e # fail fast
+
+# File names
+basename="$PWD"
+outputfile="starpu_paje_state_stats.csv"
+r_script="$(dirname $(which $0))/starpu_paje_state_stats.R"
+r_input=""
+
+# Command line arguments
+range="0:-1"
+name="All"
+verbose=0
+inputfiles=""
+
+help_script()
+{
+cat << EOF
+Give statistical analysis of the paje trace
+
+$0 [ options ] paje.trace [paje.trace2 ...]
+
+Options:
+   -r      To fix range x1:x2 ("-1" for infinity)
+   -n      To choose a certain state
+   -v      Print output to command line
+   -h      Show this message
+
+Examples:
+
+$0 example.native.trace
+
+$0 -r 100:300 -n FetchingInput -v example.native.trace example.simgrid.trace
+
+Report bugs to <@PACKAGE_BUGREPORT@>
+EOF
+}
+
+if [ "$1" = "--version" ] ; then
+    echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
+    exit 0
+fi
+
+if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
+    help_script
+    exit 0
+fi
+
+while getopts "r:n:vh" opt; do
+  case $opt in
+     r)
+      range="$OPTARG"
+      ;;
+     n)
+      name="$OPTARG"
+      ;;
+     v)
+      verbose=1
+      ;;
+     h)
+      help_script
+      exit 4
+      ;;
+    \?)
+      echo "Invalid option: -$OPTARG"
+      help_script
+      exit 3
+      ;;
+  esac
+done
+
+# Reading files that need to be analyzed
+shift $((OPTIND - 1))
+inputfiles=$@
+if [[ $# < 1 ]]; then
+    echo "Error!"
+    help_script
+    exit 2
+fi
+
+# Getting range
+range1=$(eval echo $range | cut -d: -f1)
+range2=$(eval echo $range | cut -d: -f2)
+
+#####################################
+# Transforming input files into .csv
+for file in $inputfiles; do
+    if [ ! -s $file ]
+	then
+	echo "Error: file $file does not exist!"
+	exit 5
+    fi
+# Sorting traces
+    head -1000 $file  > start.trace
+    tail --lines=+1001 $file  > end.trace
+    sort -n -s --key=2,2 end.trace > endSorted.trace
+    cat start.trace endSorted.trace > outputSorted.trace
+
+# Transferring to .csv
+    pj_dump -n outputSorted.trace > $file.csv
+    perl -i -ne 'print if /^State/' $file.csv
+
+    r_input=$(eval echo "$r_input $file.csv")
+done
+
+#####################################
+# Running R file to get actual results
+Rscript $r_script $range1 $range2 $name $outputfile $r_input
+
+# If verbose then write results to stdout
+if [[ $verbose == 1 ]]; then
+    column -s, -t $outputfile
+fi
+
+# Cleanup: delete temporary files
+rm -f outputSorted.trace
+rm -f start.trace
+rm -f end.trace
+rm -f endSorted.trace