public override int[,] CalcFrameJagged(int[][] frame) { int maxEventsCount = 0; int maxChannel = 0; for (int i = 0; i < frame.Length; i++) { if (frame[i].Length > maxEventsCount) { maxEventsCount = frame[i].Length; } for (int ii = 0; ii < frame[i].Length; ii++) { if (frame[i][ii] > maxChannel) { maxChannel = frame[i][ii]; } } } int THREADS_COUNT = 1024; dim3 blockDim = new dim3( 1,//(int)Math.Ceiling((decimal)maxEventsCount / THREADS_COUNT), 1 ); dim3 gridDim = new dim3( maxEventsCount,//(int)Math.Ceiling((decimal)maxEventsCount / blockDim.x), frame.Length ); LaunchParam lp = new LaunchParam(gridDim, blockDim); //int[,] channels = new int[frame.Length, channelsCount]; DeviceMemory2D <int> channelsMem = new DeviceMemory2D <int>(gpu.Context, new IntPtr(frame.Length), new IntPtr(channelsCount)); Pitched2DPtr <int> ptr = channelsMem.Pitched2DPtr; gpu.Launch( KernelNeutronsSum, lp, ptr, frame, maxEventsCount, channelsCount ); THREADS_COUNT = 64; blockDim = new dim3( (int)Math.Ceiling((decimal)channelsCount / THREADS_COUNT), 1 ); gridDim = new dim3( (int)Math.Ceiling((decimal)maxEventsCount / blockDim.x), frame.Length ); lp = new LaunchParam(gridDim, blockDim); int[,] spectrum = new int[frame.Length, channelsCount]; SummatorCPU summator = new SummatorCPU(channelsCount, channelWidth, detectors, strob); int[,] channelsCPU = summator.calcChannelsJagged(frame); int[][] spectrCPU = summator.CalcFrame2d(frame); int[,] channels = Gpu.Copy2DToHost(channelsMem); gpu.Launch( KernelStrobApply, lp, spectrum, channelsCPU, channelsCount, frame.Length, strob ); int[,] difference = new int[detectors.Length, channelsCount]; for (int i = 0; i < detectors.Length; i++) { for (int index = 0; index < channelsCount; index++) { difference[i, index] = channels[i, index] - channelsCPU[i, index]; } } int[,] difference2 = new int[detectors.Length, channelsCount]; for (int i = 0; i < detectors.Length; i++) { for (int index = 0; index < channelsCount; index++) { difference2[i, index] = spectrCPU[i][index] - spectrum[i, index]; } } return(spectrum); }