Results 1 to 3 of 3

Thread: kernel function for cartesian product of two sets A and B

  1. #1

    kernel function for cartesian product of two sets A and B

    I have written the kernel for computing the cartesian product of A and B
    So my cartesian product will have elements where each element is a pair; first element of the pair i am storing in C and other i am storing in

    A={0,1,2,3,4,5}
    B={6,5,4,3,2,1}
    _kernel void cartesian(__global int *A, __global int *B, __global int *C, __global int *D,int k)
    {

    // Get the index of the current element
    int i = get_global_id(0); //this will get you the index
    int j = get_global_id(1); //this will get you the other index

    // Do the operation for producing the cartesian product
    C[i]=A[i];
    D[i]=B[j];

    }
    I am getting this
    A Cartesian B ->
    (0 , 0)
    (1 , 1)
    (2 , 2)
    (3 , 3)
    (4 , 4)
    (5 , 5)
    (6 , 6)
    (7 , 7)
    (8 ,
    (9 , 9)
    (10 , 10)
    (11 , 11)
    (12 , 12)
    (13 , 13)
    (14 , 14)
    (15 , 15)
    (16 , 16)
    (17 , 17)
    (18 , 1
    (19 , 19)
    (20 , 20)
    (21 , 21)
    (22 , 22)
    (23 , 23)
    (24 , 24)
    (25 , 25)
    (26 , 26)
    (27 , 27)
    (28 , 2
    (29 , 29)
    (30 , 30)
    (31 , 31)
    (32 , 32)
    (33 , 33)
    (34 , 34)
    (35 , 35)

    But the result should be
    (0,1)
    (0,2)
    (0,3)
    |
    |
    |

    |
    (5,6)

  2. #2

    get_global_id(0)

    what is the significance of 0 inside the brackets

  3. #3
    Senior Member
    Join Date
    Oct 2012
    Posts
    109

    Re: kernel function for cartesian product of two sets A and

    Shouldn't it be something like:

    C[i*n+j]=A[i]
    D[i*n+j]=B[j]

Similar Threads

  1. finding intersection of two sets
    By shahsaurabh1990 in forum OpenCL
    Replies: 0
    Last Post: 01-27-2013, 10:15 PM
  2. Replies: 4
    Last Post: 08-22-2011, 03:51 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
  •