|
@@ -87,15 +87,18 @@ extern double wtime(void);
|
|
|
/*---< usage() >------------------------------------------------------------*/
|
|
|
void usage(char *argv0) {
|
|
|
char *help =
|
|
|
- "\nUsage: %s [switches] -i filename\n\n"
|
|
|
+ "\nUsage: %s [switches] -i filename\n\n"
|
|
|
" -i filename :file containing data to be clustered\n"
|
|
|
" -m max_nclusters :maximum number of clusters allowed [default=5]\n"
|
|
|
- " -n min_nclusters :minimum number of clusters allowed [default=5]\n"
|
|
|
+ " -n min_nclusters :minimum number of clusters allowed [default=5]\n"
|
|
|
" -t threshold :threshold value [default=0.001]\n"
|
|
|
" -l nloops :iteration for each number of clusters [default=1]\n"
|
|
|
" -b :input file is in binary format\n"
|
|
|
- " -r :calculate RMSE [default=off]\n"
|
|
|
- " -o :output cluster center coordinates [default=off]\n";
|
|
|
+ " -r :calculate RMSE [default=off]\n"
|
|
|
+ " -o :output cluster center coordinates [default=off]\n"
|
|
|
+ " -p platform_id :OCL platform to use [default=0]\n"
|
|
|
+ " -d device_id :OCL device to use [default=0]\n"
|
|
|
+ " -g use_gpu :1 for GPU 0 for CPU [default=0]\n";
|
|
|
fprintf(stderr, help, argv0);
|
|
|
exit(-1);
|
|
|
}
|
|
@@ -103,7 +106,7 @@ void usage(char *argv0) {
|
|
|
/*---< main() >-------------------------------------------------------------*/
|
|
|
int setup(int argc, char **argv) {
|
|
|
int opt;
|
|
|
- extern char *optarg;
|
|
|
+ extern char *optarg;
|
|
|
char *filename = 0;
|
|
|
float *buf;
|
|
|
char line[1024];
|
|
@@ -127,9 +130,14 @@ int setup(int argc, char **argv) {
|
|
|
|
|
|
int isOutput = 0;
|
|
|
//float cluster_timing, io_timing;
|
|
|
+
|
|
|
+ // Variables to store information on platform and device to use_gpu
|
|
|
+ int platform_id = 0;
|
|
|
+ int device_id = 0;
|
|
|
+ int use_gpu = 0;
|
|
|
|
|
|
/* obtain command line arguments and change appropriate options */
|
|
|
- while ( (opt=getopt(argc,argv,"i:t:m:n:l:bro"))!= EOF) {
|
|
|
+ while ( (opt=getopt(argc,argv,"i:t:m:n:l:brop:d:g:"))!= EOF) {
|
|
|
switch (opt) {
|
|
|
case 'i': filename=optarg;
|
|
|
break;
|
|
@@ -141,12 +149,18 @@ int setup(int argc, char **argv) {
|
|
|
break;
|
|
|
case 'n': min_nclusters = atoi(optarg);
|
|
|
break;
|
|
|
- case 'r': isRMSE = 1;
|
|
|
+ case 'r': isRMSE = 1;
|
|
|
break;
|
|
|
- case 'o': isOutput = 1;
|
|
|
- break;
|
|
|
- case 'l': nloops = atoi(optarg);
|
|
|
- break;
|
|
|
+ case 'o': isOutput = 1;
|
|
|
+ break;
|
|
|
+ case 'l': nloops = atoi(optarg);
|
|
|
+ break;
|
|
|
+ case 'p': platform_id = atoi(optarg);
|
|
|
+ break;
|
|
|
+ case 'd': device_id = atoi(optarg);
|
|
|
+ break;
|
|
|
+ case 'g': use_gpu = atoi(optarg);
|
|
|
+ break;
|
|
|
case '?': usage(argv[0]);
|
|
|
break;
|
|
|
default: usage(argv[0]);
|
|
@@ -242,11 +256,14 @@ int setup(int argc, char **argv) {
|
|
|
min_nclusters, /* range of min to max number of clusters */
|
|
|
max_nclusters,
|
|
|
threshold, /* loop termination factor */
|
|
|
- &best_nclusters, /* return: number between min and max */
|
|
|
- &cluster_centres, /* return: [best_nclusters][nfeatures] */
|
|
|
- &rmse, /* Root Mean Squared Error */
|
|
|
+ &best_nclusters, /* return: number between min and max */
|
|
|
+ &cluster_centres, /* return: [best_nclusters][nfeatures] */
|
|
|
+ &rmse, /* Root Mean Squared Error */
|
|
|
isRMSE, /* calculate RMSE */
|
|
|
- nloops); /* number of iteration for each number of clusters */
|
|
|
+ nloops,
|
|
|
+ platform_id,
|
|
|
+ device_id,
|
|
|
+ use_gpu); /* number of iteration for each number of clusters */
|
|
|
|
|
|
//cluster_timing = omp_get_wtime() - cluster_timing;
|
|
|
|