HW2: Setup build env and basic code setup
This commit is contained in:
+76
-1
@@ -1,3 +1,78 @@
|
||||
int main(void) {
|
||||
/*!
|
||||
* \file main.cpp
|
||||
* \brief Main application file for PDS HW2 (MPI)
|
||||
*
|
||||
* \author
|
||||
* Christos Choutouridis AEM:8997
|
||||
* <cchoutou@ece.auth.gr>
|
||||
*/
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
#include "matrix.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "config.h"
|
||||
|
||||
// Global session data
|
||||
session_t session;
|
||||
|
||||
/*!
|
||||
* A small command line argument parser
|
||||
* \return The status of the operation
|
||||
*/
|
||||
bool get_options(int argc, char* argv[]){
|
||||
bool status =true;
|
||||
|
||||
// iterate over the passed arguments
|
||||
for (int i=1 ; i<argc ; ++i) {
|
||||
std::string arg(argv[i]); // get current argument
|
||||
|
||||
if (arg == "-x" || arg == "--xxxxx") {
|
||||
if (i+2 < argc) {
|
||||
// session.corpusMtxFile = std::string(argv[++i]);
|
||||
// session.corpusDataSet = std::string(argv[++i]);
|
||||
}
|
||||
else
|
||||
status = false;
|
||||
}
|
||||
|
||||
else if (arg == "-v" || arg == "--verbose")
|
||||
session.verbose = true;
|
||||
else if (arg == "-h" || arg == "--help") {
|
||||
std::cout << "distbitonic - A distributed bitonic sort\n\n";
|
||||
std::cout << "distbitonic -x <> [-v]\n";
|
||||
std::cout << '\n';
|
||||
std::cout << "Options:\n\n";
|
||||
std::cout << " -v | --verbose\n";
|
||||
std::cout << " Request a more verbose output to stdout.\n\n";
|
||||
std::cout << " -h | --help\n";
|
||||
std::cout << " Prints this and exit.\n\n";
|
||||
std::cout << "Examples:\n\n";
|
||||
std::cout << " ...Example case...:\n";
|
||||
std::cout << " > distbitonic -x <xxxxx> \n\n";
|
||||
|
||||
exit(0);
|
||||
}
|
||||
else { // parse error
|
||||
std::cout << "Invocation error. Try -h for details.\n";
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) try {
|
||||
// try to read command line
|
||||
if (!get_options(argc, argv))
|
||||
exit(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
//we probably pollute the user's screen. Comment `cerr << ...` if you don't like it.
|
||||
std::cerr << "Error: " << e.what() << '\n';
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user