示例#1
0
bap_blocks_t * asmir_bap_from_trace_file(char * filename, 
                                         uint64_t offset,
                                         uint64_t numisns,
                                         long atts,
					 long pintrace)
{
  bap_blocks_t * b = read_trace_from_file(string(filename), 
					  offset,
                                          numisns,
					  false,
					  atts, 
					  pintrace);
  return b;
}
示例#2
0
int main(int argc, char *argv[])
{
    string progname, tracename ;
    bool print = false, atts = false ;
    int offset = 0 ;


    struct option options[] = {
        {"trace", required_argument, 0, 't'},
        {"offset", required_argument, 0, 'o'},
        {"attribute", no_argument, 0, 'a'},
        {"print", no_argument, 0, 'p'},
        {"help", no_argument, 0, 'h'},
        {0,0,0,0}
    };

    if(argc < 2) {
        help();
        return 0;
    }

    char c;
    int option_index;

    while( (c = getopt_long(argc, argv, "ahpt:o:",
                            options, &option_index)) > 0 ) {
        switch(c) {
        case 't':
            if(optarg == NULL) {
                Usage(argv[0]);
                return -1;
            }
            tracename = string(optarg);
            break;
        case 'o':
            if(optarg == NULL) {
                Usage(argv[0]);
                return -1;
            }
            offset = atoi(optarg) ;
            break;
        case 'p':
            print = true ;
            break;
        case 'a':
            atts = true ;
            break;
        case 'h':
            help();
            return 0;
            break;
        default:
            Usage(argv[0]);
            return -1;
            break;
        }
    }

    if(argc > optind) {
        progname = string(argv[optind]);
        optind++;
    }
    if(argc > optind) {
        Usage(argv[0]);
        return -1;
    }

    read_trace_from_file(tracename, offset, 0LL, print, atts, false);

    return 0;
}
示例#3
0
int main(int argc, char **argv) {
    ModelConfig model_config;
    ThreadDim thread_dim;
    std::vector<WarpTrace> warp_traces;
    std::vector<AnalyseTask> tasks;
    std::vector<DistanceStat> stats;


    //  Number of arguments check
    //  Argument 0: executable file name
    //  Argument 1: input trace file path
    //  Argument 2: output file path
    //  Argument 3: config file path
    if (argc != 4) {
        std::cout << "####  main: Too many or too few arguments.  ####" << std::endl;
        return -1;
    }

    //  Read model config from coresponding file
    std::cout << "####  main: Reading model config from '" << argv[3] << "'  ####" << std::endl;
    read_model_config_from_file(argv[3], model_config);

    //  Read input trace from file
    //  Coalescing is already done in this phase
    std::cout << "####  main: Reading trace from '" << argv[1] << "'  ####" << std::endl;
    read_trace_from_file(argv[1], warp_traces, thread_dim, model_config);

    //  Generate tasks
    AnalyseTask::generate_tasks(warp_traces, tasks, model_config, thread_dim);

    //  Assign memory for stats
    stats.resize(model_config.num_running_threads);

    //  Launch multiple threads to do the work
    std::vector<pthread_t> threads;
    std::vector<ThreadArgu> thread_argus;

    threads.resize(model_config.num_running_threads);
    thread_argus.resize(model_config.num_running_threads);
    stats.resize(model_config.num_running_threads);
    for (int i = 0; i < model_config.num_running_threads; i++) {
        int err;

        thread_argus[i].num_threads = model_config.num_running_threads;
        thread_argus[i].thread_id = i;
        thread_argus[i].p_tasks = &tasks;
        thread_argus[i].p_model_config = &model_config;
        thread_argus[i].p_stat = &stats[i];

        err = pthread_create(&threads[i], NULL, thread_task, (void *)&thread_argus[i]);
        if (err != 0) {
            std::cout << "main: Failed to create thread " << i << std::endl;
            return -1;
        }
    }

    //  Wait for all the work thead to exit
    for (int i = 0; i < model_config.num_running_threads; i++) {
        pthread_join(threads[i], NULL);
    }

    //  Combine the DistanceStat from different threads
    for (int i = 1; i < model_config.num_running_threads; i++) {
        stats[0].merge(stats[i]);
    }

    //  Write reuse distance stat to file
    std::cout << "####  main: Writing distances to '" << argv[2] << "'  ####" << std::endl;
    stats[0].write_to_file(argv[2], model_config);

    return 0;
}