コード例 #1
0
ファイル: util.hpp プロジェクト: Auguraculums/graphdb-testing
void mt_writexf(T& target, T2 val)
{
#ifdef __MTA__
  writexf(&target, val);
#elif USING_QTHREADS
  qthread_writeF_const((aligned_t*) &target, (aligned_t) val);
#else
  target = val;
#endif
}
コード例 #2
0
ファイル: net.c プロジェクト: deniskin82/chapel
static void die_msg_handler(int    tag,
                            void  *start,
                            size_t len)
{
    qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin die_msg_handler\n", my_rank);

    if (my_rank == 0) {
        num_ended++;
    } else {
        qthread_writeF_const(&time_to_die, 1);
    }

    qthread_debug(MULTINODE_FUNCTIONS, "[%d] end die_msg_handler\n", my_rank);
}
コード例 #3
0
ファイル: net.c プロジェクト: deniskin82/chapel
static void return_msg_handler(int    tag,
                               void  *start,
                               size_t len)
{
    struct return_msg_t *msg = (struct return_msg_t *)start;

    qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin return_msg_handler 0x%lx, %ld\n",
                  my_rank, (unsigned long)msg->return_addr, msg->return_val);

    qthread_writeF_const((aligned_t *)msg->return_addr, msg->return_val);

    qthread_debug(MULTINODE_FUNCTIONS, "[%d] end return_msg_handler\n",
                  my_rank);
}
コード例 #4
0
ファイル: net.c プロジェクト: Agobin/chapel
static void return_long_msg_handler(int    tag,
                                    void  *start,
                                    size_t len)
{
    struct return_msg_t *msg = (struct return_msg_t *)start;

    qthread_debug(MULTINODE_FUNCTIONS, "[%d] begin return_long_msg_handler 0x%lx, %ld\n",
                  my_rank, (unsigned long)msg->return_addr, msg->return_val);

    qthread_writeF_const((aligned_t *)msg->return_addr, msg->return_val);

    // TODO: figure out how to free long message. This is only called when there is
    //       a return value.

    qthread_debug(MULTINODE_FUNCTIONS, "[%d] end return_long_msg_handler\n",
                  my_rank);
}
コード例 #5
0
ファイル: time_stencil_pre.c プロジェクト: deniskin82/chapel
int main(int argc, char *argv[])
{
    int n = 10;
    int m = 10;
    num_timesteps = 10;
    workload = 0;
    workload_per = 0;
    workload_var = 0;
    int print_final = 0;
    int alltime = 0;

    CHECK_VERBOSE();
    NUMARG(n, "N");
    NUMARG(m, "M");
    NUMARG(num_timesteps, "TIMESTEPS");
    NUMARG(workload, "WORKLOAD");
    NUMARG(workload_per, "WORKLOAD_PER");
    NUMARG(workload_var, "WORKLOAD_VAR");
    NUMARG(print_final, "PRINT_FINAL");
    NUMARG(alltime, "ALL_TIME");

    assert (n > 0 && m > 0);

    // Initialize Qthreads
    assert(qthread_initialize() == 0);

    qtimer_t alloc_timer = qtimer_create();
    qtimer_t init_timer = qtimer_create();
    qtimer_t exec_timer = qtimer_create();

    // Allocate memory for 3-stage stencil (with boundary padding)
    qtimer_start(alloc_timer);
    stencil_t points;
    points.N = n + 2;
    points.M = m + 2;

    for (int s = 0; s < NUM_STAGES; s++) {
        points.stage[s] = malloc(points.N*sizeof(aligned_t *));
        assert(NULL != points.stage[s]);
        for (int i = 0; i < points.N; i++) {
            points.stage[s][i] = calloc(points.M, sizeof(aligned_t));
            assert(NULL != points.stage[s][i]);
        }
    }
    qtimer_stop(alloc_timer);

    // Initialize first stage and set boundary conditions
    qtimer_start(init_timer);
    for (int i = 1; i < points.N-1; i++) {
        for (int j = 1; j < points.M-1; j++) {
            qthread_writeF_const(&points.stage[0][i][j], 0);
            for (int s = 1; s < NUM_STAGES; s++)
                qthread_empty(&points.stage[s][i][j]);
        }
    }
    for (int i = 0; i < points.N; i++) {
        for (int s = 0; s < NUM_STAGES; s++) {
#ifdef BOUNDARY_SYNC
            qthread_writeF_const(&points.stage[s][i][0], BOUNDARY);
            qthread_writeF_const(&points.stage[s][i][points.M-1], BOUNDARY);
#else
            points.stage[s][i][0] = BOUNDARY;
            points.stage[s][i][points.M-1] = BOUNDARY;
#endif
        }
    }
    for (int j = 0; j < points.M; j++) {
        for (int s = 0; s < NUM_STAGES; s++) {
#ifdef BOUNDARY_SYNC
            qthread_writeF_const(&points.stage[s][0][j], BOUNDARY);
            qthread_writeF_const(&points.stage[s][points.N-1][j], BOUNDARY);
#else
            points.stage[s][0][j] = BOUNDARY;
            points.stage[s][points.N-1][j] = BOUNDARY;
#endif
        }
    }
    qtimer_stop(init_timer);

    // Create barrier to synchronize on completion of calculations
    qtimer_start(exec_timer);
    points.barrier = qt_feb_barrier_create(n*m+1);

    // Spawn tasks to start calculating updates at each point
    update_args_t args = {&points, -1, -1, 1, 1};
    for (int i = 1; i < points.N-1; i++) {
        for (int j = 1; j < points.M-1; j++) {
            args.i = i;
            args.j = j;
            qthread_fork_syncvar_copyargs(update, &args, sizeof(update_args_t), NULL);
        }
    }

    // Wait for calculations to finish
    qt_feb_barrier_enter(points.barrier);
    qtimer_stop(exec_timer);

    // Print timing info
    if (alltime) {
        fprintf(stderr, "Allocation time: %f\n", qtimer_secs(alloc_timer));
        fprintf(stderr, "Initialization time: %f\n", qtimer_secs(init_timer));
        fprintf(stderr, "Execution time: %f\n", qtimer_secs(exec_timer));
    } else {
        fprintf(stdout, "%f\n", qtimer_secs(exec_timer));
    }

    // Print stencils
    if (print_final) {
        size_t final = (num_timesteps % NUM_STAGES);
        iprintf("Stage %lu:\n", prev_stage(prev_stage(final)));
        print_stage(&points, prev_stage(prev_stage(final)));
        iprintf("\nStage %lu:\n", prev_stage(final));
        print_stage(&points, prev_stage(final));
        iprintf("\nStage %lu:\n", final);
        print_stage(&points, final);
    }

    qt_feb_barrier_destroy(points.barrier);
    qtimer_destroy(alloc_timer);
    qtimer_destroy(init_timer);
    qtimer_destroy(exec_timer);

    // Free allocated memory
    for (int i = 0; i < points.N; i++) {
        free(points.stage[0][i]);
        free(points.stage[1][i]);
        free(points.stage[2][i]);
    }
    free(points.stage[0]);
    free(points.stage[1]);
    free(points.stage[2]);

    return 0;
}