There is a C # code, and I need to redo it so that everything is counted on a video card:
public static double[] SATL(double[] data) { double[] matrix = { 0.0982862174, ..., -0.0229204861, ..., 0.0161380976 }; int dataLength = data.Length; int matrixLength = matrix.Length; int start = matrixLength + 1; var newData = new double[dataLength]; if (dataLength <= matrixLength) { return null; } for (int i = matrixLength; i < dataLength; i++) { int counter = i - matrixLength; for (int j = 0; j < matrixLength; j++) { newData[i] += matrix[j] * data[counter++]; } } return newData; }
The problem is that I still can not figure out how to run through the second array. I don’t understand how indexing happens in Cudafy . This is what I did, but it does not work correctly:
public static double[] FATLCuda(double[] data, double[] matrix) { CudafyModule km = CudafyTranslator.Cudafy(); GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId); gpu.LoadModule(km); ... gpu.Launch().add(dev_data, dev_matrix, dev_newdata); } [Cudafy] public static void add(GThread thread, double[] data, double[] matrix, double[] newdata) { int tid = thread.blockIdx.x; if (tid < data.Length) { int jid = 0; int counter = tid - matrix.Length; if (jid < matrix.Length) { newdata[tid] += matrix[jid] * data[counter++]; jid++; } tid++; } }