public AdaptiveBitonicSorter(GPUIntArray array) { this.value = array; left = new GPUIntArray(array.Length); rigt = new GPUIntArray(array.Length); output = new GPUIntArray(array.Length); }
//GPUArray<int> h = new GPUArray<int>(100000000); public Game(GameWindow window) : base(window) { new Shader2D("SIFT.shaders.plain_color.glsl").Run(Window.Width, Window.Height, Window.Canvas); //object a = new int(); //Console.WriteLine(a.GetType()); ////return; int n = 100000000; int loop_n = 1; // 60 * 32; GPUIntArray s_gpu = new GPUIntArray(n); List <int> s_cpu = new List <int>(n); for (int i = 0; i < n; i++) { s_cpu.Add(0); } Print(s_gpu.IsValue(7122)); s_gpu.Value(7122); Print(s_gpu.IsValue(7122)); GL.Finish(); //Print("GPU time:", a=Timing(() => //{ // for (int i = 0; i < n * power * 11; i++) // { // s_gpu[Rand.Next(n)] = Rand.Next(); // } // GL.Finish(); //})); TimeSpan a, b; Print("GPU time:", a = Timing(() => { for (int i = 0; i < loop_n; i++) { //Print("i =", i); s_gpu.Random(); //s_gpu.Data(Shuffled(Range(n)).ToArray()); s_gpu.Sort(); //s_gpu.Value(0); //if (!s_gpu.IsSorted()) //{ // Print(s_gpu); //} Assert(s_gpu.IsSorted()); } GL.Finish(); })); Print("CPU time:", b = Timing(() => { for (int i = 0; i < loop_n; i++) { //Print("i =", i); s_cpu.Random(); s_cpu.Sort(); Assert(s_cpu.IsSorted()); } })); Print("speedup =", b.TotalMilliseconds / a.TotalMilliseconds); Print("finish"); }
public bool Contains(int value) { var flag = new GPUIntArray(new[] { 0 }); new Shader($"SIFT.shaders.contains_value.glsl").QueueForRunInSequence(Length, this, flag, ("value", value)); return(flag[0] == 1); }
public bool IsSorted() { var flag = new GPUIntArray(new[] { 1 }); new Shader($"SIFT.shaders.is_sorted.glsl").QueueForRunInSequence(Length, this, flag); return(flag[0] == 1); }
public ParallelAdaptiveMergeSorter(GPUIntArray array) { this.value = array; output = new GPUIntArray(array.Length); left = new GPUIntArray(array.Length); rigt = new GPUIntArray(array.Length); a = new GPUIntArray(array.Length); }
//GPUIntArray debug; public ParallelMergeSorter(GPUIntArray array) { this.value = array; output = new GPUIntArray(array.Length); left = new GPUIntArray(array.Length); rigt = new GPUIntArray(array.Length); //debug = new GPUIntArray(array.Length); }
public TowardParallelAdaptiveBitonicSorter(GPUIntArray array) { int n = array.Length; Assert(__builtin_popcount(n) == 1); this.value = array; left = new GPUIntArray(n); rigt = new GPUIntArray(n); roots = new GPUIntArray(n); spares = new GPUIntArray(n); }
public InPlaceParallelBitonicSorter(GPUIntArray array) { this.value = array; left = new GPUIntArray(array.Length); rigt = new GPUIntArray(array.Length); }
public GPUIntArray(GPUIntArray array) : base(array) { }