Results 1 to 3 of 3

Thread: beginer errors in my CL file

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    10

    beginer errors in my CL file

    Hi everyone,

    I'm quite a beginer and am having some trouble with my OpenCL C code :

    Code :
    struct knapSack
    {
        int valeur;
        int dimension;
    };
    typedef struct knapSack knapSack;
     
     
    __kernel void knapSack_kernel(__read_only int *tableauObjet, __global int *F, __read_only int capaciteMaxSac, __read_only int nbElement, __global int *resultat)
    {
        int E = 0;
        int i = nbElement;
     
        for( E = 0; E <= capaciteMaxSac ; E++)
        {
            if(( E <=( capaciteMaxSac - tableauObjet[nbElement - 1]->dimension)) && (tableauObjet[nbElement - 1]->valeur >= 0))
            {
                F[E] = tableauObjet[nbElement - 1]->valeur;
            }
            else
            {
                F[E] = 0;
            }
        }
        i--;
     
     
        while(i > 1)
        {
            for(E = 0; E <= capaciteMaxSac; E++)
            {
                if( E + tableauObjet[i-1]->dimension > capaciteMaxSac)
                {
     
                }
                else
                {
                    F[E] = fmax(F[E], tableauObjet[i - 1]->valeur + F[E + (int)tableauObjet[i - 1]->dimension]);
                }
            }
            i--;
     
     
        }
     
        F[0] = fmax(F[0],tableauObjet[0]->valeur+F[(int)tableauObjet[0]->dimension]);
        resultat = (int)F[0];
     
    }


    I get the following errors:

    Code :
     :9:47: error: invalid address space for pointee of pointer argument to __kernel function
    __kernel void knapSack_kernel(__read_only int *tableauObjet, __global int *F, __read_only int capaciteMaxSac, __read_only int nbElement, __global int *resultat)
                                                  ^
    :16:66: error: member reference type 'int' is not a pointer
            if(( E <=( capaciteMaxSac - tableauObjet[nbElement - 1]->dimension)) && (tableauObjet[nbElement - 1]->valeur >= 0))
                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    :18:49: error: member reference type 'int' is not a pointer
                F[E] = tableauObjet[nbElement - 1]->valeur;
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    :36:40: error: member reference type 'int' is not a pointer
                if( E + tableauObjet[i-1]->dimension > capaciteMaxSac)
                        ~~~~~~~~~~~~~~~~~  ^
    :42:56: error: member reference type 'int' is not a pointer
                    F[E] = fmax(F[E], tableauObjet[i - 1]->valeur + F[E + (int)tableauObjet[i - 1]->dimension]);
                                      ~~~~~~~~~~~~~~~~~~~  ^
    :51:39: error: member reference type 'int' is not a pointer
        F[0] = fmax(F[0],tableauObjet[0]->valeur+F[(int)tableauObjet[0]->dimension]);
                         ~~~~~~~~~~~~~~~  ^
    :52:14: warning: incompatible integer to pointer conversion assigning to 'int __attribute__((address_space(1))) *' from 'int'
        resultat = (int)F[0];
                 ^ ~~~~~~~~~
    I do understand the errors, but don't have any idea how to solve them. It must be very simple but, as I said, I'm quite a newbie.

    If someone could give me a hint how to solve them, it would be great.

    I thank you beforehand for your answers;

    Regards;

    Elrachal

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    9

    Re: beginer errors in my CL file

    Hi,

    if(( E <=( capaciteMaxSac - tableauObjet[nbElement - 1]->dimension)) && (tableauObjet[nbElement - 1]->valeur >= 0))
    I think that tableauObjet has no field "dimension" since you declared it as "int" pointer.

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    10

    Re: beginer errors in my CL file

    I'm stupid.

    Now it works !!

    Thank you !!

Similar Threads

  1. Errors, errors, and more errors..the kicker->theyre Run-t
    By Alaric in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 11-09-2005, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •