Esempio n. 1
0
int main(int argc, char** argv)
{
  std::string working_directory = "";
  std::string decomp_method = "";
  std::string mesh = "";
  std::string type = "exodusii";
  int id_integer_size = 4;
  bool create_faces = false;
  bool create_edges = false;
  bool create_skin  = false;
  //----------------------------------
  // Process the broadcast command line arguments
  stk::ParallelMachine comm = stk::parallel_machine_init(&argc, &argv);
  stk::BroadcastArg b_arg(comm, argc, argv);
  bopt::options_description desc("options");

  desc.add_options()
    ("help,h", "produce help message")
    ("directory,d",   bopt::value<std::string>(&working_directory),
     "working directory with trailing '/'" )
    ("decomposition,D", bopt::value<std::string>(&decomp_method),
     "decomposition method.  One of: linear, rcb, rib, hsfc, block, cyclic, random, kway, geom_kway, metis_sfc" )
    ("faces", "create all faces" )
    ("edges", "create all edges" )
    ("skin",  "create all boundary faces (skin of the model)" )
    ("id_integer_size", bopt::value<int>(&id_integer_size), "use 4 or 8-byte integers for ids" )
    ("mesh",          bopt::value<std::string>(&mesh),
     "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Can also specify a filename." );

  stk::get_options_description().add(desc);

  bopt::variables_map &vm = stk::get_variables_map();
  try {
    bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm);
    bopt::notify(vm);
  }
  catch (std::exception & /* x */) {
    std::exit(1);
  }

  if (mesh.empty()) {
    std::cerr << "\nERROR: The --mesh option is required\n";
    std::cerr << "\nApplication " << desc << "\n";
    std::exit(EXIT_FAILURE);
  }

  if (vm.count("help")) {
    std::cout << "Usage: " << argv[0] << " " << desc << "\n";
    std::exit(EXIT_SUCCESS);
  }
  
  if (vm.count("faces")) {create_faces = true;}
  if (vm.count("edges")) {create_edges = true;}
  if (vm.count("skin"))  {create_skin  = true;}

  type = "exodusii";
  if (strncasecmp("gen:", mesh.c_str(), 4) == 0) {
    mesh = mesh.substr(4, mesh.size());
    type = "generated";
  }
  if (strncasecmp("dof:", mesh.c_str(), 4) == 0) {
    mesh = mesh.substr(4, mesh.size());
    type = "dof";
  }

  driver(comm, working_directory, mesh, type, decomp_method,
	 create_edges, create_faces, create_skin, id_integer_size);

  stk::parallel_machine_finalize();
  return 0;
}
Esempio n. 2
0
int main(int argc, char** argv)
{
  use_case::UseCaseEnvironment use_case_environment(&argc, &argv);
  stk_classic::ParallelMachine comm = use_case_environment.m_comm;

  //----------------------------------
  // Broadcast argc and argv to all processors.

  stk_classic::BroadcastArg b_arg(comm, argc, argv);

  //----------------------------------
  // Process the broadcast command line arguments

  bopt::options_description desc("options");

  stk_classic::get_options_description().add(desc);

  int num_trials = 0;
  int nthreads = 1;
  int bucket_size = 1000;

  desc.add_options()
    ("help,h",        "produce help message")
    ("performance",   "run performance test [14/14a/blas only]")
    ("mesh,m",        bopt::value<std::string>(), "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." )
    ("directory,d",   bopt::value<std::string>(), "working directory with trailing '/'" )
    ("output-log,o",  bopt::value<std::string>(), "output log path" )
    ("runtest,r",     bopt::value<std::string>(), "runtest pid file" )
    ("threads",       bopt::value<int>(&nthreads)->default_value(1),   "number of threads [14/14a/blas only]")
    ("trials",        bopt::value<int>(&num_trials)->default_value(1),   "number of trials (execute loops) [14/14a/blas only]")
    ("bucket_size",    bopt::value<int>(&bucket_size)->default_value(1000),   "size of buckets used internally in stk_classic::mesh [14/14a/blas only]")
    ("tbb",           "Use Threaded Building Blocks algorithm thread runner [14/14a/blas only]")
    ("tpi",           "Use Thread Pool Interface algorithm thread runner [14/14a/blas only]")
    ("nonthreaded",   "Run algorithms non-threaded [default] [14/14a/blas only]")
    ( use_case_7 ,   "use case 7" )
    ( use_case_blas , "use case blas (fill, axpby, dot, norm)" )
    ( use_case_14 ,   "use case 14 (hex internal force algorithm)" )
    ( use_case_14a ,  "use case 14a (hex internal force algorithm)" )
    ( use_case_24 ,   "use case 24 " );

  bopt::variables_map vm;
  try {
    bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm);
    bopt::notify(vm);
  }
  catch (std::exception &x) {
    std::cout << x.what() << std::endl;
    std::exit(1);
  }


  //----------------------------------

  if (vm.count("help")) {
    std::cout << desc << "\n";
    std::exit(EXIT_SUCCESS);
  }

  bool run_performance_test = vm.count( "performance" ) > 0;

  std::string thread_runner = "NonThreaded";
  if (vm.count("tbb"))
    thread_runner = "TBB";
  if (vm.count("tpi"))
    thread_runner = "TPI";
