|
@@ -13,12 +13,12 @@ int main(int argc, char *argv[]) {
|
|
int i;
|
|
int i;
|
|
// args
|
|
// args
|
|
char filename[100];
|
|
char filename[100];
|
|
- int resultsCount=10,quiet=0,timing=0,platform=-1,device=-1;
|
|
|
|
|
|
+ int resultsCount=10,quiet=0,timing=0,platform=-1,device=-1,use_gpu=-1;
|
|
float lat=0.0,lng=0.0;
|
|
float lat=0.0,lng=0.0;
|
|
|
|
|
|
// parse command line
|
|
// parse command line
|
|
if (parseCommandline(argc, argv, filename,&resultsCount,&lat,&lng,
|
|
if (parseCommandline(argc, argv, filename,&resultsCount,&lat,&lng,
|
|
- &quiet, &timing, &platform, &device)) {
|
|
|
|
|
|
+ &quiet, &timing, &platform, &device, &use_gpu)) {
|
|
printUsage();
|
|
printUsage();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
if (resultsCount > numRecords) resultsCount = numRecords;
|
|
if (resultsCount > numRecords) resultsCount = numRecords;
|
|
|
|
|
|
- context = cl_init_context(platform,device,quiet);
|
|
|
|
|
|
+ context = cl_init_context(platform,device,quiet,use_gpu);
|
|
|
|
|
|
recordDistances = OpenClFindNearestNeighbors(context,numRecords,locations,lat,lng,timing);
|
|
recordDistances = OpenClFindNearestNeighbors(context,numRecords,locations,lat,lng,timing);
|
|
|
|
|
|
@@ -259,7 +259,7 @@ void findLowest(std::vector<Record> &records,float *distances,int numRecords,int
|
|
}
|
|
}
|
|
|
|
|
|
int parseCommandline(int argc, char *argv[], char* filename,int *r,float *lat,float *lng,
|
|
int parseCommandline(int argc, char *argv[], char* filename,int *r,float *lat,float *lng,
|
|
- int *q, int *t, int *p, int *d){
|
|
|
|
|
|
+ int *q, int *t, int *p, int *d, int *g){
|
|
int i;
|
|
int i;
|
|
if (argc < 2) return 1; // error
|
|
if (argc < 2) return 1; // error
|
|
strncpy(filename,argv[1],100);
|
|
strncpy(filename,argv[1],100);
|
|
@@ -299,6 +299,10 @@ int parseCommandline(int argc, char *argv[], char* filename,int *r,float *lat,fl
|
|
i++;
|
|
i++;
|
|
*d = atoi(argv[i]);
|
|
*d = atoi(argv[i]);
|
|
break;
|
|
break;
|
|
|
|
+ case 'g': // device
|
|
|
|
+ i++;
|
|
|
|
+ *g = atoi(argv[i]);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -326,6 +330,7 @@ void printUsage(){
|
|
printf("\n");
|
|
printf("\n");
|
|
printf("-p [int] Choose the platform (must choose both platform and device)\n");
|
|
printf("-p [int] Choose the platform (must choose both platform and device)\n");
|
|
printf("-d [int] Choose the device (must choose both platform and device)\n");
|
|
printf("-d [int] Choose the device (must choose both platform and device)\n");
|
|
|
|
+ printf("-g [int] Choose 1 for GPU, 0 for CPU\n");
|
|
printf("\n");
|
|
printf("\n");
|
|
printf("\n");
|
|
printf("\n");
|
|
printf("Notes: 1. The filename is required as the first parameter.\n");
|
|
printf("Notes: 1. The filename is required as the first parameter.\n");
|