Error: Unable to get device_id

When trying to compile the host code. The following error appears.
Unable to get device_id

How to fix this error ??
Thanks,

Host code:

#include<assert.h>
#include<math.h>
#include<cstring>
#include "AOCLUtils/aocl_utils.h"
#include<CL/cl.h>
#include<time.h>
#include<sys/time.h>
#include<CL/cl_ext.h>
#include<algorithm>
#include<iomanip>
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <array> 
#include <string.h>
#include <CL/opencl.h>

using namespace std;
using namespace aocl_utils;
void cleanup() {}

bool read_data_set(string filename, array<array<int, 20>, 5430>& array_X_dataset, array<int, 5430>& array_Y_dataset) {
    int field0, field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11,
        field12, field13, field14, field15, field16, field17, field18, field19, field20, field21;
    char comma;
    int line = 0;

    ifstream myfile(filename);

    if (myfile.is_open())
    {
        while (myfile
            >> field0 >> comma
            >> field1 >> comma
            >> field2 >> comma
            >> field3 >> comma
            >> field4 >> comma
            >> field5 >> comma
            >> field6 >> comma
            >> field7 >> comma
            >> field8 >> comma
            >> field9 >> comma
            >> field10 >> comma
            >> field11 >> comma
            >> field12 >> comma
            >> field13 >> comma
            >> field14 >> comma
            >> field15 >> comma
            >> field16 >> comma
            >> field17 >> comma
            >> field18 >> comma
            >> field19 >> comma
            >> field20 >> comma
            >> field21)
        {


            array<int, 20> inner_array{ field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11,
            field12, field13, field14, field15, field16, field17, field18, field19, field20 };
            array_X_dataset[line] = inner_array;
            array_Y_dataset[line] = field21;
            line++;

        }

        myfile.close();

    }
    else {
        cout << "Unable to open file";
        return true;
    }
    return false;
}


void mix_dataset(array<array<int, 20>, 5430>& array_X_dataset, array<int, 5430>& array_Y_dataset) {
    size_t len = array_X_dataset.size();
    for (size_t i = 0; i < len; ++i) {
        size_t swap_index = rand() % len;  
        if (i == swap_index)
            continue;

        array<int, 20> data_point{  };
        data_point = array_X_dataset[i];
        array_X_dataset[i] = array_X_dataset[swap_index];
        array_X_dataset[swap_index] = data_point;
        int Y = array_Y_dataset[i];
        array_Y_dataset[i] = array_Y_dataset[swap_index];
        array_Y_dataset[swap_index] = Y;
    }
}



void split_dataset(int fold, int** array_X_set, int* array_Y_set, int** X_train, int* Y_train,
    int** X_test, int* Y_test) {
    int rows = 5430;
    int cols = 20;
    int division = 1086;
    switch (fold) {
    case 1:

        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j < cols; ++j) {
                if (i < division) {
                    X_test[i][j] = array_X_set[i][j];
                    Y_test[i] = array_Y_set[i];
                }

                else {
                    X_train[i - division][j] = array_X_set[i][j];
                    Y_train[i - division] = array_Y_set[i];
                }
            }
        }
        break;

    case 2:
        
        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j < cols; ++j) {
                if (i >= 1086 && i <= 2171) {
                    X_test[i - 1086][j] = array_X_set[i][j];
                    Y_test[i - 1086] = array_Y_set[i];
                }
                else {
                    if (i < 1086) {
                        X_train[i][j] = array_X_set[i][j];
                        Y_train[i] = array_Y_set[i];
                    }
                    else {
                        X_train[i - (2171 - 1086 + 1)][j] = array_X_set[i][j];
                        Y_train[i - (2171 - 1086 + 1)] = array_Y_set[i];
                    }
                }
            }
        }
        break;

    case 3:
       
        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j < cols; ++j) {
                if (i >= 2172 && i <= 3257) {
                    X_test[i - 2172][j] = array_X_set[i][j];
                    Y_test[i - 2172] = array_Y_set[i];
                }

                else {
                    if (i < 2172) {
                        X_train[i][j] = array_X_set[i][j];
                        Y_train[i] = array_Y_set[i];
                    }
                    else
                    {
                        X_train[i - (3257 - 2172 + 1)][j] = array_X_set[i][j];
                        Y_train[i - (3257 - 2172 + 1)] = array_Y_set[i];

                    }
                }
            }
        }
        break;

    case 4:
      
        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j < cols; ++j) {
                if (i >= 3258 && i <= 4343) {
                    X_test[i - 3258][j] = array_X_set[i][j];
                    Y_test[i - 3258] = array_Y_set[i];
                }

                else {
                    if (i < 3258) {
                        X_train[i][j] = array_X_set[i][j];
                        Y_train[i] = array_Y_set[i];
                    }
                    else
                    {
                        X_train[i - (4343 - 3258 + 1)][j] = array_X_set[i][j];
                        Y_train[i - (4343 - 3258 + 1)] = array_Y_set[i];

                    }
                }
            }
        }
        break;
    case 5:
       
        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j < cols; ++j) {
                if (i >= 4344 && i <= 5429) {
                    X_test[i - 4344][j] = array_X_set[i][j];
                    Y_test[i - 4344] = array_Y_set[i];
                }

                else {
                    if (i < 4344) {
                        X_train[i][j] = array_X_set[i][j];
                        Y_train[i] = array_Y_set[i];
                    }
                    else
                    {
                        X_train[i - (5429 - 4344 + 1)][j] = array_X_set[i][j];
                        Y_train[i - (5429 - 4344 + 1)] = array_Y_set[i];

                    }
                }
            }
        }
        break;
    }

}

float Euclidean_distance(int array_point_A[20], int  array_point_B[20]) {
    
    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);
}

int main()
{
    
    string filename = ".//dataset.csv";
    static array<array<int, 20>, 5430> array_X_dataset{};
    static array<int, 5430> array_Y_dataset{};

    bool error = read_data_set(filename, array_X_dataset, array_Y_dataset);
    if (error) {
        cout << "Exiting with error while reading dataset file " << filename << endl;
        exit(-1);
    }
   
    srand(3);
    mix_dataset(array_X_dataset, array_Y_dataset);

    
    int* array_Y_set = new int[5430];
    int** array_X_set = new int* [5430];
    for (int i = 0; i < 5430; i++) {
        array_X_set[i] = new int[20];
    }
   
    for (int i = 0; i < 5430; i++) {
        for (int j = 0; j < 20; j++)
            array_X_set[i][j] = array_X_dataset[i][j];
        array_Y_set[i] = array_Y_dataset[i];
    }
  
    int* Y_train = new int[4344];
    int* Y_test = new int[1086];

    int** X_train = new int* [4344];
    for (int i = 0; i < 4344; i++) {
        X_train[i] = new int[20];
    }
    int** X_test = new int* [1086];
    for (int i = 0; i < 1086; i++) {
        X_test[i] = new int[20];
    }
   
    int fold = 1;
    
    split_dataset(fold, array_X_set, array_Y_set, X_train, Y_train, X_test, Y_test);
    
    cl_platform_id fpga_paltform = NULL;
    if (clGetPlatformIDs(1, &fpga_paltform, NULL) != CL_SUCCESS) {
        printf("Unable to get platform_id\n");
        return 1;
    }

    
    cl_device_id fpga_device = NULL;
    if (clGetDeviceIDs(fpga_paltform, CL_DEVICE_TYPE_ALL, 1, &fpga_device, NULL) != CL_SUCCESS) {
        printf("Unable to get device_id\n");
        return 1;
    }

   
    cl_context context = clCreateContext(NULL, 1, &fpga_device, NULL, NULL, NULL);


    cl_command_queue queue = clCreateCommandQueue(context, fpga_device, 0, NULL);


    size_t length = 0x10000000;
    unsigned char* binary = (unsigned char*)malloc(length);
    FILE* fp = fopen("kernel.aocx", "rb");
    fread(binary, length, 1, fp);
    fclose(fp);


    cl_program program = clCreateProgramWithBinary(context, 1, &fpga_device, &length, (const unsigned char**)&binary, NULL, NULL);

 
    cl_kernel kernel = clCreateKernel(program, "KNN_classifier", NULL);


   
    int host_output[4344];
    int k = 3;
    int data_point[20] = {};
    for (int i = 0; i < 4344; ++i) {
        for (int j = 0; j < 20; ++j) {
            data_point[j] = array_X_set[i][j];
        }
    }
     int index_arr[4344] = {};
     float array_dist[4344] = {};
      for (int i = 0; i < 4344; ++i)
     {
          array_dist[i] = Euclidean_distance(X_train, data_point);
         index_arr[i] = i;
     }

 
    
    cl_mem dev_X_train = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * 4344 * 20, NULL, NULL);
    cl_mem dev_Y_train = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * 4344, NULL, NULL);
    cl_mem dev_data_point = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * 20, NULL, NULL);
    cl_mem dev_index_arr = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * 4344, NULL, NULL);
    cl_mem dev_array_dist = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * 4344, NULL, NULL);
    cl_mem dev_output = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int) * 4344, NULL, NULL);


    clEnqueueWriteBuffer(queue, dev_X_train, CL_TRUE, 0, sizeof(int) * 4344 * 20, X_train, 0, NULL, NULL);
    clEnqueueWriteBuffer(queue, dev_Y_train, CL_TRUE, 0, sizeof(int) * 4344, Y_train, 0, NULL, NULL);
    clEnqueueWriteBuffer(queue, dev_data_point, CL_TRUE, 0, sizeof(int) * 20, data_point, 0, NULL, NULL);
    clEnqueueWriteBuffer(queue, dev_index_arr, CL_TRUE, 0, sizeof(int) * 4344, index_arr, 0, NULL, NULL);
   clEnqueueWriteBuffer(queue, dev_array_dist, CL_TRUE, 0, sizeof(float) * 4344, array_dist, 0, NULL, NULL);
     
   
    clSetKernelArg(kernel, 0, sizeof(cl_mem), &dev_X_train);
    clSetKernelArg(kernel, 1, sizeof(cl_mem), &dev_Y_train);
    clSetKernelArg(kernel, 2, sizeof(cl_mem), &dev_data_point);
    clSetKernelArg(kernel, 3, sizeof(int), &k);
    clSetKernelArg(kernel, 4, sizeof(cl_mem), &dev_output);
    clSetKernelArg(kernel, 5, sizeof(cl_mem), &dev_index_arr);
    clSetKernelArg(kernel, 6, sizeof(cl_mem), &dev_array_dist);

     
    cl_event kernel_event;
    clEnqueueTask(queue, kernel, 0, NULL, &kernel_event);
    clWaitForEvents(1, &kernel_event);
    clReleaseEvent(kernel_event);

    clEnqueueReadBuffer(queue, dev_output, CL_TRUE, 0, sizeof(int) * 4344, host_output, 0, NULL, NULL);


    for (int i = 0; i < 4344; i++)
        printf("class_label[%d] = %d\n", i, host_output[i]);


    clFlush(queue);
    clFinish(queue);

    clReleaseMemObject(dev_X_train);
    clReleaseMemObject(dev_Y_train);
    clReleaseMemObject(dev_data_point);
    clReleaseMemObject(dev_index_arr);
    clReleaseMemObject(dev_array_dist);
    clReleaseMemObject(dev_output);
    clReleaseKernel(kernel);
    clReleaseProgram(program);
    clReleaseCommandQueue(queue);
    clReleaseContext(context);

   
    /*  for (int i = 0; i < 5430; i++) {
        delete[] array_X_set[i];
    }
    delete[] array_X_set;
    for (int i = 0; i < 4344; i++) {
        delete[] X_train[i];
    }
    delete[] X_test;
    for (int i = 0; i < 1086; i++) {
        delete[] X_test[i];
    }
    delete[] X_train;

    delete[] array_Y_set;
    delete[] Y_train;
    delete[] Y_test;
    free(data_point);
    free(host_output);
    free(index_arr);
    free(array_dist);
    */
    return 0;

}

So what have you tried to resolve this problem yourself? And what have you discovered in the process?

Have you checked the return value of glGetDeviceIDs() ???