//   if (vm.count("dgb"))
//     thread_runner = "DGB";
  if (vm.count("nonthreaded"))
    thread_runner = "NonThreaded";

  std::string working_directory = "";
  std::string in_filename = "";
  std::string in_filetype = "exodusii";
  if (vm.count("mesh")) {
    in_filename = boost::any_cast<std::string>(vm["mesh"].value());;

    if (strncasecmp("gen:", in_filename.c_str(), 4) == 0) {
      // Strip off the 'gen:' prefix and set the type to "generated"
      in_filename = in_filename.substr(4, in_filename.size());
      in_filetype = "generated";
    }

    if (strncasecmp("gears:", in_filename.c_str(), 6) == 0) {
      // Strip off the 'gears:' prefix and set the type to "gears"
      in_filename = in_filename.substr(6, in_filename.size());
      in_filetype = "gears";
    }

    if (vm.count("directory")) {
      working_directory = boost::any_cast<std::string>(vm["directory"].value());
    }
  } else {
    std::cout << "OPTION ERROR: The '--mesh <filename>' option is required for all use cases!\n";
    std::exit(EXIT_FAILURE);
  }

  bool success = false;

  if ( vm.count( use_case_7 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 7, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_classic::app::use_case_7_driver( comm , run_performance_test , in_filename , nthreads, thread_runner );
  }

  else if ( vm.count( use_case_blas ) ) {
    success = stk_classic::app::use_case_blas_driver(comm, nthreads, num_trials, working_directory,
                                             in_filename, in_filetype, thread_runner, bucket_size,
                                             run_performance_test);
  }

  else if ( vm.count( use_case_14 ) ) {
    success = stk_classic::app::use_case_14_driver(comm, nthreads, num_trials, working_directory,
                                           in_filename, in_filetype, thread_runner, bucket_size,
                                           run_performance_test);
  }

  else if ( vm.count( use_case_14a ) ) {
    success = stk_classic::app::use_case_14a_driver(comm, nthreads, num_trials, working_directory,
                                            in_filename, in_filetype, thread_runner, bucket_size,
                                            run_performance_test);
  }

  else if ( vm.count( use_case_24 ) ) {
    if (in_filetype == "generated") {
      std::cout << "OPTION ERROR: The 'generated mesh option' option is not supported for use case 24!\n";
      std::exit(EXIT_FAILURE);
    }

    if (in_filetype == "gears") {
      std::cout << "OPTION ERROR: The 'gears mesh option' option is not supported for use case 24!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_classic::app::use_case_24_driver( comm, working_directory, in_filename, "1mCube.e" );
  }
  else {
    std::cout << "OPTION ERROR: Missing a use case selection option.  Use --help option to see valid options.\n";
    std::exit(EXIT_FAILURE);
  }

  use_case::print_status(comm, success);

  return 0;
}
int main(int argc, char** argv)
{
  use_case::UseCaseEnvironment use_case_environment(&argc, &argv);
  stk::ParallelMachine comm = use_case_environment.m_comm;

  //----------------------------------
  // Broadcast argc and argv to all processors.

  stk::BroadcastArg b_arg(comm, argc, argv);

  //----------------------------------
  // Process the broadcast command line arguments

  bopt::options_description desc("options");

  stk::get_options_description().add(desc);

  int nthreads = 1;
  int bucket_size = 1000;

  desc.add_options()
    ("help,h",        "produce help message")
    ("mesh,m",        bopt::value<std::string>(), "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." )
    ("directory,d",   bopt::value<std::string>(), "working directory with trailing '/'" )
    ("output-log,o",  bopt::value<std::string>(), "output log path" )
    ("runtest,r",     bopt::value<std::string>(), "runtest pid file" )
    ("threads",       bopt::value<int>(&nthreads)->default_value(1),   "number of threads")
    ("bucket_size",    bopt::value<int>(&bucket_size)->default_value(1000),   "size of buckets used internally in stk::mesh")
    ("tbb",           "Use Threaded Building Blocks algorithm thread runner")
    ("tpi",           "Use Thread Pool Interface algorithm thread runner")
    ("nonthreaded",   "Run algorithms non-threaded [default]")
    ("solver_params",   "Teuchos parameter XML filename")
    ( use_case_1 ,   "use case 1" )
    ( use_case_2 ,   "use case 2" )
    ( use_case_3 ,   "use case 3" )
    ( use_case_4 ,   "use case 4" )
    ( use_case_5 ,   "use case 5" )
    ( use_case_7 ,   "use case 7" );

  bopt::variables_map vm;
  try {
    bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm);
    bopt::notify(vm);
  }
  catch (std::exception &x) {
    std::cout << x.what() << std::endl;
    std::cout << "Test Failed" << std::endl;
    stk::parallel_machine_finalize();
    std::exit(1);
  }


  //----------------------------------

  if (vm.count("help")) {
    std::cout << desc << "\n";
    std::exit(EXIT_SUCCESS);
  }

  std::string thread_runner = "NonThreaded";
  if (vm.count("tbb"))
    thread_runner = "TBB";
  if (vm.count("tpi"))
    thread_runner = "TPI";
  if (vm.count("nonthreaded"))
    thread_runner = "NonThreaded";

  // Used by multiple use cases.
  std::string working_directory = "";
  std::string in_filename = "";
  std::string in_filetype = "exodusii";
  if (vm.count("mesh")) {
    in_filename = boost::any_cast<std::string>(vm["mesh"].value());;

    if (strncasecmp("gen:", in_filename.c_str(), 4) == 0) {
      // Strip off the 'gen:' prefix and set the type to "generated"
      in_filename = in_filename.substr(4, in_filename.size());
      in_filetype = "generated";
    }

    if (strncasecmp("gears:", in_filename.c_str(), 6) == 0) {
      // Strip off the 'gears:' prefix and set the type to "gears"
      in_filename = in_filename.substr(6, in_filename.size());
      in_filetype = "gears";
    }

    if (vm.count("directory")) {
      working_directory = boost::any_cast<std::string>(vm["directory"].value());
    }
  } else {
    std::cout << "OPTION ERROR: The '--mesh <filename>' option is required for all use cases!\n";
    std::exit(EXIT_FAILURE);
  }

  bool success = false;

  if ( vm.count( use_case_1 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 1, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_linsys_usecases::use_case_1_driver( comm , in_filename );
  }
  else if ( vm.count( use_case_2 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 2, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_linsys_usecases::use_case_2_driver( comm , in_filename );
  }
  else if ( vm.count( use_case_3 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 3, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_linsys_usecases::use_case_3_driver( comm , in_filename );
  }
  else if ( vm.count( use_case_4 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 4, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    success = stk_linsys_usecases::use_case_4_driver( comm , in_filename );
  }
  else if ( vm.count( use_case_5 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 5, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    std::string solver_params = "";

    if( vm.count("solver_params")) {
      solver_params = boost::any_cast<std::string>(vm["solver_params"].value());
    }

    success = stk_linsys_usecases::use_case_5_driver( comm , in_filename, solver_params );
  }
  else if ( vm.count( use_case_7 ) ) {

    if (in_filetype != "generated") {
      std::cout << "OPTION ERROR: For use case 7, only the 'generated' mesh option is supported!\n";
      std::exit(EXIT_FAILURE);
    }

    std::string solver_params = "";

    if( vm.count("solver_params")) {
      solver_params = boost::any_cast<std::string>(vm["solver_params"].value());
    }

    success = stk_linsys_usecases::use_case_7_driver( comm , in_filename, solver_params );
  }
  else {
    std::cout << "OPTION ERROR: Missing a use case selection option.  Use --help option to see valid options.\n";
    std::exit(EXIT_FAILURE);
  }

  use_case::print_status(comm, success);

  return 0;
}