Click here to Skip to main content
15,880,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when compiling the bellow <device code="">. the following error showed up:
error: passing 'int *' to parameter of type ' int *' changes address space of pointer
            array_dist[i] = Euclidean_distance(X_train, mydatapoint);
note: passing argument to parameter 'array_point_B' here
 float Euclidean_distance(__global int* restrict array_point_A, __global int* restrict array_point_B) {


my code:
inline float Euclidean_distance(__global int* restrict array_point_A, __global int* restrict array_point_B) {
 // do something
}
_kernel void KNN_classifier(__global int* restrict X_train, __global int* restrict Y_train, __global int* restrict data_point, __global int* restrict array_X_set, __global int* restrict index_arr, __global float* restrict array_dist)
{
    int mydatapoint[20];
    for (int l = 0; l + 8 < 4344; l += 8) {
        for (int u = l; u < l + 8; ++u) {
            for (int j = 0; j < 20; ++j) {
                mydatapoint[j] = array_X_set[u];

            }

            for (int i = 0; i < 4344; i++) {
                array_dist[i] = Euclidean_distance(X_train, mydatapoint);//ask
                index_arr[i] = i;
            }


What I have tried:

I am not sure what this error mean and why it happened. I need to fix it
Posted
Updated 17-Oct-21 2:54am

1 solution

I am not an OpenCL expert but looking at your code I suspect it is because you are passing a local address to a function that expects a global:
C++
// your function definition
inline float Euclidean_distance(__global int* restrict array_point_A, __global int* restrict array_point_B) {
 // do something
 // NB both inputs are declared as __global int* restrict
}

However, in your call to this function you have:
C++
                array_dist[i] = Euclidean_distance(X_train, mydatapoint);
// mydatapoint is a local int array, which may well be the issue.
 
Share this answer
 
Comments
prother123 17-Oct-21 9:00am    
Thank you for your reply. So what do you suggest as solution
Richard MacCutchan 17-Oct-21 9:08am    
Like I said, I am not an OpenCL expert. You need to go to the OpenCL documentation to find out how to fix this. But I suspect you somehow need to allocate mydatapoint as a global array so it matches the declaration of Euclidean_distance, or change the function definition to accept a local array for the second parameter.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900