view example/word_count/main.cc @ 2069:26aa08c9a1de draft default tip

cuda example fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 12 Feb 2017 10:04:55 +0900
parents 030b8efcf357
children
line wrap: on
line source

#include <stdio.h>
#include <sys/time.h>
#include "TaskManager.h"
#include "SchedTask.h"
#include "Func.h"
#include "FileMapReduce.h"

/* ;TODO
 * PS3でCPU数が2以上の時に、あまりが計算されてない
 */

extern void task_init();
void TMend(TaskManager *);
static double st_time;
static double ed_time;
const char* usr_help_str = "";

static double
getTime() {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + (double)tv.tv_usec*1e-6;
}

int
TMmain(TaskManager *manager, int argc, char *argv[])
{

    char *filename = 0;
    FileMapReduce *fmp = new FileMapReduce(manager,TASK_EXEC,TASK_EXEC_DATA_PARALLEL,TASK_PRINT);
    filename = fmp->init(argc, argv);
    if (filename < 0) {
        return -1;
    }
    fmp->division_out_size = sizeof(unsigned long long)*4;
    task_init();
    st_time = getTime();
    fmp->run_start(manager, filename);
    manager->set_TMend(TMend);
    return 0;
}

void
TMend(TaskManager *manager)
{
    ed_time = getTime();
    printf("Time: %0.6f\n",ed_time-st_time);
}

/* end */