Results 1 to 2 of 2

Thread: reg sudoku problem

  1. #1
    Junior Member
    Join Date
    Mar 2011

    reg sudoku problem


    This my serial code.
    bool NumberFits(int sudoku[], int i, int j) {
    /* place number j in sudoku-field i */
    int x, y;
    int line;
    int squareX, squareY; /* coordinates of subsquare */

    x = i % cCount;//col
    y = i / cCount;//row

    /* checks for equals in rows and columns */
    for (line = 0; line < cCount; line ++)// want to parallelise this loop
    if (sudoku[x + line * cCount] == j) return false;
    if (sudoku[line + y * cCount] == j) return false;

    Here is my kernel function for serial code above

    "__kernel void NumberFits(int i, int j,int cCount,__global const int *sudoku,__global int *res){" \
    "int x, y, squareX, squareY,k;" \
    "x = i % cCount;"\
    "y = i / cCount;"\
    "int line=get_global_id(0);"\
    "if((sudoku[line + y * cCount] == j) || (sudoku[x + line * cCount]==j))"\

    But res[0] is getting overwritten
    is there any bug in this kernel function??

  2. #2
    Join Date
    Mar 2010
    Raleigh, NC

    Re: reg sudoku problem

    Your code is not buggy - it's just not written correctly.
    Each work item is writing to the same location in res. Thus, the last work item to finish will be writing the last value to it.

    What I'd suggest is to use get_local_id() or get_global_id() to give yourself your correct location and make your write of res[] to be dependent on this.

Similar Threads

  1. using openCL for sudoku solver algorithm
    By Sudarshan in forum OpenCL
    Replies: 1
    Last Post: 03-24-2011, 09:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean