Click here to Skip to main content
15,891,777 members
Articles / Programming Languages / C#

Multicore Speedup Analysis using Jacobi Relaxation Running on Multiple Threads

Rate me:
Please Sign up or sign in to vote.
3.18/5 (8 votes)
10 Jul 2007CPOL3 min read 39K   220   16  
Analyse the speedup achieved by multicore processors by running a computation intensive task, using multithreading to create 1 separate thread per processor.
namespace Jacobi_RedBlack
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.pictureCanvas = new System.Windows.Forms.PictureBox();
            this.buttonStart = new System.Windows.Forms.Button();
            this.buttonStop = new System.Windows.Forms.Button();
            this.textBoxLoopCount = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.pictureBoxScale = new System.Windows.Forms.PictureBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.radioButtonGrey = new System.Windows.Forms.RadioButton();
            this.radioButtonColor = new System.Windows.Forms.RadioButton();
            this.groupBoxCanvas = new System.Windows.Forms.GroupBox();
            this.textBoxHeight = new System.Windows.Forms.TextBox();
            this.textBoxWidth = new System.Windows.Forms.TextBox();
            this.labelHeight = new System.Windows.Forms.Label();
            this.labelWidth = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.pictureCanvas)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxScale)).BeginInit();
            this.groupBox1.SuspendLayout();
            this.groupBoxCanvas.SuspendLayout();
            this.SuspendLayout();
            // 
            // pictureCanvas
            // 
            this.pictureCanvas.BackColor = System.Drawing.Color.Black;
            this.pictureCanvas.Location = new System.Drawing.Point(47, 12);
            this.pictureCanvas.Name = "pictureCanvas";
            this.pictureCanvas.Size = new System.Drawing.Size(100, 100);
            this.pictureCanvas.TabIndex = 0;
            this.pictureCanvas.TabStop = false;
            // 
            // buttonStart
            // 
            this.buttonStart.Location = new System.Drawing.Point(577, 52);
            this.buttonStart.Name = "buttonStart";
            this.buttonStart.Size = new System.Drawing.Size(177, 33);
            this.buttonStart.TabIndex = 1;
            this.buttonStart.Text = "Start Processing";
            this.buttonStart.UseVisualStyleBackColor = true;
            this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click);
            // 
            // buttonStop
            // 
            this.buttonStop.Enabled = false;
            this.buttonStop.Location = new System.Drawing.Point(577, 91);
            this.buttonStop.Name = "buttonStop";
            this.buttonStop.Size = new System.Drawing.Size(177, 34);
            this.buttonStop.TabIndex = 2;
            this.buttonStop.Text = "Stop Processing";
            this.buttonStop.UseVisualStyleBackColor = true;
            this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click);
            // 
            // textBoxLoopCount
            // 
            this.textBoxLoopCount.Location = new System.Drawing.Point(679, 13);
            this.textBoxLoopCount.Name = "textBoxLoopCount";
            this.textBoxLoopCount.Size = new System.Drawing.Size(75, 20);
            this.textBoxLoopCount.TabIndex = 3;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(574, 16);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(99, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Current Loop Count";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(8, 517);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(34, 13);
            this.label2.TabIndex = 6;
            this.label2.Text = "Scale";
            // 
            // pictureBoxScale
            // 
            this.pictureBoxScale.Location = new System.Drawing.Point(12, 12);
            this.pictureBoxScale.Name = "pictureBoxScale";
            this.pictureBoxScale.Size = new System.Drawing.Size(18, 500);
            this.pictureBoxScale.TabIndex = 8;
            this.pictureBoxScale.TabStop = false;
            this.pictureBoxScale.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxScale_Paint);
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.radioButtonGrey);
            this.groupBox1.Controls.Add(this.radioButtonColor);
            this.groupBox1.Location = new System.Drawing.Point(581, 168);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(173, 54);
            this.groupBox1.TabIndex = 9;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Scale Color";
            // 
            // radioButtonGrey
            // 
            this.radioButtonGrey.AutoSize = true;
            this.radioButtonGrey.Location = new System.Drawing.Point(73, 19);
            this.radioButtonGrey.Name = "radioButtonGrey";
            this.radioButtonGrey.Size = new System.Drawing.Size(77, 17);
            this.radioButtonGrey.TabIndex = 1;
            this.radioButtonGrey.Text = "Grey Scale";
            this.radioButtonGrey.UseVisualStyleBackColor = true;
            this.radioButtonGrey.CheckedChanged += new System.EventHandler(this.radioButtonGrey_CheckedChanged);
            // 
            // radioButtonColor
            // 
            this.radioButtonColor.AutoSize = true;
            this.radioButtonColor.Checked = true;
            this.radioButtonColor.Location = new System.Drawing.Point(18, 20);
            this.radioButtonColor.Name = "radioButtonColor";
            this.radioButtonColor.Size = new System.Drawing.Size(49, 17);
            this.radioButtonColor.TabIndex = 0;
            this.radioButtonColor.TabStop = true;
            this.radioButtonColor.Text = "Color";
            this.radioButtonColor.UseVisualStyleBackColor = true;
            // 
            // groupBoxCanvas
            // 
            this.groupBoxCanvas.Controls.Add(this.labelWidth);
            this.groupBoxCanvas.Controls.Add(this.labelHeight);
            this.groupBoxCanvas.Controls.Add(this.textBoxWidth);
            this.groupBoxCanvas.Controls.Add(this.textBoxHeight);
            this.groupBoxCanvas.Location = new System.Drawing.Point(586, 238);
            this.groupBoxCanvas.Name = "groupBoxCanvas";
            this.groupBoxCanvas.Size = new System.Drawing.Size(167, 85);
            this.groupBoxCanvas.TabIndex = 10;
            this.groupBoxCanvas.TabStop = false;
            this.groupBoxCanvas.Text = "Canvas Size ( max 500 )";
            // 
            // textBoxHeight
            // 
            this.textBoxHeight.Location = new System.Drawing.Point(113, 28);
            this.textBoxHeight.Name = "textBoxHeight";
            this.textBoxHeight.Size = new System.Drawing.Size(32, 20);
            this.textBoxHeight.TabIndex = 0;
            this.textBoxHeight.Text = "100";
            this.textBoxHeight.TextChanged += new System.EventHandler(this.textBoxHeight_TextChanged);
            // 
            // textBoxWidth
            // 
            this.textBoxWidth.Location = new System.Drawing.Point(113, 54);
            this.textBoxWidth.Name = "textBoxWidth";
            this.textBoxWidth.Size = new System.Drawing.Size(32, 20);
            this.textBoxWidth.TabIndex = 1;
            this.textBoxWidth.Text = "100";
            this.textBoxWidth.TextChanged += new System.EventHandler(this.textBoxWidth_TextChanged);
            // 
            // labelHeight
            // 
            this.labelHeight.AutoSize = true;
            this.labelHeight.Location = new System.Drawing.Point(10, 31);
            this.labelHeight.Name = "labelHeight";
            this.labelHeight.Size = new System.Drawing.Size(77, 13);
            this.labelHeight.TabIndex = 2;
            this.labelHeight.Text = "Canvas Height";
            // 
            // labelWidth
            // 
            this.labelWidth.AutoSize = true;
            this.labelWidth.Location = new System.Drawing.Point(10, 57);
            this.labelWidth.Name = "labelWidth";
            this.labelWidth.Size = new System.Drawing.Size(71, 13);
            this.labelWidth.TabIndex = 3;
            this.labelWidth.Text = "CancasWidth";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(775, 548);
            this.Controls.Add(this.groupBoxCanvas);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.pictureBoxScale);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBoxLoopCount);
            this.Controls.Add(this.buttonStop);
            this.Controls.Add(this.buttonStart);
            this.Controls.Add(this.pictureCanvas);
            this.Name = "Form1";
            this.Text = "Jacobi Relaxation with Red Black Optimization";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
            ((System.ComponentModel.ISupportInitialize)(this.pictureCanvas)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBoxScale)).EndInit();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBoxCanvas.ResumeLayout(false);
            this.groupBoxCanvas.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.PictureBox pictureCanvas;
        private System.Windows.Forms.Button buttonStart;
        private System.Windows.Forms.Button buttonStop;
        private System.Windows.Forms.TextBox textBoxLoopCount;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.PictureBox pictureBoxScale;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.RadioButton radioButtonGrey;
        private System.Windows.Forms.RadioButton radioButtonColor;
        private System.Windows.Forms.GroupBox groupBoxCanvas;
        private System.Windows.Forms.Label labelWidth;
        private System.Windows.Forms.Label labelHeight;
        private System.Windows.Forms.TextBox textBoxWidth;
        private System.Windows.Forms.TextBox textBoxHeight;
    }
}

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)


Written By
Web Developer
Sri Lanka Sri Lanka
coding in C# C++ C

==============================================

Code in English, not Gibberish Smile | :)

Comments and Discussions