?? ad_testfs_seek.c
字號:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * $Id: ad_testfs_seek.c,v 1.4 2002/10/24 17:01:05 gropp Exp $ * * Copyright (C) 2001 University of Chicago. * See COPYRIGHT notice in top-level directory. */#include "ad_testfs.h"#include "adioi.h"#include "adio_extern.h"/* ADIOI_TESTFS_SeekIndividual() * * Implements SEEK_SET only (and doesn't test for whence type); all * other types of whence must be converted before calling this. * * Returns an absolute offset in bytes. The offset passed into the call is in * terms of the etype relative to the filetype, so some calculations are * necessary. */ADIO_Offset ADIOI_TESTFS_SeekIndividual(ADIO_File fd, ADIO_Offset offset, int whence, int *error_code){ int myrank, nprocs; ADIO_Offset off; ADIOI_Flatlist_node *flat_file; int i, n_etypes_in_filetype, n_filetypes, etype_in_filetype; ADIO_Offset abs_off_in_filetype=0; int size_in_filetype, sum; int filetype_size, etype_size, filetype_is_contig; MPI_Aint filetype_extent; *error_code = MPI_SUCCESS; MPI_Comm_size(fd->comm, &nprocs); MPI_Comm_rank(fd->comm, &myrank); FPRINTF(stdout, "[%d/%d] ADIOI_TESTFS_SeekIndividual called on %s\n", myrank, nprocs, fd->filename); ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig); etype_size = fd->etype_size; if (filetype_is_contig) off = fd->disp + etype_size * offset; else { flat_file = ADIOI_Flatlist; while (flat_file->type != fd->filetype) flat_file = flat_file->next; MPI_Type_extent(fd->filetype, &filetype_extent); MPI_Type_size(fd->filetype, &filetype_size); if ( ! filetype_size ) { *error_code = MPI_SUCCESS; return 0; } n_etypes_in_filetype = filetype_size/etype_size; n_filetypes = (int) (offset / n_etypes_in_filetype); etype_in_filetype = (int) (offset % n_etypes_in_filetype); size_in_filetype = etype_in_filetype * etype_size; sum = 0; for (i=0; i<flat_file->count; i++) { sum += flat_file->blocklens[i]; if (sum > size_in_filetype) { abs_off_in_filetype = flat_file->indices[i] + size_in_filetype - (sum - flat_file->blocklens[i]); break; } } /* abs. offset in bytes in the file */ off = fd->disp + (ADIO_Offset) n_filetypes * filetype_extent + abs_off_in_filetype; } fd->fp_ind = off; fd->fp_sys_posn = off; return off;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -