/*! * \brief Send message by defined LogOutput method, satisfy thread safety * \param[in] message * \author Sascha Kaden * \date 2016-11-14 */ void Logging::sendString(const std::string& message, LogLevel level) { if (level > m_level) return; m_mutex.lock(); if (m_output == LogOutput::file) { writeToFile(message); } else if (m_output == LogOutput::terminlAndFile) { printToTerminal(message); writeToFile(message); } else { printToTerminal(message); } m_mutex.unlock(); }
void Menu::setup() { printToTerminal(); }
int main(int argc, char* argv[]) { int totalNumPoints = 0; int numClusters = 0; int dim = 2; //default 2 dimensions char* inFile = ""; //"/Users/neil/Documents/cluster.csv", /afs/andrew.cmu.edu/usr11/ndhruva/public/test.txt char* outFile = ""; //"./output/2doutput_mpi.csv" double stopThreshold = 0.001; //default threshold int maxIter = 100000; //default max iterations int printTime = 0; extern char optopt; extern char* optarg; //process input char arg; int err; while((arg=getopt(argc,argv,"i:n:p:d:otmv")) != -1) { switch (arg) { case 'i': { inFile=optarg; break; } case 'n': { numClusters = atoi(optarg); break; } case 'p': { totalNumPoints = atoi(optarg); break; } case 'o': { outFile=optarg; break; } case 't': { stopThreshold=atof(optarg); break; } case 'm': { maxIter=atoi(optarg); break; } case 'd': { dim=atoi(optarg); break; } case 'v': { printTime=atoi(optarg); break; } case '?': { fprintf(stderr, "Unrecognized option -%c.\n", optopt); err = 1; break; } default: { break; } } } if(err==1 || (inFile && inFile[0] == '\0') || numClusters <= 0 || totalNumPoints <= 0 || stopThreshold <= 0.0 || maxIter <= 0) { return 0; } char** init_centers = (char**)malloc(numClusters*sizeof(char*)); struct timeb tmb; ftime(&tmb); double startInputTime = (double)tmb.time+(double)tmb.millitm/1000; char** points = readFromFileForGP(inFile, dim, totalNumPoints); ftime(&tmb); double endInputTime = (double)tmb.time+(double)tmb.millitm/1000; ftime(&tmb); double startClusteringTime = (double)tmb.time+(double)tmb.millitm/1000; char** cluster_centers = get_cluster_centers_seq(points, totalNumPoints, numClusters, dim, maxIter, totalNumPoints, stopThreshold); ftime(&tmb); double endClusteringTime = (double)tmb.time+(double)tmb.millitm/1000; ftime(&tmb); double startOutputTime = (double)tmb.time+(double)tmb.millitm/1000; if(outFile && outFile[0] != '\0') { writeToFileForGP(outFile, cluster_centers, numClusters, dim); } else { printToTerminal(cluster_centers, numClusters, dim); } ftime(&tmb); double endOutputTime = (double)tmb.time+(double)tmb.millitm/1000; if(printTime == 1) { printf("IO time: %lf\n", (endInputTime-startInputTime+endOutputTime-startOutputTime)); printf("Clustering time: %lf\n", (endClusteringTime-startClusteringTime)); } free(points); free(cluster_centers); return 0; }