nearestNeighbor_kernel.cl 662 B

12345678910111213141516171819202122
  1. //#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
  2. typedef struct latLong
  3. {
  4. float lat;
  5. float lng;
  6. } LatLong;
  7. __kernel void NearestNeighbor(__global LatLong *d_locations,
  8. __global float *d_distances,
  9. const int numRecords,
  10. const float lat,
  11. const float lng) {
  12. int globalId = get_global_id(0);
  13. if (globalId < numRecords) {
  14. __global LatLong *latLong = d_locations+globalId;
  15. __global float *dist=d_distances+globalId;
  16. *dist = (float)sqrt((lat-latLong->lat)*(lat-latLong->lat)+(lng-latLong->lng)*(lng-latLong->lng));
  17. }
  18. }