Question

So I am currently working on a project that involves a parallel grid structure. The problem I am having is related to the communication scheme. The amount of information I have for each element in this matrix is what processor rank it is. This lets me calculate where, in the global scheme, it is.

I'll try to give a visual example:

This matrix represents a global picture of the node numbering.

| 0| 1| 2| 3|

| 4| 5| 6| 7|

| 8| 9|10|11|

|12|13|14|15|

Locally, I can find any (i,j) given its' processor rank and total number of processors in the comm.

The problem I am trying to solve is how to find, for an arbitrarily sized square mesh, how do I know which element is on the diagonal or ant diagonal.

A better picture of what I am looking at is posted below. The differing black/white scheme has been taken care of, I just need to know how to find the diagonal and anti diagonal given its' processor rank and node coordinates.

Infographic

Was it helpful?

Solution

I figured something out to solve the problem.

The first thing I did was look at the coordinate system (i,j) for each processor. Then I noticed that if you take abs(i - j) you get either an odd number or an even number. This was pretty obvious, but when you apply it to each subdivision, like the image in the original question, you can see the same behaviour and it differentiates between the main diagonal and the anti diagonal. So I used the (i,j) coordinate and set up a rule that determined if said coordinate was in either quadrant (I or III) vs (II or IV) and determined whether the flag should be a zero or one. This gave me the solution I was looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top