gen_times_taskdep.R 3.16 KB
Newer Older
Martin Khannouz's avatar
Martin Khannouz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
library(plyr)
library(reshape)
library(ggplot2)


gen_times_taskdep_plot <- function(data, algo_wanted, model_wanted)
{
    # Sort data to have task, runtime and idle.
	subdata <- subset(data, model == model_wanted && algo == algo_wanted)
	subdata$rmem <- NULL
	subdata$global_time <- NULL
	subdata <- melt(subdata, id=c("model", "algo", "nnode", "nthreads", "npart","height","bsize"))
	subdata <- rename(subdata, c("variable"="event", "value"="duration"))
	#subdata <- subdata[order(subdata$event, decreasing = TRUE),] 
    g <- ggplot(data=subdata, aes(x=nnode, y=duration, fill=event))
	g <- g + geom_bar(stat="identity", position="fill")

	#Pour le titre
	g <- g + facet_wrap(npart ~ height, scales="free",
						labeller = labeller(npart = as_labeller(npart_labeller),
											height = as_labeller(height_labeller),
											.default=label_both,
											.multi_line=FALSE))
    # Set colors.
	breaks <- c('idle_time', 'communication_time', 'runtime_time', 'scheduling_time', 'task_time')
	labels <- c('Idle', 'Communication', 'Runtime', 'Scheduling', 'Task')
	colors <- c(
		'task_time'      = "#619dff",
		'runtime_time'   = "#01ba38",
		'idle_time'      = "#f9766e",
		'scheduling_time'   = "#02bb37",
		'communication_time'   = "#9D2FEA"
	)
	g <- g + scale_fill_manual(name="Time", breaks=breaks,
							   labels=labels, values=colors)

    # Set title and X/Y labels.
    g <- g + xlab("Number of nodes")
    g <- g + ylab("% of time")

	output <- paste(algo_wanted, "-", model_wanted, "-times.pdf", sep="")
    # Save generated plot.
    ggsave(output, g, width=29.7, height=21, units=c("cm"), device=cairo_pdf)
	print(output)
}

#Use this function to normalize
compute_timings <- function(data, n, h, m)
{
    # Select data
    sdata <- subset(data, npart == n & height == h & model == m)

    # Select Tt(1)
    tt_1 <- subset(sdata, event == "task_time" & nthreads == 1)

    # Compute task efficiency
    tt_p <- subset(sdata, event == "task_time")
    tt_p$event <- "task"
    tt_p$efficiency <- tt_p$duration / tt_1$duration

    # Compute scheduling efficiency
    ts_p <- subset(sdata, event == "scheduling_time")
    ts_p$event <- "scheduling"
    ts_p$efficiency <- ts_p$duration / tt_1$duration

    # Compute runtime efficiency
    tr_p <- subset(sdata, event == "runtime_time")
    tr_p$event <- "runtime"
    tr_p$efficiency <- tr_p$duration / tt_1$duration

    # Compute pipeline efficiency
    ti_p <- subset(sdata, event == "idle_time")
    ti_p$event <- "idle"
    ti_p$efficiency <- ti_p$duration / tt_1$duration

    # Merge all efficiencies
    sdata <- rbind(tt_p, ts_p, tr_p, ti_p)

    return (sdata)
}

gen_times_taskdep <- function(dbfile)
{
    # Cube (volume)
    data <- get_data_subset(dbfile, 0L, 0L, "False")

	all_algorithm <- unique(data$algo)
	all_model <- unique(data$model)
	for (i in 1:length(all_algorithm))
	{
		for (j in 1:length(all_model))
		{
			gen_times_taskdep_plot(data, all_algorithm[i], all_model[j])
		}
	}

    # Ellipsoid (Surface)
    #data <- get_data_subset(dbfile, 0L, 0L, "True")
    #data <- subset(data, name == compiler)
    #output <- paste("times_taskdep/", machine, "_", compiler, "_ellipsoid.pdf", sep="")
    #gen_times_taskdep_plot(output, data)
}