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

📄 ad_pvfs_read.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 2 页
字号:
	    pvfs_read_list(fd->fd_sys, mem_list_count, &mem_offsets,			   &mem_lengths, file_list_count, file_offsets,			   file_lengths);	}    }    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)) */	    /*  fakes filling the readlist arrays of lengths found above  */	    k = start_k;	    j = start_j;	    for (i=0; i<mem_list_count; i++) {	     		if(i) {		    if (i == (mem_list_count - 1)) {			if (flat_buf->blocklens[k] == end_brd_size)			    brd_size = flat_buf->blocklens[(k+1)%							  flat_buf->count];			else {			    brd_size = flat_buf->blocklens[k] - end_brd_size;			    k--;			    buf_count--;			}		    }		}		buf_count++;		k = (k + 1)%flat_buf->count;	    } /* for (i=0; i<mem_list_count; i++) */	    for (i=0; i<file_list_count; i++) {		if (i) {		    if (i == (file_list_count - 1)) {			if (flat_file->blocklens[j] == end_frd_size)			    frd_size = flat_file->blocklens[(j+1)%							  flat_file->count];   			else {			    frd_size = flat_file->blocklens[j] - end_frd_size;			    j--;			}		    }		}		if (j < flat_file->count - 1) j++;		else {		    j = 0;		    n_filetypes++;		}	    } /* for (i=0; i<file_list_count; i++) */	    size_read += new_buffer_read;	    start_k = k;	    start_j = j;	    if (max_mem_list < mem_list_count)	        max_mem_list = mem_list_count;	    if (max_file_list < file_list_count)	        max_file_list = file_list_count;	    if (max_mem_list == max_mem_list == MAX_ARRAY_SIZE)	        break;	} /* while (size_read < bufsize) */	mem_offsets = (char **)ADIOI_Malloc(max_mem_list*sizeof(char *));	mem_lengths = (int *)ADIOI_Malloc(max_mem_list*sizeof(int));	file_offsets = (int64_t *)ADIOI_Malloc(max_file_list*sizeof(int64_t));	file_lengths = (int32_t *)ADIOI_Malloc(max_file_list*sizeof(int32_t));	    	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;	/*  this section calculates mem_list_count and file_list_count	    and also finds the possibly odd sized last array elements	    in new_frd_size and new_brd_size  */		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)) */	    /*  fills the allocated readlist arrays  */	    k = start_k;	    j = start_j;	    for (i=0; i<mem_list_count; i++) {	     	        mem_offsets[i] = (char*)((char *)buf + buftype_extent*					 (buf_count/flat_buf->count) +					 (int)flat_buf->indices[k]);		if(!i) {		    mem_lengths[0] = brd_size;		    mem_offsets[0] += flat_buf->blocklens[k] - brd_size;		}		else {		    if (i == (mem_list_count - 1)) {		        mem_lengths[i] = end_brd_size;			if (flat_buf->blocklens[k] == end_brd_size)			    brd_size = flat_buf->blocklens[(k+1)%							  flat_buf->count];			else {			    brd_size = flat_buf->blocklens[k] - end_brd_size;			    k--;			    buf_count--;			}		    }		    else {		        mem_lengths[i] = flat_buf->blocklens[k];		    }		}		buf_count++;		k = (k + 1)%flat_buf->count;	    } /* for (i=0; i<mem_list_count; i++) */	    for (i=0; i<file_list_count; i++) {	        file_offsets[i] = disp + flat_file->indices[j] + n_filetypes *		    filetype_extent;	        if (!i) {		    file_lengths[0] = frd_size;		    file_offsets[0] += flat_file->blocklens[j] - frd_size;		}		else {		    if (i == (file_list_count - 1)) {		        file_lengths[i] = end_frd_size;			if (flat_file->blocklens[j] == end_frd_size)			    frd_size = flat_file->blocklens[(j+1)%							  flat_file->count];   			else {			    frd_size = flat_file->blocklens[j] - end_frd_size;			    j--;			}		    }		    else file_lengths[i] = flat_file->blocklens[j];		}		if (j < flat_file->count - 1) j++;		else {		    j = 0;		    n_filetypes++;		}	    } /* for (i=0; i<file_list_count; i++) */	    /* 	    printf("about to call read_list in noncontig/noncontig\n");	    printf("offsets and lengths in terms of integers\n");	    printf("\nmem_list_count = %d\n", mem_list_count);	    for (i=0; i<mem_list_count; i++) {	      printf("mem_offsets[%2d] = %2d   ", i, (int)(mem_offsets[i] - (int)buf)/4);	      printf("mem_lengths[%2d] = %2d\n", i, mem_lengths[i]/4);	    }	    printf("\nfile_list_count = %d\n", file_list_count);	    for (i=0; i<file_list_count; i++) {	      printf("file_offsets[%2d] = %2d   ", i, (int)file_offsets[i]/4);	      printf("file_lengths[%2d] = %2d\n", i, file_lengths[i]/4);	    }	    printf("\n\n");	    */	    pvfs_read_list(fd->fd_sys,mem_list_count, mem_offsets,			   mem_lengths, file_list_count, file_offsets,			   file_lengths);	    size_read += new_buffer_read;	    start_k = k;	    start_j = j;	} /* while (size_read < bufsize) */	ADIOI_Free(mem_offsets);	ADIOI_Free(mem_lengths);    }    ADIOI_Free(file_offsets);    ADIOI_Free(file_lengths);        if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;    fd->fp_sys_posn = -1;   /* set it to null. */    #ifdef HAVE_STATUS_SET_BYTES    MPIR_Status_set_bytes(status, datatype, bufsize);    /* This is a temporary way of filling in status. The right way is to        keep track of how much data was actually read and placed in buf        by ADIOI_BUFFERED_READ. */#endif        if (!buftype_is_contig) ADIOI_Delete_flattened(datatype);}#endif /* HAVE_PVFS_LISTIO */

⌨️ 快捷键说明

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