gen_parallel_efficiency_plots.R 2.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
library(plyr)
library(ggplot2)

calc_parallel_efficiency <- function(data, ref_name)
{
    # XXX: Most likely suboptimal but it works as expected!
	# NOTE does it really make sense to compare with an mpi version on only one node ?
    for (i in 1:length(ref_name)) {
        data_ref <- subset(data, algo == ref_name[i])

        for (j in 1:nrow(data)) {
            if (data$algo[j] == ref_name[i]) {
                tmp_ref <- subset(data_ref, npart == data$npart[j])
                tmp_ref <- subset(tmp_ref, height == data$height[j])

                seq_time <- subset(tmp_ref, nnode == 1)
                tid = as.integer(as.vector(data$nnode[j]))
Martin Khannouz's avatar
Martin Khannouz committed
18 19 20 21 22 23 24 25 26 27 28 29
				if(nrow(subset(tmp_ref, nnode == 1)) == 0)
				{
					data$efficiency[j] <- NA
				}
				else if(data$global_time[j] == 0)
				{
					data$efficiency[j] <- NA
				}
				else 
				{
					data$efficiency[j] <- seq_time$global_time / (data$global_time[j] * tid)
				}
30 31 32 33 34 35 36 37 38 39 40
            }
        }
    }
    return (data)
}

gen_pareff_plot <- function(db, d_breaks, model_wanted)
{
	db <- subset(db, model == model_wanted)
    db <- calc_parallel_efficiency(db, d_breaks)

Martin Khannouz's avatar
Martin Khannouz committed
41
	db <- db[!(is.na(db$efficiency)),]
42 43 44 45 46 47 48 49 50
	if(nrow(db) > 0)
	{
		g <- ggplot(data=db,aes_string(x="nnode", y="efficiency", color="algo"))
		g <- g + geom_line()
		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))
51

52 53 54 55 56
		# Set our own colors, linetypes and point shapes.
		g <- g + scale_color_manual(name="Algorithm",
									breaks=get_breaks_runtime(),
									labels=get_labels_runtime(),
									values=get_colors_runtime())
57

58 59 60
		# Set X/Y labels.
		g <- g + xlab("Number of nodes")
		g <- g + ylab("Parallel efficiency")
Martin Khannouz's avatar
Martin Khannouz committed
61
		g <- g + get_theme()
62

63 64 65 66
		# Save generated plot.
		output <- paste(get_output_directory(), "/", model_wanted, "-parallel-efficiency.pdf", sep="")
		ggsave(output, g, width=29.7, height=21, units=c("cm"), device=cairo_pdf)
	}
67 68 69 70 71
}

gen_pareff <- function(dbfile)
{
    file  <- paste(dbfile, sep="")
Martin Khannouz's avatar
Martin Khannouz committed
72
    data <- get_data_subset(dbfile, 0L, 0L, "False", get_bsize_reference())
73
	data <- subset(data, algo != get_one_node_reference_algorithm())
74
	data <- subset(data, global_time >= 0)
75 76 77 78 79 80
	all_model <- unique(data$model)
	for (i in 1:length(all_model))
	{
		gen_pareff_plot(data, unique(data$algo), all_model[i])
	}
}