Example #1
0
void server() {
    int64_t chunksize = buffersize / (bb.nmemb * dtype_itemsize(bb.dtype));
    int64_t offset;
    int64_t work[2];
    for(offset = 0; offset < bb.size; ) {
        MPI_Status status;
        int result = 0;
        MPI_Recv(&result, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
                &status);
        if(status.MPI_TAG == ERROR_TAG) {
            break;
        }

        /* never read beyond my end (read_simple caps at EOF) */
        if(offset + chunksize > bb.size) {
            chunksize = bb.size - offset;
        }
        work[0] = offset;
        work[1] = chunksize;
        MPI_Send(work, 1, MPI_TYPE_WORK, status.MPI_SOURCE, WORK_TAG, MPI_COMM_WORLD);

        offset += chunksize;
        if(verbose) {
            fprintf(stderr, "%td / %td done (%0.4g%%)\r", offset, bb.size, (100. / bb.size) * offset);
        }
    }
    int i;
    for(i = 1; i < NTask; i ++) {
        int64_t work[2];
        MPI_Send(work, 1, MPI_TYPE_WORK, i, DIE_TAG, MPI_COMM_WORLD);
    }

}
Example #2
0
int main(int argc, char * argv[]) {
    int opt;
    while(-1 != (opt = getopt(argc, argv, "t:n:N:"))) {
        switch(opt){
            case 'N':
                Nfile = atoi(optarg);
                break;
            case 't':
                dtype = optarg;
                break;
            case 'n':
                nmemb = atoi(optarg);
                break;
            default:
                usage();
        }
    }
    if(argc - optind < 3) {
        usage();
    }
    argv += optind - 1;
    BigFile bf = {0};
    BigBlock bb = {0};
    if(0 != big_file_create(&bf, argv[1])) {
        fprintf(stderr, "failed to create file : %s\n", big_file_get_error_message());
        return -1;
    }
    int Nfile;
    int Ninput = argc - optind - 2;
    size_t size[Nfile];
    size_t total = 0;
    int i;
    for(i = 0; i < Ninput; i ++) {
        struct stat st;
        stat(argv[i + 3], &st);
        total += st.st_size / dtype_itemsize(dtype) / nmemb;
    }
    for(i = 0; i < Nfile; i ++) {

    }
    
    if(0 != big_file_create_block(&bf, &bb, argv[2], dtype, nmemb, Nfile, fsize)) {
        fprintf(stderr, "failed to create block: %s\n", big_file_get_error_message());
        return -1;
    }
    for(i = 0; i < Nfile; i ++) {
        FILE * fp = fopen
    }
    big_file_close(&bf);
    return 0;
}
Example #3
0
static void print_attr(BigAttr * attr, int brief) {
    char buffer[128];
    char * data = attr->data;
    int i;
    if(!brief || longfmt) {
        printf("%-20s %s %3d  ", attr->name, attr->dtype, attr->nmemb);
        printf("[ ");
    }
    for(i = 0; i < attr->nmemb; i ++) {
        char * endl;
        if(i != attr->nmemb - 1 && attr->dtype[1] != 'S') {
            endl = " ";
        } else {
            endl = "";
        }
        dtype_format(buffer, attr->dtype, data, NULL);
        printf("%s%s", buffer, endl);
        data += dtype_itemsize(attr->dtype);
    }
    if(!brief || longfmt) {
        printf(" ]");
    }
    printf("\n");
}