예제 #1
0
파일: yada.c 프로젝트: HPDCS/htmMCATS
/* =============================================================================
 * main
 * =============================================================================
 */
MAIN(argc, argv)
{
    GOTO_REAL();

    SETUP_NUMBER_TASKS(6);

    /*
     * Initialization
     */

    parseArgs(argc, (char** const)argv);
    SIM_GET_NUM_CPU(global_numThread);
    TM_STARTUP(global_numThread, 0);
    P_MEMORY_STARTUP(global_numThread);

    SETUP_NUMBER_THREADS(global_numThread);

    thread_startup(global_numThread);


int repeat = global_repeats;
double time_total = 0.0;
double energy_total = 0.0;
for (; repeat > 0; --repeat) {

    global_meshPtr = mesh_alloc();
    assert(global_meshPtr);
    long initNumElement = mesh_read(global_meshPtr, global_inputPrefix);
    global_workHeapPtr = heap_alloc(1, &element_heapCompare);
    assert(global_workHeapPtr);
    long initNumBadElement = initializeWork(global_workHeapPtr, global_meshPtr);

    TIMER_T start;
    TIMER_READ(start);
    GOTO_SIM();
    thread_start(process, NULL);
    GOTO_REAL();
    TIMER_T stop;
    TIMER_READ(stop);
double time_tmp = TIMER_DIFF_SECONDS(start, stop);
PRINT_STATS();
time_total += time_tmp;

}
    printf("Time = %0.3lf\n",
           time_total);
    fflush(stdout);

    TM_SHUTDOWN();
    P_MEMORY_SHUTDOWN();

    GOTO_SIM();

    thread_shutdown();

    MAIN_RETURN(0);
}
예제 #2
0
파일: yada.c 프로젝트: jaingaurav/rstm
/* =============================================================================
 * main
 * =============================================================================
 */
MAIN(argc, argv)
{
    /*
     * Initialization
     */

    parseArgs(argc, (char** const)argv);
    SIM_GET_NUM_CPU(global_numThread);
    TM_STARTUP(global_numThread);
    P_MEMORY_STARTUP(global_numThread);
    thread_startup(global_numThread);
    global_meshPtr = mesh_alloc();
    assert(global_meshPtr);
    printf("Angle constraint = %lf\n", global_angleConstraint);
    printf("Reading input... ");
    long initNumElement = mesh_read(global_meshPtr, (char*)global_inputPrefix);
    puts("done.");
    global_workHeapPtr = heap_alloc(1, &yada_heapcompare);
    assert(global_workHeapPtr);
    long initNumBadElement = initializeWork(global_workHeapPtr, global_meshPtr);

    printf("Initial number of mesh elements = %li\n", initNumElement);
    printf("Initial number of bad elements  = %li\n", initNumBadElement);
    printf("Starting triangulation...");
    fflush(stdout);

    /*
     * Run benchmark
     */

    // NB: Since ASF/PTLSim "REAL" is native execution, and since we are using
    //     wallclock time, we want to be sure we read time inside the
    //     simulator, or else we report native cycles spent on the benchmark
    //     instead of simulator cycles.
    GOTO_SIM();
    TIMER_T start;
    TIMER_READ(start);
#ifdef OTM
#pragma omp parallel
    {
        process();
    }
#else
    thread_start((void(*)(void*))process, NULL);
#endif
    TIMER_T stop;
    TIMER_READ(stop);
    // NB: As above, timer reads must be done inside of the simulated region
    //     for PTLSim/ASF
    GOTO_REAL();

    puts(" done.");
    printf("Elapsed time                    = %0.3lf\n",
           TIMER_DIFF_SECONDS(start, stop));
    fflush(stdout);

    /*
     * Check solution
     */

    long finalNumElement = initNumElement + global_totalNumAdded;
    printf("Final mesh size                 = %li\n", finalNumElement);
    printf("Number of elements processed    = %li\n", global_numProcess);
    fflush(stdout);

#if 1
    bool isSuccess = mesh_check(global_meshPtr, finalNumElement);
#else
    bool isSuccess = true;
#endif
    printf("Final mesh is %s\n", (isSuccess ? "valid." : "INVALID!"));
    fflush(stdout);
    assert(isSuccess);

    /*
     * TODO: deallocate mesh and work heap
     */
    TM_SHUTDOWN();
    P_MEMORY_SHUTDOWN();

    GOTO_SIM();

    thread_shutdown();

    MAIN_RETURN(0);
}
예제 #3
0
/* =============================================================================
 * main
 * =============================================================================
 */
