Changeset 111
- Timestamp:
- 03/19/07 19:06:05
- Files:
-
- src/io_fread_list_shared_comm.upc (modified) (2 diffs)
- src/io_fwrite_list_shared_comm.upc (modified) (5 diffs)
- src/io_fwrite_list_shared_ind.upc (modified) (2 diffs)
- src/units_shared (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fread_list_shared_comm.upc
r109 r111 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 … … 31 31 32 32 #if BLOCKSIZE != 0 33 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(1 00, blocksize*sizeof(TYPE));33 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 34 34 #endif 35 35 src/io_fwrite_list_shared_comm.upc
r103 r111 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 … … 14 14 #endif 15 15 16 shared [0] TYPE vbf[180]; 17 16 18 17 19 /* nmembs and offsets, this only works for up to 8 threads */ 18 static int nmembs [] = { 23, 37, 12 , 44, 14, 31, 4, 55};19 static int offsets [] = { 2, 30, 81 , 25, 77, 121, 139, 47};20 static int nmembs [] = {23, 37}; 21 static int offsets [] = {2, 35}; 20 22 21 23 int … … 23 25 24 26 int i, j; 25 int nmemb = nmembs[MYTHREAD];26 upc_off_t offset = offsets[MYTHREAD];27 27 int blocksize = BLOCKSIZE; 28 ssize_t bytes;29 upc_off_t vo;28 ssize_t ret; 29 shared [0] TYPE *vbfp; 30 30 31 31 #if BLOCKSIZE != 0 32 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(1 00, blocksize*sizeof(TYPE));32 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize * sizeof(TYPE)); 33 33 #endif 34 34 … … 37 37 memvec[0].blocksize = blocksize; 38 38 memvec[0].len = nmembs[0]; 39 memvec[0].elemsize = 1;39 memvec[0].elemsize = sizeof(TYPE); 40 40 41 41 memvec[1].baseaddr = buffer + offsets[1]; 42 42 memvec[1].blocksize = blocksize; 43 43 memvec[1].len = nmembs[1]; 44 memvec[1].elemsize = 1;44 memvec[1].elemsize = sizeof(TYPE); 45 45 46 46 struct upc_filevec filevec[3]; 47 filevec[0].offset = offsets[0] ;48 filevec[0].len = 30 ;47 filevec[0].offset = offsets[0] * sizeof(TYPE); 48 filevec[0].len = 30 * sizeof(TYPE); 49 49 50 filevec[1].offset = offsets[1] ;51 filevec[1].len = 1 ;50 filevec[1].offset = offsets[1] * sizeof(TYPE); 51 filevec[1].len = 1 * sizeof(TYPE); 52 52 53 filevec[2].offset = 40 ;54 filevec[2].len = 29 ;53 filevec[2].offset = 40 * sizeof(TYPE); 54 filevec[2].len = 29 * sizeof(TYPE); 55 55 56 if( MYTHREAD == 0) 57 for( i = 0; i< 180; i++ ) 58 buffer[i] = i % 0x80; 59 upc_barrier; 56 60 57 for( j = 0; j< THREADS; j++ ) { 58 if( MYTHREAD == j) { 59 fprintf(stderr, "TH%d : ", j); 60 for(i = 0; i < 2; i++ ) 61 fprintf( stderr, "memvec: len = %d, fv: offset = %d\n", memvec[i].len, filevec[i].offset ); 62 fprintf(stderr, "\n"); 63 } 64 sleep(3); 65 upc_barrier; 66 } 67 68 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_WRONLY | UPC_COMMON_FP, 0, NULL); 61 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 69 62 if (fd == NULL) { 70 63 #if BLOCKSIZE != 0 … … 72 65 upc_free(buffer); 73 66 #endif 74 GULA_FAIL("failed to open the file using UPC_ WRONLY| UPC_COMMON_FP");67 GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); 75 68 } 76 69 upc_barrier; 77 70 78 bytes = upc_all_fwrite_list_shared(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 79 vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 80 fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, 0, bytes, vo); 71 upc_all_fwrite_list_shared(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 72 upc_all_fsync(fd); 73 upc_barrier; 74 75 /* Validation for data integirty */ 76 /* Read the data to vbf */ 77 vbfp = vbf; 78 for (i = 0; i < 3; i++) { 79 upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 80 ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 81 vbfp += filevec[i].len / sizeof(TYPE); 82 upc_barrier; 83 } 84 85 /* Check the data integrity based on the memvec */ 86 vbfp = vbf; 87 for (i = 0; i < 2; i++) { 88 for (j = 0; j < memvec[i].len; j++) { 89 if (*vbfp != (offsets[i] + j) % 0x80) 90 GULA_FAIL("Data integrity is violated!"); 91 vbfp ++; 92 } 93 } 81 94 upc_barrier; 82 95 src/io_fwrite_list_shared_ind.upc
r106 r111 34 34 35 35 #if BLOCKSIZE != 0 36 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize *sizeof(TYPE));36 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize * sizeof(TYPE)); 37 37 #endif 38 38 … … 83 83 upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 84 84 upc_all_fread_local(fd, vbfp, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 85 vbfp += filevec[i].len /sizeof(TYPE);85 vbfp += filevec[i].len / sizeof(TYPE); 86 86 } 87 87 src/units_shared
r109 r111 5 5 io_fread_list_shared_ind 6 6 io_fread_list_shared_comm 7 io_fwrite_list_shared_ind 8 io_fwrite_list_shared_comm
