Exemplo n.º 1
0
extern void fatalerror(char *s)
{   print_preamble();

    printf("Fatal error: %s\n",s);
    if (no_compiler_errors > 0) print_sorry_message();

#ifdef ARC_THROWBACK
    throwback(0, s);
    throwback_end();
#endif
#ifdef MAC_FACE
    close_all_source();
    if (temporary_files_switch) remove_temp_files();
    abort_transcript_file();
    free_arrays();
    if (store_the_text)
        my_free(&all_text,"transcription text");
    longjmp(g_fallback, 1);
#endif
    exit(1);
}
Exemplo n.º 2
0
int
main (int argc, char *argv[])
{
    int i, numprocs, rank, size;
    int skip;
    double latency = 0.0, t_start = 0.0, t_stop = 0.0;
    double timer=0.0;
    double avg_time = 0.0, max_time = 0.0, min_time = 0.0;
    char * sendbuf = NULL, * recvbuf = NULL;
    int po_ret;
    size_t bufsize;

    set_header(HEADER);
    set_benchmark_name("osu_gather");
    enable_accel_support();
    po_ret = process_options(argc, argv);

    if (po_okay == po_ret && none != options.accel) {
        if (init_accel()) {
            fprintf(stderr, "Error initializing device\n");
            exit(EXIT_FAILURE);
        }
    }

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);

    switch (po_ret) {
        case po_bad_usage:
            print_bad_usage_message(rank);
            MPI_Finalize();
            exit(EXIT_FAILURE);
        case po_help_message:
            print_help_message(rank);
            MPI_Finalize();
            exit(EXIT_SUCCESS);
        case po_version_message:
            print_version_message(rank);
            MPI_Finalize();
            exit(EXIT_SUCCESS);
        case po_okay:
            break;
    }

    if(numprocs < 2) {
        if (rank == 0) {
            fprintf(stderr, "This test requires at least two processes\n");
        }

        MPI_Finalize();
        exit(EXIT_FAILURE);
    }

    if ((options.max_message_size * numprocs) > options.max_mem_limit) {
        options.max_message_size = options.max_mem_limit / numprocs;
    }

    if (0 == rank) {
        bufsize = options.max_message_size * numprocs;
        if (allocate_buffer((void**)&recvbuf, bufsize, options.accel)) {
            fprintf(stderr, "Could Not Allocate Memory [rank %d]\n", rank);
            MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
        }
        set_buffer(recvbuf, options.accel, 1, bufsize);
    }

    if (allocate_buffer((void**)&sendbuf, options.max_message_size,
                options.accel)) {
        fprintf(stderr, "Could Not Allocate Memory [rank %d]\n", rank);
        MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
    }
    set_buffer(sendbuf, options.accel, 0, options.max_message_size);

    print_preamble(rank);

    for (size=1; size <= options.max_message_size; size *= 2) {
        if (size > LARGE_MESSAGE_SIZE) {
            skip = SKIP_LARGE;
            options.iterations = options.iterations_large;
        } else {
            skip = SKIP;
        }

        MPI_Barrier(MPI_COMM_WORLD);
        timer=0.0;

        for (i=0; i < options.iterations + skip ; i++) {
            t_start = MPI_Wtime();
            MPI_Gather(sendbuf, size, MPI_CHAR, recvbuf, size, MPI_CHAR, 0,
                    MPI_COMM_WORLD);
            t_stop = MPI_Wtime();

            if (i >= skip) {
                timer+=t_stop-t_start;
            }
            MPI_Barrier(MPI_COMM_WORLD);
        }
        latency = (double)(timer * 1e6) / options.iterations;

        MPI_Reduce(&latency, &min_time, 1, MPI_DOUBLE, MPI_MIN, 0,
                MPI_COMM_WORLD);
        MPI_Reduce(&latency, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0,
                MPI_COMM_WORLD);
        MPI_Reduce(&latency, &avg_time, 1, MPI_DOUBLE, MPI_SUM, 0,
                MPI_COMM_WORLD);
        avg_time = avg_time/numprocs;

        print_stats(rank, size, avg_time, min_time, max_time);
        MPI_Barrier(MPI_COMM_WORLD);
    }

    if (0 == rank) {
        free_buffer(recvbuf, options.accel);
    }
    free_buffer(sendbuf, options.accel);

    MPI_Finalize();

    if (none != options.accel) {
        if (cleanup_accel()) {
            fprintf(stderr, "Error cleaning up device\n");
            exit(EXIT_FAILURE);
        }
    }

    return EXIT_SUCCESS;
}
Exemplo n.º 3
0
static void Write(FILE *fp, Gdinfo *ginfo) {
    register int  i,j,k;
    const    int nel = ginfo->nel;
    double   *x = ginfo->x;
    double   *y = ginfo->y;

    print_preamble(fp);

    /* write mesh */
    fprintf(fp,
            "**MESH DATA** 1st line is X of corner 1,2,3,4. 2nd line is Y.\n");
    fprintf(fp,"\t %d \t %d \t %d \t NEL,NDIM,NELV\n",nel,2,nel);

    for(i = 0; i < nel; ++i) {
        fprintf(fp,"\tELEMENT    %d   [  1A]    GROUP     0\n",i+1);
        for(j = 0; j < 3; ++j)
            fprintf(fp,"  %12.6lf",x[ginfo->elmtpts[i][j]-1]);
        fprintf(fp,"  %12.6lf\n",x[ginfo->elmtpts[i][0]-1]);
        for(j = 0; j < 3; ++j)
            fprintf(fp,"  %12.6lf",y[ginfo->elmtpts[i][j]-1]);
        fprintf(fp,"  %12.6lf\n",y[ginfo->elmtpts[i][0]-1]);
    }

    fprintf(fp," ***** CURVED SIDE DATA ***** \n");
    if(ginfo->clist) {
        int      n;
        Curlist *cl;
        Curinfo *c;

        /* count to see how many types */
        for(n=0,c = ginfo->curve; c; c = c->next) ++n;

        fprintf(fp,"%d\tNumber of curve types \n",n);

        for(c = ginfo->curve; c; c = c->next)
            switch(c->type) {
            case 'C':
                fprintf(fp,"Circle\n");
                fprintf(fp,"%lf  %lf  %lf  %c     xc yc rad tagid\n",c->info.arc.xc,
                        c->info.arc.yc,c->info.arc.radius,c->type);
                break;
            case 'S':
                fprintf(fp,"Straight sided\n");
                fprintf(fp,"%c\ttagid\n",c->idtype);
                break;
            case 'F':
                fprintf(fp,"File\n");
                fprintf(fp,"%s %c\n",c->info.file.name,c->idtype);
                break;
            default:
                fprintf(stderr,"unknown curve type %c\n",c->idtype);
            }

        for(n=0,cl = ginfo->clist; cl; cl = cl->next) ++n;
        fprintf(fp,"%d\tnumber of curved sides, (iside, iel, tagid) \n",n);
        for(cl=ginfo->clist,n=0; cl; cl = cl->next,++n) {
            fprintf(fp,"%d  %d  %c  \t",cl->iside+1,cl->eid,cl->type);
            if((n+1)%4 == 0) fprintf(fp,"\n");
        }
        if(!(n%4 == 0))fprintf(fp,"\n");
    }
    else
        fprintf(fp," 0 Curved sides follow IEDGE,IEL,CURVE(I),I=1,5, CCURVE \n");

    /* write fluid boundary conditions */
    fprintf(fp," ***** BOUNDARY CONDITIONS *****\n");
    fprintf(fp," ***** FLUID BOUNDARY CONDITIONS *****\n");
    for(i = 0; i < nel; ++i) {
        for(j = 0; j < 3; ++j) {
            switch(ginfo->elmtcon[i][j].type) {
            case 'E':
                fprintf(fp,"E  %d  %d  %12.6lf  %12.6lf      0.000000 \n",i+1,j+1,
                        (double) ginfo->elmtcon[i][j].elmtid,
                        (double) ginfo->elmtcon[i][j].vsid+1);
                break;
            case 'W':
            case 'O':
            case 'S':
            case 'B':
            case 'M':
            case 'I':
            case 'Z':
                fprintf(fp,"%c  %d  %d      0.000000      0.000000      0.000000 \n",
                        ginfo->elmtcon[i][j].type,i+1,j+1);
                break;
            case 'V':
            case 'F':
                fprintf(fp,"%c  %d  %d      %12.6lf      %12.6lf      %12.6lf \n",
                        ginfo->elmtcon[i][j].type,i+1,j+1,ginfo->elmtcon[i][j].f[0],
                        ginfo->elmtcon[i][j].f[1],ginfo->elmtcon[i][j].f[2]);
                break;
            case 'v':
            case 'f':
            case 'm':
                fprintf(fp,"%c  %d  %d      0.000000      0.000000      0.000000 \n",
                        ginfo->elmtcon[i][j].type,i+1,j+1);
                k = 0;
                while(ginfo->elmtcon[i][j].str[k])
                    fprintf(fp,"\t%s",ginfo->elmtcon[i][j].str[k++]);
                break;
            default:
                fprintf(stderr,"Unknown boundary type %c in Write\n",
                        ginfo->elmtcon[i][j].type);
                fprintf(fp,"W  %d  %d      0.000000      0.000000      0.000000 \n",
                        i+1,j+1);
            }
        }
        fprintf(fp, "not used\n");
    }
    print_postamble(fp);
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    int i, j, numprocs, rank, size;
    double latency = 0.0, t_start = 0.0, t_stop = 0.0;
    double timer=0.0;
    double avg_time = 0.0, max_time = 0.0, min_time = 0.0;
    float *sendbuf, *recvbuf;
    int po_ret;
    size_t bufsize;

    int64_t* problems = all_reduce_kernels_size;
    int64_t* numRepeats = all_reduce_kernels_repeat;

    set_header(HEADER);
#ifdef ENABLE_MLSL
    mlsl_comm_req request;
    set_benchmark_name("mlsl_osu_allreduce");
#else
    set_benchmark_name("osu_allreduce");
#endif
    enable_accel_support();
    po_ret = process_options(argc, argv);

    if (po_okay == po_ret && none != options.accel) {
        if (init_accel()) {
            fprintf(stderr, "Error initializing device\n");
            exit(EXIT_FAILURE);
        }
    }

#ifdef ENABLE_MLSL
    MLSL_CALL(mlsl_environment_get_env(&env));
    MLSL_CALL(mlsl_environment_init(env, &argc, &argv));
    size_t process_idx, process_count;
    MLSL_CALL(mlsl_environment_get_process_idx(env, &process_idx));
    MLSL_CALL(mlsl_environment_get_process_count(env, &process_count));
    rank = process_idx;
    numprocs = process_count;
    MLSL_CALL(mlsl_environment_create_distribution(env, process_count, 1, &distribution));
#else
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
#endif

    switch (po_ret) {
        case po_bad_usage:
            print_bad_usage_message(rank);
            FINALIZE();
            exit(EXIT_FAILURE);
        case po_help_message:
            print_help_message(rank);
            FINALIZE();
            exit(EXIT_SUCCESS);
        case po_version_message:
            print_version_message(rank);
            FINALIZE();
            exit(EXIT_SUCCESS);
        case po_okay:
            break;
    }

    if(numprocs < 2) {
        if (rank == 0) {
            fprintf(stderr, "This test requires at least two processes\n");
        }

        FINALIZE();
        exit(EXIT_FAILURE);
    }

    if (options.max_message_size > options.max_mem_limit) {
        options.max_message_size = options.max_mem_limit;
    }

    bufsize = sizeof(float)*(options.max_message_size/sizeof(float));
    if (allocate_buffer((void**)&sendbuf, bufsize, options.accel)) {
        fprintf(stderr, "Could Not Allocate Memory [rank %d]\n", rank);
        MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
    }
    set_buffer(sendbuf, options.accel, 1, bufsize);

    bufsize = sizeof(float)*(options.max_message_size/sizeof(float));
    if (allocate_buffer((void**)&recvbuf, bufsize, options.accel)) {
        fprintf(stderr, "Could Not Allocate Memory [rank %d]\n", rank);
        MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
    }
    set_buffer(recvbuf, options.accel, 0, bufsize);

    print_preamble(rank, numprocs);

    size = options.max_message_size/sizeof(float);

    for (j = 0; j < _NUMBER_OF_KERNELS_; j++)
    {
        size = problems[j];

        options.iterations = numRepeats[j];
        MPI_Barrier(MPI_COMM_WORLD);

        timer = 0.0;
        t_start = MPI_Wtime();
        for(i=0; i < options.iterations; i++) {
#ifdef ENABLE_MLSL
            MLSL_CALL(mlsl_distribution_all_reduce(distribution, sendbuf, recvbuf, size, DT_FLOAT, RT_SUM, GT_DATA, &request));
            MLSL_CALL(mlsl_environment_wait(env, request));
#else
            MPI_Allreduce(sendbuf, recvbuf, size, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
#endif
        }

        t_stop = MPI_Wtime();
        timer = t_stop-t_start;

        latency = (double)(timer * 1e3) / options.iterations;

        MPI_Reduce(&latency, &min_time, 1, MPI_DOUBLE, MPI_MIN, 0,
                MPI_COMM_WORLD);
        MPI_Reduce(&latency, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0,
                MPI_COMM_WORLD);
        MPI_Reduce(&latency, &avg_time, 1, MPI_DOUBLE, MPI_SUM, 0,
                MPI_COMM_WORLD);
        avg_time = avg_time/numprocs;

        print_stats(rank, size, avg_time, min_time, max_time);
        MPI_Barrier(MPI_COMM_WORLD);
    }

    free_buffer(sendbuf, options.accel);
    free_buffer(recvbuf, options.accel);

    FINALIZE();

    if (none != options.accel) {
        if (cleanup_accel()) {
            fprintf(stderr, "Error cleaning up device\n");
            exit(EXIT_FAILURE);
        }
    }

    return EXIT_SUCCESS;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    int i = 0, rank;
    int numprocs;
    double avg_time = 0.0, max_time = 0.0, min_time = 0.0;
    double latency = 0.0, t_start = 0.0, t_stop = 0.0;
    double timer=0.0;
    int po_ret;

    set_header(HEADER);
    set_benchmark_name("osu_barrier");
    enable_accel_support();
    po_ret = process_options(argc, argv);

    if (po_okay == po_ret && none != options.accel) {
        if (init_accel()) {
            fprintf(stderr, "Error initializing device\n");
            exit(EXIT_FAILURE);
        }
    }

    options.show_size = 0;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);

    switch (po_ret) {
        case po_bad_usage:
            print_bad_usage_message(rank);
            MPI_Finalize();
            exit(EXIT_FAILURE);
        case po_help_message:
            print_help_message(rank);
            MPI_Finalize();
            exit(EXIT_SUCCESS);
        case po_version_message:
            print_version_message(rank);
            MPI_Finalize();
            exit(EXIT_SUCCESS);
        case po_okay:
            break;
    }

    if(numprocs < 2) {
        if(rank == 0) {
            fprintf(stderr, "This test requires at least two processes\n");
        }

        MPI_Finalize();

        return EXIT_FAILURE;
    }

    print_preamble(rank);

    options.skip = options.skip_large;
    options.iterations = options.iterations_large;
    timer = 0.0;

    for(i=0; i < options.iterations + options.skip ; i++) {
        t_start = MPI_Wtime();
        MPI_Barrier(MPI_COMM_WORLD);
        t_stop = MPI_Wtime();

        if(i>=options.skip){
            timer+=t_stop-t_start;
        }
    }

    MPI_Barrier(MPI_COMM_WORLD);

    latency = (timer * 1e6) / options.iterations;

    MPI_Reduce(&latency, &min_time, 1, MPI_DOUBLE, MPI_MIN, 0,
                MPI_COMM_WORLD);
    MPI_Reduce(&latency, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0,
                MPI_COMM_WORLD);
    MPI_Reduce(&latency, &avg_time, 1, MPI_DOUBLE, MPI_SUM, 0,
                MPI_COMM_WORLD);
    avg_time = avg_time/numprocs;

    print_stats(rank, 0, avg_time, min_time, max_time);
    MPI_Finalize();

    return EXIT_SUCCESS;
}
Exemplo n.º 6
0
void ast_export_root(FILE* dest, struct ast_node_t* node) {
	print_preamble(dest);
	print_naked_list(dest, node, 0, 1);
	print_after(dest);
}