Exemplo n.º 1
0
Arquivo: fw.c Projeto: gideonla/w2014
/* Assumptions on arguments: -n must be present, the number of nodes.
 * -t may or may not be present. If it is, then it's # threads. If not,
 *  indicates serial execution. If filename not present, read from stdin.
 */
int main(int argc, char *argv[]) {
    int n_nodes = 0, n_threads = 0;
    char *filename, *outfile = NULL;
    int opt;
    while (opt = getopt(argc, argv, "n:t:o:"), opt != -1) {
        switch (opt) {
            case 'n':
                n_nodes = (int) strtol(argv[optind], NULL, 10);
                break;
            case 't':
                n_threads = (int) strtol(argv[optind], NULL, 10);
                break;
            case 'o':
                outfile = argv[optind];
                break;
        }
    }
    if (optind >= argc) {
        filename = NULL;
    }
    else {
        filename = argv[optind];
    }
    /* Initialize adj matrix and fill it in */
    int *adj_matrix = malloc (n_nodes * n_nodes * sizeof(int));
    from_csv(adj_matrix, filename, n_nodes);
    if (n_threads == 0) {
        fw_serial(adj_matrix, n_nodes);
    } else {
        fw_parallel(adj_matrix, n_nodes, n_threads);
    }
    to_csv(adj_matrix, outfile, n_nodes);
    return 0;
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: Elekhyr/ran
int main(int argc, char *argv[]){

    if(argc > 2){
        max_time = (unsigned int) atoi(argv[1]);
    }

    if (argc > 3 && atoi(argv[2]) > 2){
        core_number = (unsigned int) atoi(argv[2]);
    }
    core_number = 6;
    int k;
    FILE *file;

    char *functions_names[] = {
            "tree_sort",
            "selection_sort",
            "heapsort",
            "insertion_sort",
            "merge_sort",
            "dichotomous_insertion_sort",
            "quicksort",
            "bubble_sort"
            //"insertion_sort_linked_list"
    };

    functions_t functions[] = {
            tree_sort,
            selection_sort,
            heapsort,
            insertion_sort,
            merge_sort,
            dichotomous_insertion_sort,
            quicksort,
            bubble_sort
            //insertion_sort_linked_list
    };

    int size = (int) (sizeof(functions) / sizeof(functions[0]));
    for(k = 0; k < core_number ; k++){
        create_child(functions, functions_names, size*k/core_number, size*(k+1)/core_number);
    }

    for(k = 0; k < core_number ; k++){
        wait(NULL);
    }

    file = fopen("results.csv", "w+");
    to_csv(file, functions_names, size);
    fclose(file);

    return 0;
}
Exemplo n.º 3
0
void output(const char *field, const char *value)
{
	switch (format) {
		case FORMAT_CSV:
			to_csv(field, value);
			break;
		case FORMAT_XML:
			to_xml(field, value);
			break;
		case FORMAT_HTML:
			to_html(field, value);
			break;
		case FORMAT_TEXT:
		default:
			to_text(field, value);
			break;
	}
}
Exemplo n.º 4
0
// save path to file in csv format
void minipath::save2csv(ministring filename)
   {to_csv().save(filename);}
Exemplo n.º 5
0
// serialization
std::string minipath::to_stdstring()
   {return(to_csv().to_string("\n").c_str());}
Exemplo n.º 6
0
void csv::to_csv(vector<string>& row, string& ret, bool crlf) {
  to_csv(row, ret, crlf, false);
}
Exemplo n.º 7
0
void csv::to_csv(vector<string>& row, string& ret) {
  to_csv(row, ret, true);
}
Exemplo n.º 8
0
void csv::to_csv(string& ret, bool crlf, bool empty_field_to_null) {
  to_csv(put_field_buffer, ret, crlf, empty_field_to_null);
  put_field_buffer.clear();
}
Exemplo n.º 9
0
void csv::to_csv(string& ret, bool crlf) {
  to_csv(put_field_buffer, ret, crlf, false);
  put_field_buffer.clear();
}
Exemplo n.º 10
0
void csv::to_csv(string& ret) {
  to_csv(put_field_buffer, ret, true);
  put_field_buffer.clear();
}