Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Superlinear: an investigation into concurrent speedup

, 11 Oct 2009
Making more of your cores
Superlinear.zip
Superlinear
Superlinear
Superlinear
bin
Release
data.1.1.dat
data.10.2.dat
data.100.1.dat
data.3.3.dat
steps.24.10.1.dat
Common
Properties
Settings.settings
ZedGraph.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Common;
using ZedGraph;

namespace Superlinear
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();

			Load += HandlesLoad;

			new WinFormsKickstart( this ).Loaded += HandlesLoaded;
		}

		void HandlesLoad( object sender, EventArgs args )
		{
			CreateGraphs();
		}

		void CreateGraphs()
		{
			//zed.IsAutoScrollRange = true;

			//zed.GraphPane.XAxis.Cross = 1;
			zedSize.GraphPane.XAxis.Scale.Min = 0;
			zedSize.GraphPane.XAxis.Scale.Max = 43;
			zedSize.GraphPane.YAxis.Scale.Min = 0.5;
			zedSize.GraphPane.YAxis.Scale.Max = 1.3;

			zedStep.GraphPane.XAxis.Scale.Min = 0;
			zedStep.GraphPane.XAxis.Scale.Max = 20;
			zedStep.GraphPane.YAxis.Scale.Min = 0.0;
			zedStep.GraphPane.YAxis.Scale.Max = 6;
			zedStep.GraphPane.Y2Axis.Scale.Min = 0.0;
			zedStep.GraphPane.Y2Axis.Scale.Max = 60;

			var paneSize = zedSize.GraphPane;
			paneSize.Title.Text = "Efficiency vs Dataset Size for various Repetitions";
			paneSize.XAxis.Title.Text = "Dataset ( MB )";
			paneSize.YAxis.Title.Text = "Efficiency";
			paneSize.GraphObjList.Add( new LineObj( Color.Red, paneSize.XAxis.Scale.Min, 1, paneSize.XAxis.Scale.Max, 1 ) );
			//paneSize.Chart.Fill = new Fill( Color.White, Color.LightGray, 45 );
			paneSize.Chart.Fill = new Fill( Color.AliceBlue );

			var paneStep = zedStep.GraphPane;
			paneStep.Title.Text = "Efficiency and Time vs Stride";
			paneStep.XAxis.Title.Text = "log2( Step )";
			paneStep.YAxis.Title.Text = "Efficiency";
			paneStep.YAxis.Title.FontSpec.FontColor = Color.Blue;
			paneStep.YAxis.Scale.FontSpec.FontColor = Color.Blue;
			paneStep.Y2Axis.Title.Text = "Time ( secs )";
			paneStep.Y2Axis.Title.FontSpec.FontColor = Color.Green;
			paneStep.Y2Axis.Scale.FontSpec.FontColor = Color.Green;
			paneStep.Y2Axis.IsVisible = true;
			paneStep.YAxis.MajorTic.IsOpposite = false;
			paneStep.YAxis.MinorTic.IsOpposite = false;
			paneStep.GraphObjList.Add( new LineObj( Color.Red, paneStep.XAxis.Scale.Min, 1, paneStep.XAxis.Scale.Max, 1 ) );
			paneStep.Chart.Fill = new Fill( Color.AliceBlue );

			zedSize.AxisChange();
			zedStep.AxisChange();
		}

		void HandlesLoaded()
		{
			//return;
			var results = Worker.Work();

			var sybmols = new SymbolType[] { SymbolType.Circle, SymbolType.Diamond, SymbolType.Square, SymbolType.TriangleDown };

			int s = 0;
			foreach ( var effs in results.Repeat )
			{
				var list = new PointPairList();

				foreach ( var eff in effs.Value )
				{
					//list.Add( eff.Key, eff.Value[ 2 ], eff.Value[ 6 ] );
					//list.Add( eff.Key, eff.Value[ 2 ] );
					list.Add( eff.Key, eff.Value.Average() );
				}

				//var curve = zed.GraphPane.AddErrorBar( "label", list, Color.Blue );
				var curve = zedSize.GraphPane.AddCurve( effs.Key.ToString(), list, Color.Blue, sybmols[ s++ ] );
				curve.Symbol.Fill = new Fill( Color.White );
			}

			s = 0;
			foreach ( var repeat in results.RepeatDetails )
			{
				var effs = new PointPairList();
				var seqs = new PointPairList();
				var pars = new PointPairList();

				foreach ( var step in repeat.Value )
				{
					effs.Add( step.Key, step.Value.Average( detail => detail.Eff ) );
					seqs.Add( step.Key, 1 * step.Value.Average( detail => detail.Seq.TotalSeconds ) );
					pars.Add( step.Key, 1 * step.Value.Average( detail => detail.Par.TotalSeconds ) );
				}

				var curveEffs = zedStep.GraphPane.AddCurve( "Efficiency", effs, Color.Blue, sybmols[ s++ ] ); curveEffs.Symbol.Fill = new Fill( Color.White );
				var curveSeqs = zedStep.GraphPane.AddCurve( "Seqential", seqs, Color.Green, sybmols[ s++ ] ); curveSeqs.Symbol.Fill = new Fill( Color.White );
				var curvePars = zedStep.GraphPane.AddCurve( "Parallel", pars, Color.Green, sybmols[ s++ ] ); curvePars.Symbol.Fill = new Fill( Color.White );

				curveSeqs.IsY2Axis = true;
				curvePars.IsY2Axis = true;
			}

			zedSize.Refresh();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nicholas Butler

United Kingdom United Kingdom

I built my first computer, a Sinclair ZX80, on my 11th birthday in 1980.
In 1992, I completed my Computer Science degree and built my first PC.
I discovered C# and .NET 1.0 Beta 1 in late 2000 and loved them immediately.
I have been writing concurrent software professionally, using multi-processor machines, since 1995.
 
In real life, I have spent 3 years travelling abroad,
I have held a UK Private Pilots Licence for 20 years,
and I am a PADI Divemaster.
 
I now live near idyllic Bournemouth in England.
 
If you would like help with multithreading, please contact me via my website:
 
 
I can work 'virtually' anywhere!

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 11 Oct 2009
Article Copyright 2009 by Nicholas Butler
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid