Research Article

Parallel Implementations of Candidate Solution Evaluation Algorithm for N-Queens Problem

Algorithm 9

Generate subscripts in GPU.
Input:
Output:
(1)tid global thread id in Kernel;
(2)NumofRound N−1;
(3)For iRound = 0; iRound ¡ N-1; iRound ++;/∗ find queens to be compared for current thread ∗/
(4)do
(5)if tid - NumofRound¡ 0 then
(6)  Xi iRound;
(7)  Xj tid +1 +iRound;
(8)  break;
(9)end
(10) tid tid - NumofRound;
(11) NumofRound NumofRound - 1;
(12)end
(13) ;
(14) ;
(15)ifthen
(16) atomicAdd(conflicts);
(17)end