Skip to content

Commit

Permalink
kernel: ldiag and rdiag are not stored, just used once
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Feb 19, 2024
1 parent 1e3155d commit f71712d
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/main/resources/kernels.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ kernel void nqfaf_nvidia(global struct constellation *constellation_arr, global
local uint jkl_queens[N];
jkl_queens[l_id % N] = jkl_queens_arr[get_group_id(0) * N + l_id % N];
barrier(CLK_LOCAL_MEM_FENCE);

uint ldiag = L >> ((c.start_ijkl >> 5) & 31); // ld from queen l with respect to the first row
uint rdiag = 1 << (c.start_ijkl & 31); // ld from queen k with respect to the first row

ld &= ~(ldiag << start); // remove queen k from ld
ld &= ~(L >> (((c.start_ijkl >> 5) & 31) - start)); // remove queen k from ld
if((c.start_ijkl & 31) != N-1)
/* only remove queen k from rd, if no queen in corner (N-1,N-1),
* otherwise we continue in row N-1 and find too many solutions
*/
rd &= ~(rdiag >> start);
rd &= ~(1 << ((c.start_ijkl & 31) - start));

int row = start;
ulong solutions = 0;
Expand Down Expand Up @@ -207,16 +204,13 @@ kernel void nqfaf_amd(constant struct constellation *constellation_arr, global u
local uint jkl_queens[N];
jkl_queens[l_id % N] = jkl_queens_arr[get_group_id(0) * N + l_id % N];
barrier(CLK_LOCAL_MEM_FENCE);

uint ldiag = L >> ((c.start_ijkl >> 5) & 31); // ld from queen l with respect to the first row
uint rdiag = 1 << (c.start_ijkl & 31); // ld from queen k with respect to the first row

ld &= ~(ldiag << start); // remove queen k from ld
ld &= ~(L >> (((c.start_ijkl >> 5) & 31) - start)); // remove queen k from ld
if((c.start_ijkl & 31) != N-1)
/* only remove queen k from rd, if no queen in corner (N-1,N-1),
* otherwise we continue in row N-1 and find too many solutions
*/
rd &= ~(rdiag >> start);
rd &= ~(1 << ((c.start_ijkl & 31) - start));

int row = start;
ulong solutions = 0;
Expand Down Expand Up @@ -379,16 +373,13 @@ kernel void nqfaf_intel(global struct constellation *constellation_arr, global u
local uint jkl_queens[N];
jkl_queens[l_id % N] = jkl_queens_arr[get_group_id(0) * N + l_id % N];
barrier(CLK_LOCAL_MEM_FENCE);

uint ldiag = L >> ((c.start_ijkl >> 5) & 31); // ld from queen l with respect to the first row
uint rdiag = 1 << (c.start_ijkl & 31); // ld from queen k with respect to the first row

ld &= ~(ldiag << start); // remove queen k from ld
ld &= ~(L >> (((c.start_ijkl >> 5) & 31) - start)); // remove queen k from ld
if((c.start_ijkl & 31) != N-1)
/* only remove queen k from rd, if no queen in corner (N-1,N-1),
* otherwise we continue in row N-1 and find too many solutions
*/
rd &= ~(rdiag >> start);
rd &= ~(1 << ((c.start_ijkl & 31) - start));

int row = start;
ulong solutions = 0;
Expand Down

0 comments on commit f71712d

Please sign in to comment.