// single C-friendly interface for the above two functions
int parse_opts_and_paths(
    int               _argc,
    char**            _argv,
    rodsArguments_t&  _rods_args,
    rodsEnv*          _rods_env,
    int               _src_type,
    int               _dst_type,
    int               _flag,
    rodsPathInp_t*    _rods_paths ) {

    path_list_t paths;
    int p_err = parse_program_options(
                    _argc,
                    _argv,
                    _rods_args,
                    paths );
    if( p_err < 0 ) {
        return p_err;

    }

    p_err = build_irods_path_structure(
                 paths,
                 _rods_env,
                 _src_type,
                 _dst_type,
                 _flag,
                 _rods_paths );
    if( p_err < 0 ) {
        return p_err;
    }

    return 0;

} // parse_opts_and_paths
int main(int argn, char* argv[])
{
	po::variables_map vm = parse_program_options(argn, argv);

	if(vm.empty() || vm.count("help"))
	{
		return 0;
	}

	pid_t child_pid = fork();

	if(child_pid == 0)
	{
		// Make args string vector into null-terminated char* array
		std::vector<std::string> args_vec = vm["commands"].as<std::vector<std::string>>();
		std::vector<char*> args;

		for(auto& arg : args_vec)
		{
			args.push_back(const_cast<char*>(arg.c_str()));
		}

		args.push_back(nullptr);

		// Run given process
		if(!run_child(args_vec.front(), args.data()))
		{
			std::cerr << "Error : Failed to execute and trace the given commands." << std::endl;
		}
	}
	else if(child_pid == -1)
	{
		std::cerr << "Error : Failed to execute the given commands." << std::endl;
	}
	else
	{
		Tracer tracer;
		tracer.do_trace(child_pid, vm);
	}

	return 0;
}
Example #3
0
int main(int argc, char* argv[]) {

    El::Initialize(argc, argv);

    int seed, s, mind;
    std::string infile, outfile;
    double sigma;

    int flag = parse_program_options(argc, argv, seed, s, mind,
        infile, outfile, sigma);
    if (flag != 1000)
        return flag;

    skylark::base::context_t context(seed);

    boost::mpi::communicator world;
    int rank = world.rank();

    typedef El::DistMatrix<double, El::STAR, El::VR> data_matrix_t;
    typedef El::DistMatrix<El::Int, El::STAR, El::VR> label_matrix_t;

    data_matrix_t X;
    label_matrix_t L;

    boost::mpi::timer timer;

    // Load A and Y
    if (rank == 0) {
        std::cout << "Reading the matrix... ";
        std::cout.flush();
        timer.restart();
    }

    skylark::utility::io::ReadLIBSVM(infile, X, L,
        skylark::base::COLUMNS, mind);

    if (rank == 0)
        std::cout <<"took " << boost::format("%.2e") % timer.elapsed()
                  << " sec\n";

    // Compute kernel matrix
    if (rank == 0) {
        std::cout << "Computing the transformed matrix... ";
        std::cout.flush();
        timer.restart();
    }

    data_matrix_t Z(s, X.Width());
    skylark::ml::gaussian_t k(X.Height(), sigma);
    auto S = k.create_rft<data_matrix_t, data_matrix_t>(s,
        skylark::ml::regular_feature_transform_tag(), context);
    S->apply(X, Z, skylark::sketch::columnwise_tag());

    if (rank == 0)
        std::cout << "took " << boost::format("%.2e") % timer.elapsed()
                  << " sec\n";

    // Write output
    if (rank == 0) {
        std::cout << "Writing the matrix... ";
        std::cout.flush();
        timer.restart();
    }

    skylark::utility::io::WriteLIBSVM(outfile, Z, L, skylark::base::COLUMNS);

    if (rank == 0)
        std::cout <<"took " << boost::format("%.2e") % timer.elapsed()
                  << " sec\n";

    El::Finalize();
    return 0;
}