int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE disp, ompi_datatype_t *etype, ompi_datatype_t *filetype, char *datarep, ompi_info_t *info) { size_t max_data = 0; MPI_Aint lb,ub; fh->f_iov_count = 0; fh->f_disp = disp; fh->f_offset = disp; fh->f_total_bytes = 0; ompi_io_ompio_decode_datatype (fh, filetype, 1, NULL, &max_data, &fh->f_decoded_iov, &fh->f_iov_count); opal_datatype_get_extent(&filetype->super, &lb, &fh->f_view_extent); opal_datatype_type_ub (&filetype->super, &ub); opal_datatype_type_size (&etype->super, &fh->f_etype_size); opal_datatype_type_size (&filetype->super, &fh->f_view_size); ompi_datatype_duplicate (etype, &fh->f_etype); ompi_datatype_duplicate (filetype, &fh->f_filetype); fh->f_cc_size = get_contiguous_chunk_size (fh); if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) { if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1) && fh->f_view_extent == (OPAL_PTRDIFF_TYPE)fh->f_view_size ) { fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW; } } return OMPI_SUCCESS; }
int mpich_typeub3( void ) { int blocklen[3], err = 0, idisp[3]; size_t sz; OPAL_PTRDIFF_TYPE disp[3], lb, ub, ex; opal_datatype_t *types[3], *dt1, *dt2, *dt3, *dt4, *dt5; /* Create a datatype with explicit LB and UB */ blocklen[0] = 1; blocklen[1] = 1; blocklen[2] = 1; disp[0] = -3; disp[1] = 0; disp[2] = 6; types[0] = (opal_datatype_t*)&opal_datatype_lb; types[1] = (opal_datatype_t*)&opal_datatype_int4; types[2] = (opal_datatype_t*)&opal_datatype_ub; /* Generate samples for contiguous, hindexed, hvector, indexed, and vector (struct and contiguous tested in typeub2) */ opal_datatype_create_struct(3, blocklen, disp, types, &dt1); opal_datatype_commit( dt1 ); /* This type is the same as in typeub2, and is tested there */ types[0]=dt1; types[1]=dt1; blocklen[0]=1; blocklen[1]=1; disp[0]=-4; disp[1]=7; idisp[0]=-4; idisp[1]=7; opal_datatype_create_hindexed( 2, blocklen, disp, dt1, &dt2 ); opal_datatype_commit( dt2 ); opal_datatype_type_lb( dt2, &lb ); opal_datatype_type_ub( dt2, &ub ); opal_datatype_type_extent( dt2, &ex ); opal_datatype_type_size( dt2, &sz ); if (lb != -7 || ub != 13 || ex != 20) { printf("hindexed lb %d ub %d extent %d size %d\n", (int)-7, (int)13, (int)20, (int)sz); printf("hindexed lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex, (int)sz); err++; } else printf( "hindexed ok\n" ); opal_datatype_create_indexed( 2, blocklen, idisp, dt1, &dt3 ); opal_datatype_commit( dt3 ); opal_datatype_type_lb( dt3, &lb ); opal_datatype_type_ub( dt3, &ub ); opal_datatype_type_extent( dt3, &ex ); opal_datatype_type_size( dt3, &sz ); if (lb != -39 || ub != 69 || ex != 108) { printf("indexed lb %d ub %d extent %d size %d\n", (int)-39, (int)69, (int)108, (int)sz); printf("indexed lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex, (int)sz); err++; } else printf( "indexed ok\n" ); opal_datatype_create_hvector( 2, 1, 14, dt1, &dt4 ); opal_datatype_commit( dt4 ); opal_datatype_type_lb( dt4, &lb ); opal_datatype_type_ub( dt4, &ub ); opal_datatype_type_extent( dt4, &ex ); opal_datatype_type_size( dt4, &sz ); if (lb != -3 || ub != 20 || ex != 23) { printf("hvector lb %d ub %d extent %d size %d\n", (int)-3, (int)20, (int)23, (int)sz); printf("hvector lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex, (int)sz); err++; } else printf( "hvector ok\n" ); opal_datatype_create_vector( 2, 1, 14, dt1, &dt5 ); opal_datatype_commit( dt5 ); opal_datatype_type_lb( dt5, &lb ); opal_datatype_type_ub( dt5, &ub ); opal_datatype_type_extent( dt5, &ex ); opal_datatype_type_size( dt5, &sz ); if (lb != -3 || ub != 132 || ex != 135) { printf("vector lb %d ub %d extent %d size %d\n", (int)-3, (int)132, (int)135, (int)sz); printf("vector lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex, (int)sz); err++; } else printf( "vector ok\n" ); OBJ_RELEASE( dt1 ); /*assert( dt1 == NULL );*/ OBJ_RELEASE( dt2 ); /*assert( dt2 == NULL );*/ OBJ_RELEASE( dt3 ); /*assert( dt3 == NULL );*/ OBJ_RELEASE( dt4 ); /*assert( dt4 == NULL );*/ OBJ_RELEASE( dt5 ); assert( dt5 == NULL ); return err; }
int mpich_typeub2( void ) { int blocklen[3], err = 0; size_t sz1, sz2, sz3; OPAL_PTRDIFF_TYPE disp[3], lb, ub, ex1, ex2, ex3; opal_datatype_t *types[3], *dt1, *dt2, *dt3; blocklen[0] = 1; blocklen[1] = 1; blocklen[2] = 1; disp[0] = -3; disp[1] = 0; disp[2] = 6; types[0] = (opal_datatype_t*)&opal_datatype_lb; types[1] = (opal_datatype_t*)&opal_datatype_int4; types[2] = (opal_datatype_t*)&opal_datatype_ub; opal_datatype_create_struct(3, blocklen, disp, types, &dt1); opal_datatype_commit( dt1 ); opal_datatype_type_lb(dt1, &lb); opal_datatype_type_ub(dt1, &ub); opal_datatype_type_extent(dt1,&ex1); opal_datatype_type_size(dt1,&sz1); /* Values should be lb = -3, ub = 6 extent 9; size depends on implementation */ if (lb != -3 || ub != 6 || ex1 != 9) { printf("Example 3.26 type1 lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex1, (int)sz1); err++; } else printf("Example 3.26 type1 correct\n" ); opal_datatype_create_contiguous(2, dt1, &dt2); opal_datatype_type_lb(dt2, &lb); opal_datatype_type_ub(dt2, &ub); opal_datatype_type_extent(dt2,&ex2); opal_datatype_type_size(dt2,&sz2); /* Values should be lb = -3, ub = 15, extent = 18, size depends on implementation */ if (lb != -3 || ub != 15 || ex2 != 18) { printf("Example 3.26 type2 lb %d ub %d extent %d size %d\n", (int)-3, (int)15, (int)18, 8); printf("Example 3.26 type2 lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex2, (int)sz2); err++; } else printf("Example 3.26 type1 correct\n" ); OBJ_RELEASE( dt2 ); assert( dt2 == NULL ); opal_datatype_create_contiguous(2,dt1,&dt2); opal_datatype_type_lb(dt2, &lb); opal_datatype_type_ub(dt2, &ub); opal_datatype_type_extent(dt2,&ex2); opal_datatype_type_size(dt2,&sz2); /* Values should be lb = -3, ub = 15, extent = 18, size depends on implementation */ if (lb != -3 || ub != 15 || ex2 != 18) { printf("Example 3.26 type2 lb %d ub %d extent %d size %d\n", (int)-3, (int)15, (int)18, 8); printf("Example 3.26 type2 lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex2, (int)sz2); err++; } else printf( "Example 3.26 type2 correct\n" ); types[0]=dt1; types[1]=dt1; blocklen[0]=1; blocklen[1]=1; disp[0]=0; disp[1]=ex1; opal_datatype_create_struct(2, blocklen, disp, types, &dt3); opal_datatype_commit( dt3 ); opal_datatype_type_lb(dt3, &lb); opal_datatype_type_ub(dt3, &ub); opal_datatype_type_extent(dt3,&ex3); opal_datatype_type_size(dt3,&sz3); /* Another way to express type2 */ if (lb != -3 || ub != 15 || ex3 != 18) { printf("type3 lb %d ub %d extent %d size %d\n", (int)-3, (int)15, (int)18, 8); printf("type3 lb %d ub %d extent %d size %d\n", (int)lb, (int)ub, (int)ex3, (int)sz2); err++; } else printf( "type3 correct\n" ); OBJ_RELEASE( dt1 ); /*assert( dt1 == NULL );*/ OBJ_RELEASE( dt2 ); /*assert( dt2 == NULL );*/ OBJ_RELEASE( dt3 ); assert( dt3 == NULL ); return err; }
int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE disp, ompi_datatype_t *etype, ompi_datatype_t *filetype, char *datarep, ompi_info_t *info) { size_t max_data = 0; int i; int num_groups = 0; contg *contg_groups; size_t ftype_size; OPAL_PTRDIFF_TYPE ftype_extent, lb, ub; ompi_datatype_t *newfiletype; if ( NULL != fh->f_etype ) { ompi_datatype_destroy (&fh->f_etype); } if ( NULL != fh->f_filetype ) { ompi_datatype_destroy (&fh->f_filetype); } if ( NULL != fh->f_orig_filetype ) { ompi_datatype_destroy (&fh->f_orig_filetype); } if (NULL != fh->f_decoded_iov) { free (fh->f_decoded_iov); fh->f_decoded_iov = NULL; } if (NULL != fh->f_datarep) { free (fh->f_datarep); fh->f_datarep = NULL; } /* Reset the flags first */ fh->f_flags = 0; fh->f_flags |= OMPIO_FILE_VIEW_IS_SET; fh->f_datarep = strdup (datarep); ompi_datatype_duplicate (filetype, &fh->f_orig_filetype ); opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent); opal_datatype_type_size (&filetype->super, &ftype_size); if ( etype == filetype && ompi_datatype_is_predefined (filetype ) && ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){ ompi_datatype_create_contiguous(MCA_IO_DEFAULT_FILE_VIEW_SIZE, &ompi_mpi_byte.dt, &newfiletype); ompi_datatype_commit (&newfiletype); } else { newfiletype = filetype; } fh->f_iov_count = 0; fh->f_disp = disp; fh->f_offset = disp; fh->f_total_bytes = 0; ompi_io_ompio_decode_datatype (fh, newfiletype, 1, NULL, &max_data, &fh->f_decoded_iov, &fh->f_iov_count); opal_datatype_get_extent(&newfiletype->super, &lb, &fh->f_view_extent); opal_datatype_type_ub (&newfiletype->super, &ub); opal_datatype_type_size (&etype->super, &fh->f_etype_size); opal_datatype_type_size (&newfiletype->super, &fh->f_view_size); ompi_datatype_duplicate (etype, &fh->f_etype); ompi_datatype_duplicate (newfiletype, &fh->f_filetype); fh->f_cc_size = get_contiguous_chunk_size (fh); if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) { if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1) && fh->f_view_extent == (OPAL_PTRDIFF_TYPE)fh->f_view_size ) { fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW; } } contg_groups = (contg*) calloc ( 1, fh->f_size * sizeof(contg)); if (NULL == contg_groups) { opal_output (1, "OUT OF MEMORY\n"); return OMPI_ERR_OUT_OF_RESOURCE; } for( i = 0; i < fh->f_size; i++){ contg_groups[i].procs_in_contg_group = (int*)calloc (1,fh->f_size * sizeof(int)); if(NULL == contg_groups[i].procs_in_contg_group){ int j; opal_output (1, "OUT OF MEMORY\n"); for(j=0; j<i; j++) { free(contg_groups[j].procs_in_contg_group); } free(contg_groups); return OMPI_ERR_OUT_OF_RESOURCE; } } if( OMPI_SUCCESS != mca_io_ompio_fview_based_grouping(fh, &num_groups, contg_groups)){ opal_output(1, "mca_io_ompio_fview_based_grouping() failed\n"); free(contg_groups); return OMPI_ERROR; } if( !( (fh->f_comm->c_flags & OMPI_COMM_CART) && (num_groups == 1 || num_groups == fh->f_size)) ) { mca_io_ompio_finalize_initial_grouping(fh, num_groups, contg_groups); } for( i = 0; i < fh->f_size; i++){ free(contg_groups[i].procs_in_contg_group); } free(contg_groups); if ( etype == filetype && ompi_datatype_is_predefined (filetype ) && ftype_extent == (OPAL_PTRDIFF_TYPE)ftype_size ){ ompi_datatype_destroy ( &newfiletype ); } if (OMPI_SUCCESS != mca_fcoll_base_file_select (fh, NULL)) { opal_output(1, "mca_fcoll_base_file_select() failed\n"); return OMPI_ERROR; } return OMPI_SUCCESS; }
int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE disp, ompi_datatype_t *etype, ompi_datatype_t *filetype, char *datarep, ompi_info_t *info) { size_t max_data = 0; int i; int num_groups = 0; contg *contg_groups; MPI_Aint lb,ub; fh->f_iov_count = 0; fh->f_disp = disp; fh->f_offset = disp; fh->f_total_bytes = 0; ompi_io_ompio_decode_datatype (fh, filetype, 1, NULL, &max_data, &fh->f_decoded_iov, &fh->f_iov_count); opal_datatype_get_extent(&filetype->super, &lb, &fh->f_view_extent); opal_datatype_type_ub (&filetype->super, &ub); opal_datatype_type_size (&etype->super, &fh->f_etype_size); opal_datatype_type_size (&filetype->super, &fh->f_view_size); ompi_datatype_duplicate (etype, &fh->f_etype); ompi_datatype_duplicate (filetype, &fh->f_filetype); fh->f_cc_size = get_contiguous_chunk_size (fh); if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) { if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1) && fh->f_view_extent == (OPAL_PTRDIFF_TYPE)fh->f_view_size ) { fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW; } } contg_groups = (contg*) calloc ( 1, fh->f_size * sizeof(contg)); if (NULL == contg_groups) { opal_output (1, "OUT OF MEMORY\n"); return OMPI_ERR_OUT_OF_RESOURCE; } for( i = 0; i < fh->f_size; i++) { contg_groups[i].procs_in_contg_group = (int*)calloc (1,fh->f_size * sizeof(int)); if(NULL == contg_groups[i].procs_in_contg_group) { int j; opal_output (1, "OUT OF MEMORY\n"); for(j=0; j<i; j++) { free(contg_groups[j].procs_in_contg_group); } free(contg_groups); return OMPI_ERR_OUT_OF_RESOURCE; } } if( OMPI_SUCCESS != mca_io_ompio_fview_based_grouping(fh, &num_groups, contg_groups)) { opal_output(1, "mca_io_ompio_fview_based_grouping() failed\n"); free(contg_groups); return OMPI_ERROR; } if( !( (fh->f_comm->c_flags & OMPI_COMM_CART) && (num_groups == 1 || num_groups == fh->f_size)) ) { mca_io_ompio_finalize_initial_grouping(fh, num_groups, contg_groups); } for( i = 0; i < fh->f_size; i++) { free(contg_groups[i].procs_in_contg_group); } free(contg_groups); return OMPI_SUCCESS; }