⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ad_pvfs2_read.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 3 页
字号:
    } /* else [file_ptr_type != ADIO_INDIVIDUAL] */    start_off = offset;    st_frd_size = frd_size;    st_n_filetypes = n_filetypes;        if (buftype_is_contig && !filetype_is_contig) {/* contiguous in memory, noncontiguous in file. should be the most   common case. */        int mem_lengths;	char *mem_offsets;		i = 0;	j = st_index;	n_filetypes = st_n_filetypes;		mem_list_count = 1;		/* determine how many blocks in file to read */	f_data_read = ADIOI_MIN(st_frd_size, bufsize);	total_blks_to_read = 1;	if (j < (flat_file->count-1)) j++;	else {	    j = 0;	    n_filetypes++;	}	while (f_data_read < bufsize) {	    f_data_read += flat_file->blocklens[j];	    total_blks_to_read++;	    if (j<(flat_file->count-1)) j++;	    else j = 0;		}      	j = st_index;	n_filetypes = st_n_filetypes;	n_read_lists = total_blks_to_read/MAX_ARRAY_SIZE;	extra_blks = total_blks_to_read%MAX_ARRAY_SIZE;		mem_offsets = buf;	mem_lengths = 0;		/* if at least one full readlist, allocate file arrays	   at max array size and don't free until very end */	if (n_read_lists) {	    file_offsets = (int64_t*)ADIOI_Malloc(MAX_ARRAY_SIZE*						  sizeof(int64_t));	    file_lengths = (int32_t*)ADIOI_Malloc(MAX_ARRAY_SIZE*						  sizeof(int32_t));	}	/* if there's no full readlist allocate file arrays according	   to needed size (extra_blks) */	else {	    file_offsets = (int64_t*)ADIOI_Malloc(extra_blks*						  sizeof(int64_t));	    file_lengths = (int32_t*)ADIOI_Malloc(extra_blks*						  sizeof(int32_t));	}		/* for file arrays that are of MAX_ARRAY_SIZE, build arrays */	for (i=0; i<n_read_lists; i++) {	    file_list_count = MAX_ARRAY_SIZE;	    if(!i) {	        file_offsets[0] = offset;		file_lengths[0] = st_frd_size;		mem_lengths = st_frd_size;	    }	    for (k=0; k<MAX_ARRAY_SIZE; k++) {	        if (i || k) {		    file_offsets[k] = disp + 			((ADIO_Offset)n_filetypes)*filetype_extent		      + flat_file->indices[j];		    file_lengths[k] = flat_file->blocklens[j];		    mem_lengths += file_lengths[k];		}		if (j<(flat_file->count - 1)) j++;		else {		    j = 0;		    n_filetypes++;		}	    } /* for (k=0; k<MAX_ARRAY_SIZE; k++) */	    err_flag = PVFS_Request_contiguous(mem_lengths, 					       PVFS_BYTE, &mem_req);	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_Request_contiguous (memory)", 0);		goto error_state;	    }	    /* --END ERROR HANDLING-- */	    err_flag = PVFS_Request_hindexed(file_list_count, file_lengths, 					     file_offsets, PVFS_BYTE,					     &file_req);	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_Request_hindexed (file)", 0);		goto error_state;	    }	    /* --END ERROR HANDLING-- */	    /* PVFS_Request_hindexed already expresses the offsets into the	     * file, so we should not pass in an offset if we are using	     * hindexed for the file type */#ifdef ADIOI_MPE_LOGGING            MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );#endif	    err_flag = PVFS_sys_read(pvfs_fs->object_ref, file_req, 0, 				     mem_offsets, mem_req,				     &(pvfs_fs->credentials), &resp_io);#ifdef ADIOI_MPE_LOGGING            MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );#endif	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_sys_read", 0);		goto error_state;	    }	    /* --END ERROR HANDING-- */	    PVFS_Request_free(&mem_req);	    PVFS_Request_free(&file_req);	    total_bytes_read += resp_io.total_completed;	    mem_offsets += mem_lengths;	    mem_lengths = 0;	} /* for (i=0; i<n_read_lists; i++) */	/* for file arrays smaller than MAX_ARRAY_SIZE (last read_list call) */	if (extra_blks) {	    file_list_count = extra_blks;	    if(!i) {	        file_offsets[0] = offset;		file_lengths[0] = st_frd_size;	    }	    for (k=0; k<extra_blks; k++) {	        if(i || k) {		    file_offsets[k] = disp + 			((ADIO_Offset)n_filetypes)*filetype_extent +			flat_file->indices[j];		    if (k == (extra_blks - 1)) {		        file_lengths[k] = bufsize - (int32_t) mem_lengths			  - (int32_t) mem_offsets + (int32_t)  buf;		    }		    else file_lengths[k] = flat_file->blocklens[j];		} /* if(i || k) */		mem_lengths += file_lengths[k];		if (j<(flat_file->count - 1)) j++;		else {		    j = 0;		    n_filetypes++;		}	    } /* for (k=0; k<extra_blks; k++) */	    err_flag = PVFS_Request_contiguous(mem_lengths,					       PVFS_BYTE, &mem_req);	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_Request_contiguous (memory)", 0);		goto error_state;	    }	    /* --END ERROR HANDLING-- */	    err_flag = PVFS_Request_hindexed(file_list_count, file_lengths, 		    file_offsets, PVFS_BYTE, &file_req);	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_Request_hindexed (file)", 0);		goto error_state;	    }	    /* --END ERROR HANDLING-- */	    /* as above, use 0 for 'offset' when using hindexed file type */#ifdef ADIOI_MPE_LOGGING            MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );#endif	    err_flag = PVFS_sys_read(pvfs_fs->object_ref, file_req, 0, 		    mem_offsets, mem_req, &(pvfs_fs->credentials), &resp_io);#ifdef ADIOI_MPE_LOGGING            MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );#endif	    /* --BEGIN ERROR HANDLING-- */	    if (err_flag != 0) {		*error_code = MPIO_Err_create_code(MPI_SUCCESS,						   MPIR_ERR_RECOVERABLE,						   myname, __LINE__,						   ADIOI_PVFS2_error_convert(err_flag),						   "Error in PVFS_sys_read", 0);				goto error_state;	    }	    /* --END ERROR HANDLING-- */	    PVFS_Request_free(&mem_req);	    PVFS_Request_free(&file_req);	    total_bytes_read += resp_io.total_completed;	}    }    else {/* noncontiguous in memory as well as in file */              ADIOI_Flatten_datatype(datatype);	flat_buf = ADIOI_Flatlist;	while (flat_buf->type != datatype) flat_buf = flat_buf->next;	size_read = 0;	n_filetypes = st_n_filetypes;	frd_size = st_frd_size;	brd_size = flat_buf->blocklens[0];	buf_count = 0;	start_mem_offset = 0;	start_k = k = 0;	start_j = st_index;	max_mem_list = 0;	max_file_list = 0;	/* run through and file max_file_list and max_mem_list so that you 	   can allocate the file and memory arrays less than MAX_ARRAY_SIZE	   if possible */	while (size_read < bufsize) {	    k = start_k;	    new_buffer_read = 0;	    mem_list_count = 0;	    while ((mem_list_count < MAX_ARRAY_SIZE) && 		   (new_buffer_read < bufsize-size_read)) {	        /* find mem_list_count and file_list_count such that both are		   less than MAX_ARRAY_SIZE, the sum of their lengths are		   equal, and the sum of all the data read and data to be		   read in the next immediate read list is less than		   bufsize */	        if(mem_list_count) {		    if((new_buffer_read + flat_buf->blocklens[k] + 			size_read) > bufsize) {		        end_brd_size = new_buffer_read + 			    flat_buf->blocklens[k] - (bufsize - size_read);			new_buffer_read = bufsize - size_read;		    }		    else {		        new_buffer_read += flat_buf->blocklens[k];			end_brd_size = flat_buf->blocklens[k];		    }		}		else {		    if (brd_size > (bufsize - size_read)) {		        new_buffer_read = bufsize - size_read;			brd_size = new_buffer_read;		    }		    else new_buffer_read = brd_size;		}		mem_list_count++;		k = (k + 1)%flat_buf->count;	     } /* while ((mem_list_count < MAX_ARRAY_SIZE) && 	       (new_buffer_read < bufsize-size_read)) */	    j = start_j;	    new_file_read = 0;	    file_list_count = 0;	    while ((file_list_count < MAX_ARRAY_SIZE) && 		   (new_file_read < new_buffer_read)) {	        if(file_list_count) {		    if((new_file_read + flat_file->blocklens[j]) > 		       new_buffer_read) {		        end_frd_size = new_buffer_read - new_file_read;			new_file_read = new_buffer_read;			j--;		    }		    else {		        new_file_read += flat_file->blocklens[j];			end_frd_size = flat_file->blocklens[j];		    }		}		else {		    if (frd_size > new_buffer_read) {		        new_file_read = new_buffer_read;			frd_size = new_file_read;		    }		    else new_file_read = frd_size;		}		file_list_count++;		if (j < (flat_file->count - 1)) j++;		else j = 0;				k = start_k;		if ((new_file_read < new_buffer_read) && 		    (file_list_count == MAX_ARRAY_SIZE)) {		    new_buffer_read = 0;		    mem_list_count = 0;		    while (new_buffer_read < new_file_read) {		        if(mem_list_count) {			    if((new_buffer_read + flat_buf->blocklens[k]) >			       new_file_read) {			        end_brd_size = new_file_read - new_buffer_read;				new_buffer_read = new_file_read;				k--;			    }			    else {			        new_buffer_read += flat_buf->blocklens[k];				end_brd_size = flat_buf->blocklens[k];			    }			}			else {			    new_buffer_read = brd_size;			    if (brd_size > (bufsize - size_read)) {			        new_buffer_read = bufsize - size_read;				brd_size = new_buffer_read;			    }			}			mem_list_count++;			k = (k + 1)%flat_buf->count;		    } /* while (new_buffer_read < new_file_read) */		} /* if ((new_file_read < new_buffer_read) && (file_list_count		     == MAX_ARRAY_SIZE)) */	    } /* while ((mem_list_count < MAX_ARRAY_SIZE) && 		 (new_buffer_read < bufsize-size_read)) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -