public void CalculateFitness(CudaDeviceVariable <byte> population, CudaDeviceVariable <float> fitness) { Profiler.Start("Calculate accuracy"); var deviceAccuracy = accuracyCalc.CalculateAccuracy(population); Profiler.Stop("Calculate accuracy"); float[] asdf = deviceAccuracy; Profiler.Start("Calculate vectorSizes"); countVectorsKernel.Calculate(population, vectorSizes); Profiler.Stop("Calculate vectorSizes"); int[] v = vectorSizes; Profiler.Start("Avrage VectorSizes"); float avrageVectorSize = Thrust.Avrage(vectorSizes); Profiler.Stop("Avrage VectorSizes"); Profiler.Start("Avrage accuracy"); float avrageAccuracy = Thrust.Avrage(deviceAccuracy); Profiler.Stop("Avrage accuracy"); Profiler.Start("fittness kernel"); fitnessKernel.Run( deviceAccuracy.DevicePointer, avrageAccuracy, vectorSizes.DevicePointer, avrageVectorSize, fitness.DevicePointer ); Profiler.Stop("fittness kernel"); }
public void AvrageFloatTest() { using (var context = new CudaContext()) { var data = new float[] { 2, 5, 8, 9, 6, 3, 5, 4, 0, 8, 8 }; float avg = Thrust.Avrage(data); Assert.AreEqual((float)data.Average(), avg); } }
public void CalculateFitness(CudaDeviceVariable <byte> population, CudaDeviceVariable <float> fitness) { Profiler.Start("vector sizes"); //countVectorsKernel.Calculate(population, deviceVectorSizes); Profiler.Stop("vector sizes"); Profiler.Start("size and indeces"); sizeAndIndecesKernel.Run( population.DevicePointer, populationIndeces.DevicePointer, deviceVectorSizes.DevicePointer ); Profiler.Stop("size and indeces"); var accuracy = accuracyFunc.CalculateAccuracy(population, populationIndeces, deviceVectorSizes); Profiler.Start("Avrage Accuracy"); float avrageAccuracy = Thrust.Avrage(accuracy); Profiler.Stop("Avrage Accuracy"); Profiler.Start("Avrage VectorSize"); float avrageVectorSize = Thrust.Avrage(deviceVectorSizes); Profiler.Stop("Avrage VectorSize"); Profiler.Start("fitness kernel"); fitnessKernel.Run( accuracy.DevicePointer, avrageAccuracy, deviceVectorSizes.DevicePointer, avrageVectorSize, fitness.DevicePointer ); Profiler.Stop("fitness kernel"); }