Changeset 100
- Timestamp:
- 03/18/07 04:53:47
- Files:
-
- src/io_fread_shared_comm.upc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fread_shared_comm.upc
r86 r100 7 7 8 8 /* For all BLOCKSIZE == 0, use the static memeory. 9 for all other cases, use the dynamic memory allocation10 */9 * for all other cases, use the dynamic memory allocation 10 */ 11 11 12 12 #if BLOCKSIZE == 0 … … 18 18 19 19 int i; 20 int num = 24; 21 int offset = 6; 20 int nmemb = 24; 22 21 int blocksize = BLOCKSIZE; 22 int memoff = 6; 23 upc_off_t fileoff = 19; 23 24 ssize_t bytes; 24 upc_off_t vo; 25 upc_off_t offset; 26 27 if (argc != 2) { 28 if (MYTHREAD == 0) 29 printf("Usage: %s file\n", argv[0]); 30 upc_global_exit(-1); 31 } 25 32 26 33 #if BLOCKSIZE != 0 … … 32 39 #if BLOCKSIZE != 0 33 40 if (MYTHREAD == 0) 34 upc_free(buffer);41 upc_free(buffer); 35 42 #endif 36 43 GULA_FAIL("failed to open the file using UPC_RDONLY | UPC_COMMON_FP"); 37 44 } 45 upc_barrier; 38 46 47 upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 48 bytes = upc_all_fread_shared(fd, buffer + memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 39 49 40 50 upc_barrier; 41 42 upc_all_fseek(fd, 19*sizeof(int), UPC_SEEK_SET); 43 bytes = upc_all_fread_shared(fd, buffer+offset, blocksize, sizeof(TYPE), num, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 44 45 upc_barrier; 51 52 /* Validation for data integrity */ 46 53 if( MYTHREAD == 0 ) { 47 for(i = 0; i < num; i++ ) 48 fprintf( stderr, "%u ", buffer[i+offset] ); 54 for (i = 0; i < nmemb; i++) { 55 if (buffer[memoff + i] != (fileoff + i) % 0x80) 56 GULA_FAIL("Data integrity is violated!"); 57 } 49 58 } 50 59 51 vo= upc_all_fseek(fd, 0, UPC_SEEK_CUR);52 fprintf(stderr, "th%d: orign=%d, read %d bytes, offset = %d \n", MYTHREAD, 19*sizeof(int), bytes, vo);53 upc_barrier;60 offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 61 if (offset != (fileoff + nmemb) * sizeof(TYPE)) 62 GULA_FAIL("Fail to setup the file pointer"); 54 63 55 64 #if BLOCKSIZE != 0
