• Hallo Gast, du kaufst gerne günstig ein und erfährst oft vor deinen Freunden von interessanten Angeboten? Dann kannst du dein Talent als Schnäppchenjäger jetzt zu Geld machen und anderen PCGH-Lesern beim Sparen helfen! Schau einfach mal rein - beim Test der Community Deals!

Dynamic Workload Manager (CPU/GPU)

thysol

BIOS-Overclocker(in)
Hi,
Ich moechte euch hier in diesem Thread meine Idee vorstellen. Ich habe diesen Thread in diesem Unterforum aufgemacht weil es hier sehr viel um Grafikkarten geht.

Einfuehrung:

Durch meinem neuen Algorithm ist es moeglich die Effizienz von HPC (High Performance Computing) generell zu steigern. Dieser Algorithm koennte auch benutzt werden um die Performance in Games zu steigern. Ich nenne diesen Algorithm Dynamic Workload Manager.

Dynamic Workload Manager:

Mein Dynamic Workload Manager ist in der Lage dynamisch die Arbeitsaufteilung innerhalb des Computers zu steuern. Als erstes testet er welcher Code mit welcher Performance auf welchen Prozessoren laeuft. Theoretisch kann der Dynamic Workload Manager die Arbeit auf einer unendlichen Zahl CPUs und GPUs aufteilen.

Wer profitiert am meisten vom Dynamic Workload Manager?


Am meisten profitieren Multi-GPU Setups mit unterschiedlichen GPUs. Ein Beispiel waere ein Lucid Hydra Setup mit Geforce + Radeon. Der Dynamic Workload Manager wuerde der Radeon die Aufgaben zuteilen worin sie am schnellsten ist und die Aufgaben wo die Geforce schneller ist kriegt dann logischer Weise die Geforce. Der Dynamic Workload Manager kann voll automatisch herausfinden welche Algorithmen auf welchem Prozessor im System am besten laufen. Dadurch kann es sein das ein System mit einer Radeon HD 5750 + Geforce GTS 450 schneller ist als ein System mit Geforce GTX 580 SLI. Dass kann passieren wenn eine Aufgabe besonders schlecht auf einer Geforce laeuft. Der Dynamic Workload Manager wuerde dann die Aufgaben wo die Geforce schlecht drin ist der Radeon zuweisen. Die Geforce wuerde dann eine andere Arbeit kriegen. Die CPU wuerde automatisch die Arbeit aufkriegen wo beide GPUs schlecht drin sind. Im Prinzip ist mein Dynamic Workload Manager sowas wie Lucid Hydra nur fuer HPC Rechenaufgaben und nicht fuer Grafikrendering.

Was sind die Voraussetzungen dafuer dass der Dynamic Workload Manager funktioniert?

Der Code muss parrallelisierbar sein und muss zumindest teilweise unabhaengige Daten enthalten.

Ich kann euch gleich noch das Programm dass ich geschrieben habe hier reinstellen aber erstmal wollte ich von euch Wissen ob es sowas ueberhaupt schon gibt oder was ihr generell von der Idee haltet?;)


Radeon User sollten sich erst das hier installieren:

http://developer.amd.com/gpu/AMDAPPSDK/downloads/Pages/default.aspx


 
Zuletzt bearbeitet:
TE
thysol

thysol

BIOS-Overclocker(in)
Source Code des Programms:

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 System.Threading;

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

public static double CPUtime;
public static double GPUtime;
public static double total;

public static double b;
public static float gpu2;
public static float cpu2;

public static int z = 0;
public static int s = 0;
public static int gpudec2;
public static int f = 0;
public static int o = 0;
public static int p = 0;

Thread a2 = new Thread(new ThreadStart(GPUthread));
Thread b2 = new Thread(new ThreadStart(GPUthread2));
Thread c2 = new Thread(new ThreadStart(GPUthread3));
Thread d2 = new Thread(new ThreadStart(GPUthread4));
Thread e2 = new Thread(new ThreadStart(GPUthread5));
Thread f2 = new Thread(new ThreadStart(GPUthread6));
Thread g2 = new Thread(new ThreadStart(GPUthread7));
Thread h2 = new Thread(new ThreadStart(GPUthread8));
Thread i2 = new Thread(new ThreadStart(GPUthread9));
Thread j2 = new Thread(new ThreadStart(GPUthread10));
Thread k2 = new Thread(new ThreadStart(GPUthread11));
Thread l2 = new Thread(new ThreadStart(GPUthread12));
Thread m2 = new Thread(new ThreadStart(GPUthread13));

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

public static void GPUthread()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread2()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}
public static void GPUthread3()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread4()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;


}

public static void GPUthread5()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread6()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread7()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread8()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;


}

public static void GPUthread9()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread10()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread11()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}




public static void GPUthread12()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

public static void GPUthread13()
{
Random RandomClass = new Random();
f = 0;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

string orbit = @"
__kernel void
orbit(__global float * v1,
__global float * v2,
__global float * v3,
__global float * v4,
__global float * v5,
__global float * v6,
__global float * v7,
__global float * v8,
__global float * v9,
__global float * v10,
__global float * v11,
__global float * v12,
__global float * v13)
{
int i = get_global_id(0);
while (v11[0] < v12[0])
{
v9[0] = v13[0];
while (v9[0] < v10[0])
{
v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );
v9[0]++;
}
v11[0]++;
}
}";

OpenCLTemplate.CLCalc.InitCL();

OpenCLTemplate.CLCalc.Program.Compile(new string[] { orbit });

OpenCLTemplate.CLCalc.Program.Kernel VectorSum = new OpenCLTemplate.CLCalc.Program.Kernel("orbit");

int n = 1000000;

float[] v1 = new float[n], v2 = new float[n], v3 = new float[n], v4 = new float[n], v5 = new float[n], v6 = new float[n], v7 = new float[n], v8 = new float[n], v9 = new float[1], v10 = new float[1], v11 = new float[1], v12 = new float[1], v13 = new float[1];

for (int i = 0; i < n; i++)
{
v1 = RandomClass.Next(1000, 100000);
v2 = RandomClass.Next(200000, 10000000);
v3 = 6378140 + v2;
}

v13[0] = s;
v9[0] = s;
v10[0] = gpu2;
v11[0] = o;
v12[0] = p;

OpenCLTemplate.CLCalc.Program.Variable varV1 = new OpenCLTemplate.CLCalc.Program.Variable(v1);
OpenCLTemplate.CLCalc.Program.Variable varV2 = new OpenCLTemplate.CLCalc.Program.Variable(v2);
OpenCLTemplate.CLCalc.Program.Variable varV3 = new OpenCLTemplate.CLCalc.Program.Variable(v3);
OpenCLTemplate.CLCalc.Program.Variable varV4 = new OpenCLTemplate.CLCalc.Program.Variable(v4);
OpenCLTemplate.CLCalc.Program.Variable varV5 = new OpenCLTemplate.CLCalc.Program.Variable(v5);
OpenCLTemplate.CLCalc.Program.Variable varV6 = new OpenCLTemplate.CLCalc.Program.Variable(v6);
OpenCLTemplate.CLCalc.Program.Variable varV7 = new OpenCLTemplate.CLCalc.Program.Variable(v7);
OpenCLTemplate.CLCalc.Program.Variable varV8 = new OpenCLTemplate.CLCalc.Program.Variable(v8);
OpenCLTemplate.CLCalc.Program.Variable varV9 = new OpenCLTemplate.CLCalc.Program.Variable(v9);
OpenCLTemplate.CLCalc.Program.Variable varV10 = new OpenCLTemplate.CLCalc.Program.Variable(v10);
OpenCLTemplate.CLCalc.Program.Variable varV11 = new OpenCLTemplate.CLCalc.Program.Variable(v11);
OpenCLTemplate.CLCalc.Program.Variable varV12 = new OpenCLTemplate.CLCalc.Program.Variable(v12);
OpenCLTemplate.CLCalc.Program.Variable varV13 = new OpenCLTemplate.CLCalc.Program.Variable(v13);

