nearestNeighbor.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef _NEARESTNEIGHBOR
  2. #define _NEARESTNEIGHBOR
  3. #include <iostream>
  4. #include <vector>
  5. #include <float.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. // All OpenCL headers
  10. #if defined (__APPLE__) || defined(MACOSX)
  11. #include <OpenCL/opencl.h>
  12. #else
  13. #include <CL/opencl.h>
  14. #endif
  15. #include "clutils.h"
  16. //#include "utils.h"
  17. #include <algorithm>
  18. #define REC_LENGTH 49 // size of a record in db
  19. typedef struct latLong
  20. {
  21. float lat;
  22. float lng;
  23. } LatLong;
  24. typedef struct record
  25. {
  26. char recString[REC_LENGTH];
  27. float distance;
  28. } Record;
  29. float *OpenClFindNearestNeighbors(
  30. cl_context context,
  31. int numRecords,
  32. std::vector<LatLong> &locations,float lat,float lng,
  33. int timing);
  34. int loadData(char *filename,std::vector<Record> &records,std::vector<LatLong> &locations);
  35. void findLowest(std::vector<Record> &records,float *distances,int numRecords,int topN);
  36. void printUsage();
  37. int parseCommandline(int argc, char *argv[], char* filename,int *r,float *lat,float *lng,
  38. int *q, int *t, int *p, int *d, int *g);
  39. #endif