2012-06-14 13 views
7

¿Cómo paso array a una función en OpenCL? Tengo error" ..argument de tipo "_global float *" es incompatible con el parámetro de tipo de "flotación *" en línea c [n] = FindIndexFromArray (a, 3);Pasando array al parámetro de función en OpenCL

float FindIndexFromArray(float myArray[], float Key) 
{ 
    // simple looping to find the index 
    for (int i=0;i<sizeof(myArray);i++) 
     if (myArray[i]==Key) 
     return i; 

} 

kernel void ProcessArray(
    global read_only float* myArray, 
    global read_only float* Key, 
    global write_only float* c) 
{ 
    int index = get_global_id(0); 
    c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter? 
} 

Mi fuente editado código:..

float FindIndexFromArray(__global read_only float* myArray[], __global read_only float* Key) 
{ 
    // simple looping to find the index 
    for (int i=0;i<sizeof(myArray);i++) 
     if (myArray[i]==Key) 
     return i; 

} 

kernel void ProcessArray(
    __global read_only float* myArray, 
    __global read_only float* Key, 
    __global write_only float* c) 
{ 
    int index = get_global_id(0); 
    c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter? 
} 

Respuesta

2

es como se indica en el mensaje de error que su myArray y Key viene con el tipo global y read-only, por lo tanto usted tiene que declarar el mismo tipo al pasar a otra función en breve su FindIndexFromArray debe ser

+0

Todavía recibo varias advertencias pero este es el mensaje de error: 'Los tipos de operandos son incompatibles (" float "y" __global float * "' en esta línea 'if (myArray [i] == Key)'. Creí haber declarado myArray y Key como __global type. ¿Cómo puedo solucionar esto? –

+0

¿Puedes mostrar tu código fuente editado? – ardiyu07

+0

He editado mi pregunta para mostrar mi código fuente editado. –

Cuestiones relacionadas