Hi everybody

Im trying to create a FEM solver using the Jacobi Iterative Method. My data is structure in the following way. I have a table which indicate how many neighbors that node have. The Next one indicate me which are the neighbors of that node, And the last one which have the value of the nodes. The idea is to get the average of the Neighbors and store it in a new table. In all Tables, the number of row indicate the number of node. For example

table 1

…

row 4 3

row 5 8

…

table 2

row 4 1 2 3

row 5 1 2 4 6 8 9 10 12

table 3

row 1 0.58963

row 2 0.69774

…

row 9 0.25689

the idea is to get the average of the nodes indicated in table number 2, The principal problem I have is not all the rows have the same number of neighbors.

The tables have a row format, and the table number 2 is an sparse Matrix, which the number of elements are given for the table number 1.

I already did a try, but it is 3 times slower than my approach using C++.

Here is the code

**global** void Jacobi_Kernel(unsigned int *d_neigh, unsigned int *d_numNeigh, float *d_meas, float *d_results) // add for the submatrix

{

int Node = blockIdx.x;

```
unsigned int numData = d_numNeigh[Node];
float Sum = 0;
if (Node < NUM_NODES && Node > 0){
unsigned int temp = d_numNeigh[Node - 1];
numData -= temp;
for (unsigned int i = 0; i < numData; i ++)
{
Sum += d_meas[d_neigh[i + temp] - 1];
}
}
if (Node == 0){
for (unsigned int i = 0; i < numData; i ++)
{
Sum += d_meas[d_neigh[i] - 1];
}
}
if (Node < NUM_NODES)
d_results[Node] = Sum / numData;
```

}

Hope you can give some advices to improve my code.

regards

Luis