Warning: incompatible integer to pointer conversion passing

I wrote the following kernel code, but it gave me the following warning. I have tried different solutions but failed. plz any suggestion would help

`26:48: warning: incompatible integer to pointer conversion passing '__global int' to parameter of type 'int *'
            array_dist[i] = Euclidean_distance(X_train[i],  data_point[j]);

my code :

 inline float Euclidean_distance(int * array_point_A, int * array_point_B) {
    float sum = 0.0;

    float  w[20] = { 0.0847282, 0.0408621, 0.105036, 0.0619821, 0.0595455, 0.0416739, 0.0181147, 0.00592921,
     0.040049, 0.0766054, 0.0441091, 0.0376111, 0.0124285, 0.0733558, 0.0587338, 0.0303001, 0.0579207, 0.0449221,
          0.0530462, 0.0530462 };

    for (int i = 0; i < 20; ++i) {
        float a = array_point_A[i] - array_point_B[i];
        float wieghted_distance = w[i] * (a * a);
        sum += wieghted_distance;

    }
    return sqrt(sum);
}



__kernel void KNN_classifier(__global  int * restrict X_train, __global  int * restrict Y_train, __global  int * restrict data_point, int k)
{
     
    float array_dist[4344] = {};
    int index_arr[4344] = {};
    for (int i = 0; i < 4344; ++i) { 
        for (int j = 0; j < 20; ++j) {
            array_dist[i] = Euclidean_distance(X_train[i],  data_point[j]);
            index_arr[i] = i;
        }
    }

    

Do you even read your error messages? You are passing in a int type, but the parameter is an int* type. It’s literally in the message. X_train[i] is an int. But your parameter expects a pointer to an int.

Do this:

array_dist[i] = Euclidean_distance(&X_train[i],  &data_point[j]);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.