OpenCLTemplate.CLCalc.Program.Variable[] args = new OpenCLTemplate.CLCalc.Program.Variable[] { varV1, varV2, varV3, varV4, varV5, varV6, varV7, varV8, varV9, varV10, varV11, varV12, varV13 };

int[] workers = new int[1] { n };

sw.Start();
while (f < gpudec2)
{
VectorSum.Execute(args, workers);
f++;
v9[0] = s;
}
varV4.ReadFromDeviceTo(v4);
varV5.ReadFromDeviceTo(v5);
varV6.ReadFromDeviceTo(v6);
varV7.ReadFromDeviceTo(v7);
varV8.ReadFromDeviceTo(v8);

sw.Stop();


GPUtime = sw.Elapsed.TotalSeconds;

}

static void orbit(object work)
{
Work w = (Work)(work);

while (z < cpu2)
{


for (int i = w.begin; i < w.end; i++)
{
Work.v4 = Work.v3 / (2 * 398600500000000 / (Work.v3 * (Work.v1 * Work.v1)) - 1);
Work.v5 = Work.v3 * (Work.v1 * Work.v1) / 398600500000000 - 1;
Work.v6 = Work.v4 / (1 + Work.v5);
Work.v7 = Work.v5 * Work.v6;
Work.v8 = (Work.v6 * Work.v6) - (Work.v7 * Work.v7);
Work.v8 = (float)Math.Pow(Work.v8, 0.5);
}
z++;
}

}

private void button1_Click(object sender, EventArgs e)
{
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
s = 990000;
z = 990000;

gpudec2 = (int)gpudec.Value;
int cores = Environment.ProcessorCount;

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads = new Thread[cores];



if (round != 0)
{
w[cores - 1].end += round;
}

label9.Text = "5000";
label10.Text = "5000";

a2.Start();
while (!a2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads = new Thread(new ParameterizedThreadStart(orbit));
threads.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads = new Thread(new ParameterizedThreadStart(orbit));
threads.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

a2.Join();

total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

class Work
{
public int begin;
public int end;
public static float[] v1;
public static float[] v2;
public static float[] v3;
public static float[] v4;
public static float[] v5;
public static float[] v6;
public static float[] v7;
public static float[] v8;
public Work(int begin, int end)
{
this.begin = begin;
this.end = end;
}
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

gpu2 = (float)gpu.Value;
int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads3 = new Thread[cores];
b = cpu2 * (CPUtime / total);
z = (int)b;
s = (int)cpu2 - z;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

b2.Start();
while (!b2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads3 = new Thread(new ParameterizedThreadStart(orbit));
threads3.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads3 = new Thread(new ParameterizedThreadStart(orbit));
threads3.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads3.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads3.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;
b2.Join();

total = CPUtime + GPUtime;

label17.Text = CPUtime.ToString();
label16.Text = GPUtime.ToString();
label15.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button2_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads4 = new Thread[cores];
b = (cpu2 -b) * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

c2.Start();
while (!c2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads4 = new Thread(new ParameterizedThreadStart(orbit));
threads4.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads4 = new Thread(new ParameterizedThreadStart(orbit));
threads4.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads4.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads4.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

c2.Join();
total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button11_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads5 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

d2.Start();
while (!d2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads5 = new Thread(new ParameterizedThreadStart(orbit));
threads5.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads5 = new Thread(new ParameterizedThreadStart(orbit));
threads5.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads5.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads5.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;
d2.Join();

total = CPUtime + GPUtime;

label17.Text = CPUtime.ToString();
label16.Text = GPUtime.ToString();
label15.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button10_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads6 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

e2.Start();
while (!e2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads6 = new Thread(new ParameterizedThreadStart(orbit));
threads6.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads6 = new Thread(new ParameterizedThreadStart(orbit));
threads6.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads6.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads6.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

e2.Join();
total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button9_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads7 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

f2.Start();
while (!f2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads7 = new Thread(new ParameterizedThreadStart(orbit));
threads7.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads7 = new Thread(new ParameterizedThreadStart(orbit));
threads7.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads7.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads7.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;
f2.Join();

total = CPUtime + GPUtime;

label17.Text = CPUtime.ToString();
label16.Text = GPUtime.ToString();
label15.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button8_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads8 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

g2.Start();
while (!g2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads8 = new Thread(new ParameterizedThreadStart(orbit));
threads8.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads8 = new Thread(new ParameterizedThreadStart(orbit));
threads8.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads8.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads8.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

g2.Join();
total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button7_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads9 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

h2.Start();
while (!h2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads9 = new Thread(new ParameterizedThreadStart(orbit));
threads9.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads9 = new Thread(new ParameterizedThreadStart(orbit));
threads9.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads9.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads9.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

h2.Join();
total = CPUtime + GPUtime;

label17.Text = CPUtime.ToString();
label16.Text = GPUtime.ToString();
label15.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button6_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads10 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

i2.Start();
while (!i2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads10 = new Thread(new ParameterizedThreadStart(orbit));
threads10.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads10 = new Thread(new ParameterizedThreadStart(orbit));
threads10.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads10.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads10.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;
i2.Join();

total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void button5_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;
gpudec2 = (int)gpudec.Value;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads11 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

j2.Start();
while (!j2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads11 = new Thread(new ParameterizedThreadStart(orbit));
threads11.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads11 = new Thread(new ParameterizedThreadStart(orbit));
threads11.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads11.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads11.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

j2.Join();
total = CPUtime + GPUtime;

label17.Text = CPUtime.ToString();
label16.Text = GPUtime.ToString();
label15.Text = total.ToString();


progressBar2.PerformStep();
sw.Reset();
}

private void button4_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
gpudec2 = (int)gpudec.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
int cores = Environment.ProcessorCount;

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads12 = new Thread[cores];
b = b * (GPUtime / CPUtime);
s = (int)b;
z = (int)cpu2 - s;

label9.Text = z.ToString();
label10.Text = s.ToString();

if (round != 0)
{
w[cores - 1].end += round;
}

k2.Start();
while (!k2.IsAlive) ;

for (int i = 0; i < cores; i++)
{
threads12 = new Thread(new ParameterizedThreadStart(orbit));
threads12.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads12 = new Thread(new ParameterizedThreadStart(orbit));
threads12.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads12.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads12.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;
k2.Join();

total = CPUtime + GPUtime;

label1.Text = CPUtime.ToString();
label2.Text = GPUtime.ToString();
label14.Text = total.ToString();

progressBar2.PerformStep();
sw.Reset();
}

private void gpusim(object sender, EventArgs e)
{
NumericUpDown answerBox = sender as NumericUpDown;

if (answerBox != null)
{
int lengthOfAnswer = answerBox.Value.ToString().Length;
answerBox.Select(0, lengthOfAnswer);
}

}

private void button12_Click(object sender, EventArgs e)
{

o = 0;
p = (int)GPUdec3.Value;
z = 0;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
gpudec2 = (int)gpudec.Value;
int cores = Environment.ProcessorCount;

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

Random RandomClass = new Random();

int n = 1000000;
Work.v1 = new float[n];
Work.v2 = new float[n];
Work.v3 = new float[n];
Work.v4 = new float[n];
Work.v5 = new float[n];
Work.v6 = new float[n];
Work.v7 = new float[n];
Work.v8 = new float[n];

for (int i = 0; i < n; i++)
{
Work.v1 = RandomClass.Next(1000, 100000);
Work.v2 = RandomClass.Next(200000, 10000000);
Work.v3 = 6378140 + Work.v2;
}
Work[] w = new Work[cores];
int iwork = n / cores;
for (int i = 0; i < cores; i++)
{
w = new Work(i * iwork, (i + 1) * iwork);
}
int round = n % cores;
Thread[] threads13 = new Thread[cores];



if (round != 0)
{
w[cores - 1].end += round;
}

for (int i = 0; i < cores; i++)
{
threads13 = new Thread(new ParameterizedThreadStart(orbit));
threads13.Priority = ThreadPriority.Normal;
}

for (int i = 0; i < cores; i++)
{
threads13 = new Thread(new ParameterizedThreadStart(orbit));
threads13.Priority = ThreadPriority.Normal;
}

sw.Start();
for (int i = 0; i < cores; i++)
{
threads13.Start(w);
}
for (int i = 0; i < cores; i++)
{
threads13.Join();
}
sw.Stop();

CPUtime = sw.Elapsed.TotalSeconds;

label20.Text = CPUtime.ToString();


sw.Reset();
}

private void button13_Click(object sender, EventArgs e)
{

cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
gpudec2 = (int)gpudec.Value;
o = 0;
p = (int)GPUdec3.Value;
z = 0;

s = 0;
l2.Start();
while (!l2.IsAlive) ;

l2.Join();

label22.Text = GPUtime.ToString();

sw.Reset();
}

private void gpudec_Enter(object sender, EventArgs e)
{
NumericUpDown answerBox = sender as NumericUpDown;

if (answerBox != null)
{
int lengthOfAnswer = answerBox.Value.ToString().Length;
answerBox.Select(0, lengthOfAnswer);
}
}

private void numericUpDown1_Enter(object sender, EventArgs e)
{
NumericUpDown answerBox = sender as NumericUpDown;

if (answerBox != null)
{
int lengthOfAnswer = answerBox.Value.ToString().Length;
answerBox.Select(0, lengthOfAnswer);
}

}

private void button14_Click(object sender, EventArgs e)
{
s = 0;
o = 0;
p = (int)GPUdec3.Value;
cpu2 = (float)cpu.Value;
gpu2 = (float)gpu.Value;
gpudec2 = (int)gpudec.Value;

m2.Start();
while (!m2.IsAlive) ;
m2.Join();
label25.Text = GPUtime.ToString();
}


}







}




Tutorial zum testen des Programms:



So sollte das Programm aussehen nach dem Start.



Druecke auf den Start Button. Jetzt muss mann sich eine Weile gedulden. Mit meinem Intel Core i5-750 dauert es ca. 60-70 Sekunden bis sich was tut.



Druecke dann auf Continue 1, 2, 3 usw.





Der Dynamic Workload Manager teilt die Arbeit auf je nachdem wie schnell CPU und GPU im System sind. Im Normalfall uebernimmt entweder CPU oder GPU die Arbeit alleine auf. Es gibt ein paar wenige Programme die CPU und GPU nutzen koennen aber bei denen ist vorprogrammiert welche Einheit wie viel Arbeit bekommt. Mit meinem Dynamic Workload Manager geschieht das alles automatisch. Somit kann sich mein Programm verschiedenen Rechnern perfekt anpassen um maximale Effizienz zu erzielen.



 
Zuletzt bearbeitet:
TE
thysol

thysol

BIOS-Overclocker(in)
Ok. Klingt interessant.
Wenn ich das richtig verstehe bringt es aber bei meinem System (Signatur) z.B. gar nichts?

Doch. Es bringt immer was. Wieviel es bringt haengt ganz von der Rechenaufgabe und dem System ab. Ich poste mal jetzt gleich das eigentliche Programm. Dann kannst du selber ausprobieren wie viel es bringt bei deinem System.;)
 
TE
thysol

thysol

BIOS-Overclocker(in)
Ok. Mit welchen Benchmarks hast du es jetzt getestet? Ich denke ich werde kaum ein + an FPS kriegen...

Der Benchmark bestand daraus die Umlaufbahn fuer ganz viele Steine um ein Objekt zu berechnen. Hier ist die Recheaufgabe:

v4 = v3 / (2 * 398600500000000 / (v3 * (v1 * v1)) - 1);
v5 = v3 * (v1 * v1) / 398600500000000 - 1;
v6 = v4 / (1 + v5);
v7 = v5 * v6;
v6 = v6 * v6;
v7 = v7 * v7;
v8 = v6 - v7;
v8 = sqrt( v8 );

Mehr FPS koennte mann nur kriegen wenn Spiele-Entwickler den Algorithm in ihr Code implementieren. Ich lade jetzt auch mal das Programm hoch.;)
 

Papzt

Volt-Modder(in)
Hm GPU Funktioniert bei mir nicht, da schmiert das Programm ab.
Wenn ich nur CPU Benchmark mache läufts
 
TE
thysol

thysol

BIOS-Overclocker(in)
Das erste Tutorial habe ich im 2.ten Post hochgeladen. Weitere Tutorials sollen noch folgen.

Ich bin gerade auf Arbeit...hier nutze ich kein CF. Aber eine Radeon ist es trotzdem

Probier dann mal den OpenCL Treiber runterzuladen der im ersten Post verlinkt ist.;)
 

Skysnake

Lötkolbengott/-göttin
Thysol der OpenCL Support sollte bei AMD inzwischen auch in den neuesten GPU Treibern enthalten sein. Das SDK sollte man nicht mehr benötigen.
 

Papzt

Volt-Modder(in)
Naja, gibt noch genug Sachen, die nur auf einem Kern laufen.
Habe gerade mal 9% Auslastung auf der GPU. Ist ja ganz schön wenig
 
TE
thysol

thysol

BIOS-Overclocker(in)
Thysol der OpenCL Support sollte bei AMD inzwischen auch in den neuesten GPU Treibern enthalten sein. Das SDK sollte man nicht mehr benötigen.

Ok, werde ich dann spaeter rauseditieren. Danke fuer den Hinweis.;)

Naja, gibt noch genug Sachen, die nur auf einem Kern laufen.
Habe gerade mal 9% Auslastung auf der GPU. Ist ja ganz schön wenig

Das liegt daran das die Berechnung so kurz ist und die GPU so schnell. Ich poste spaeter noch ein Tutorial mit dem GPU Decelarator. Dann sollte die Auslastung bei nahezu 100% sein.;)
 

weizenleiche

BIOS-Overclocker(in)
Hab es noch nicht ausprobiert, werde es aber heut nachmittag probieren. Es bleibt abzuwarten :)

Sent from my iPhone using PCGHExtreme
 

doenertier84

PC-Selbstbauer(in)
cooles Projekt, nur habe ich eine Frage:
Profitiert mein System bei gängigen Anwendungen (Acrobat Reader, Office, Email Programm oder whatever) schon davon, oder ist das bisher mehr rumexperimentieren mit dafür zugeschnittenen Benchmarks?
Die Idee, dass meine GPU der CPU unter die Arme greift, finde ich nämlich verlockend.
 
TE
thysol

thysol

BIOS-Overclocker(in)
cooles Projekt, nur habe ich eine Frage:
Profitiert mein System bei gängigen Anwendungen (Acrobat Reader, Office, Email Programm oder whatever) schon davon, oder ist das bisher mehr rumexperimentieren mit dafür zugeschnittenen Benchmarks?
Die Idee, dass meine GPU der CPU unter die Arme greift, finde ich nämlich verlockend.

Die Idee ist ja nicht das die GPU der CPU unter die arme greift sondern das die Arbeitsaufteilung insgesamt ausgeglichener ist. Es ist aber momentan nur ein Programm zum ausprobieren. Beschleunigen bei gaengigen Anwendungen hast du nicht.;)
 

Mastermaisi777

PCGHX-HWbot-Member (m/w)
Das Programm stürzt sofort ab wenn ich den GPU Test machen will , CPU funktioniert.
Nvidia Grafikchips werden unterstützt oder ?
 

D_Donsen

Komplett-PC-Aufrüster(in)
problem ist, dass nicht jeder hier im forum einen Spiele-/softwareentwickler kennt :schief:
aber die idee an sich ist wirklich gut
 
Oben Unten