Let's consider a block of 18 * 18 threads, numbered from 0 (0, 0) to 323 (17, 17).
So, if I understand correct, my first 289 follow 1 branch [...]
If by "first 289" you refer to the threads numbered from 0 (0, 0) to 288 (16, 16), then no, not all of them take the first branch. For example, thread 17 (0, 17) does not take the branch (see illustration below). Over the span of a block, however, 289 threads take that branch indeed.
[...] and thread #324 follows another
That is right, thread 323 (17, 17) takes the second branch.
Threads 17 (0, 17), 35 (1, 17) ... 305 (16, 17) and 306 (17, 0), 307 (17, 1) ... 322 (17, 16) (totaling 35 threads) do not take any branch and are wasted. From a performance standpoint, that's bad, but it's not really catastrophic either.
But consider the following schema of what you are doing:
0 1 2 … 15 16 17
0 * * * * * * - * represents a thread that takes branch 1
1 * * * * * * - X represents a thread that takes branch 2
2 * * * * * * - - represents a thread that takes no branch
… * * * * * * -
15 * * * * * * -
16 * * * * * * -
17 - - - - - - X
Remember that warps are composed of 32 threads. So threads 0..31, 32..63, etc, execute in a lockstep. As you may notice on the schema above, you have one inactive thread every 18 threads. In other words, that means all your warps diverge.
It's probably not an enormous performance hit (if at all) though, because one of the branch is always "do nothing". That being said, I would definitely encourage you to fix your design, and I am confident you could notice a performance improvement (more due to memory access patterns than divergence itself, though).
An obvious solution would be to launch only 290 threads instead of 324, and do the mapping to x and y coordinates yourself, but then your last warp would diverge in a noticeable way.
Another solution would be to launch enough warps to cover the first 289 threads (that means 10 warps and the last one wastes 31 threads) and run a supplementary warp in which you use a thread for the second branch (the last one, for example). So that would be 11 warps, 352 threads, 62 wasted. That might seem worse in terms of efficiency, but it's actually more complicated than that because of memory access patterns, so give it a try.
Also note that if the bodies of the if/else statements do not actually differ on the code but on the data (as you kind of seem to imply...), then using a branch is pointless. Just play with pointers. Other issues may arise (related to memory access coalescing), but there will be no code flow divergence.
I would suggest more improvements but without seeing your code or knowing how your data is laid out, it's kind of a shot in the dark. You say in the comments you can't get NSIGHT to work: I strongly recommend you make that a priority.
18 x 18threads, theelse ifstatement will never been executed. No divergence in this code. - pQB