MAIN(argc, argv)
{
    char exitmsg[1024];

    GOTO_REAL();

    load_syncchar_map("sync_char.map.yada");

    /*
     * Initialization
     */

    parseArgs(argc, (char** const)argv);
    sprintf(exitmsg, "END BENCHMARK %s-parallel-phase\n", argv[0]);

    SIM_GET_NUM_CPU(global_numThread);
    TM_STARTUP(global_numThread);
    P_MEMORY_STARTUP(global_numThread);
    thread_startup(global_numThread);
    global_meshPtr = mesh_alloc();
    assert(global_meshPtr);
    printf("Angle constraint = %lf\n", global_angleConstraint);
    printf("Reading input... ");
    long initNumElement = mesh_read(global_meshPtr, global_inputPrefix);
    puts("done.");
    global_workHeapPtr = heap_alloc(1, &element_heapCompare);
    assert(global_workHeapPtr);
    long initNumBadElement = initializeWork(global_workHeapPtr, global_meshPtr);

    printf("Initial number of mesh elements = %li\n", initNumElement);
    printf("Initial number of bad elements  = %li\n", initNumBadElement);
    printf("Starting triangulation...");
    fflush(stdout);

    /*
     * Run benchmark
     */

    TIMER_T start;
    TIMER_READ(start);
    OSA_PRINT("entering parallel phase\n",0);
    START_INSTRUMENTATION();
    GOTO_SIM();
#ifdef OTM
#pragma omp parallel
    {
        process();
    }
#else
    thread_start(process, NULL);
#endif
    GOTO_REAL();
    OSA_PRINT("exiting parallel phase\n",0);
    OSA_PRINT(exitmsg,0);
    STOP_INSTRUMENTATION();
    TIMER_T stop;
    TIMER_READ(stop)

    puts(" done.");
    printf("Elapsed time                    = %0.3lf\n",
           TIMER_DIFF_SECONDS(start, stop));
    fflush(stdout);

    /*
     * Check solution
     */

    long finalNumElement = initNumElement + global_totalNumAdded;
    printf("Final mesh size                 = %li\n", finalNumElement);
    printf("Number of elements processed    = %li\n", global_numProcess);
    fflush(stdout);

#if 0
    bool_t isSuccess = mesh_check(global_meshPtr, finalNumElement);
#else
    bool_t isSuccess = TRUE;
#endif
    printf("Final mesh is %s\n", (isSuccess ? "valid." : "INVALID!"));
    fflush(stdout);
    assert(isSuccess);

    /*
     * TODO: deallocate mesh and work heap
     */

    TM_SHUTDOWN();
    P_MEMORY_SHUTDOWN();

    GOTO_SIM();

    thread_shutdown();

    MAIN_RETURN(0);
}
예제 #4
0
/* =============================================================================
 * main
 * =============================================================================
 */
int main (int argc, char** argv)
{
    /*
     * Initialization
     */

    parseArgs(argc, (char** const)argv);

    thread_startup(global_numThread);
    global_meshPtr = mesh_alloc();
    assert(global_meshPtr);
    printf("Angle constraint = %lf\n", global_angleConstraint);
    printf("Reading input... ");
    long initNumElement = mesh_read(global_meshPtr, global_inputPrefix);
    puts("done.");
    global_workHeapPtr = heap_alloc(1, &element_heapCompare);
    assert(global_workHeapPtr);
    long initNumBadElement = initializeWork(global_workHeapPtr, global_meshPtr);

    printf("Initial number of mesh elements = %li\n", initNumElement);
    printf("Initial number of bad elements  = %li\n", initNumBadElement);
    printf("Starting triangulation...");
    fflush(stdout);

    /*
     * Run benchmark
     */

    TIMER_T start;
    TIMER_READ(start);
#ifdef OTM
    #pragma omp parallel
    {
        process();
    }
#else
    thread_start(process, NULL);
#endif
    TIMER_T stop;
    TIMER_READ(stop);

    puts(" done.");
    printf("Time                            = %0.3lf\n",
           TIMER_DIFF_SECONDS(start, stop));
    fflush(stdout);

    /*
     * Check solution
     */

    long finalNumElement = initNumElement + global_totalNumAdded;
    printf("Final mesh size                 = %li\n", finalNumElement);
    printf("Number of elements processed    = %li\n", global_numProcess);
    fflush(stdout);

#if 0
    bool_t isSuccess = mesh_check(global_meshPtr, finalNumElement);
#else
    bool_t isSuccess = TRUE;
#endif
    printf("Final mesh is %s\n", (isSuccess ? "valid." : "INVALID!"));
    fflush(stdout);
    assert(isSuccess);

    /*
     * TODO: deallocate mesh and work heap
     */

    thread_shutdown();

    return 0;
}