Changeset 120
- Timestamp:
- 03/21/07 22:06:13
- Files:
-
- src/io_fwrite_list_shared_async_comm.upc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fwrite_list_shared_async_comm.upc
r118 r120 4 4 5 5 #include <stdio.h> 6 #include <errno.h> 6 7 7 8 /* For all BLOCKSIZE == 0, use the static memeory. 8 for all other cases, use the dynamic memory allocation9 */9 * for all other cases, use the dynamic memory allocation 10 */ 10 11 11 12 #if BLOCKSIZE == 0 … … 15 16 shared [0] TYPE vbf[180]; 16 17 18 17 19 /* nmembs and offsets, this only works for up to 8 threads */ 18 static int nmembs [] = { 23, 7, 15, 33};19 static int offsets [] = { 2, 35, 120, 50};20 static int nmembs [] = {23, 37}; 21 static int offsets [] = {2, 35}; 20 22 21 23 int … … 24 26 int i, j; 25 27 int blocksize = BLOCKSIZE; 26 ssize_t ret , bytes;27 shared [0] TYPE *vbfp; 28 ssize_t ret; 29 shared [0] TYPE *vbfp; 28 30 29 31 #if BLOCKSIZE != 0 30 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize *sizeof(TYPE));32 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize * sizeof(TYPE)); 31 33 #endif 32 34 33 35 struct upc_shared_memvec memvec[2]; 34 memvec[0].baseaddr = buffer + offsets[0];35 memvec[0].blocksize = blocksize;36 memvec[0].len = nmembs[0];37 memvec[0].elemsize = sizeof(TYPE);36 memvec[0].baseaddr = buffer + offsets[0]; 37 memvec[0].blocksize = blocksize; 38 memvec[0].len = nmembs[0]; 39 memvec[0].elemsize = sizeof(TYPE); 38 40 39 memvec[1].baseaddr = buffer + offsets[1];40 memvec[1].blocksize = blocksize;41 memvec[1].len = nmembs[1];42 memvec[1].elemsize = sizeof(TYPE);41 memvec[1].baseaddr = buffer + offsets[1]; 42 memvec[1].blocksize = blocksize; 43 memvec[1].len = nmembs[1]; 44 memvec[1].elemsize = sizeof(TYPE); 43 45 44 struct upc_filevec filevec[3];45 filevec[0].offset = offsets[0] * sizeof(TYPE);46 filevec[0].len = 30 * sizeof(TYPE);46 struct upc_filevec filevec[3]; 47 filevec[0].offset = offsets[0] * sizeof(TYPE); 48 filevec[0].len = 30 * sizeof(TYPE); 47 49 48 filevec[1].offset = offsets[1] * sizeof(TYPE);49 filevec[1].len = 1 * sizeof(TYPE);50 filevec[1].offset = offsets[1] * sizeof(TYPE); 51 filevec[1].len = 1 * sizeof(TYPE); 50 52 51 filevec[2].offset = 40 * sizeof(TYPE);52 filevec[2].len = 29 * sizeof(TYPE);53 filevec[2].offset = 40 * sizeof(TYPE); 54 filevec[2].len = 29 * sizeof(TYPE); 53 55 54 if( MYTHREAD == 0) 55 for( i = 0; i< 180; i++ ) 56 buffer[i] = i % 0x80;57 upc_barrier;56 if( MYTHREAD == 0) 57 for( i = 0; i< 180; i++ ) 58 buffer[i] = i % 0x80; 59 upc_barrier; 58 60 59 61 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); … … 61 63 #if BLOCKSIZE != 0 62 64 if (MYTHREAD == 0) 63 upc_free(buffer);65 upc_free(buffer); 64 66 #endif 65 67 GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); … … 68 70 69 71 upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 70 bytes = upc_all_fwait_async(fd); 72 upc_all_fwait_async(fd); 73 upc_all_fsync(fd); 71 74 upc_barrier; 72 73 /* Validation for data integirty */74 /* Read the data to vbf */75 vbfp = vbf;76 for (i = 0; i < 3; i++) {77 upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET);78 ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC);79 vbfp += filevec[i].len / sizeof(TYPE);80 upc_barrier;81 }82 83 /* Check the data integrity based on the memvec */84 vbfp = vbf;85 for (i = 0; i < 2; i++) {86 for (j = 0; j < memvec[i].len; j++) {87 if (*vbfp != (offsets[i] + j) % 0x80)88 GULA_FAIL("Data integrity is violated!");89 vbfp ++;90 }91 }92 upc_barrier;93 75 94 #if BLOCKSIZE != 0 95 if (MYTHREAD == 0) 76 /* Validation for data integirty */ 77 /* Read the data to vbf */ 78 vbfp = vbf; 79 for (i = 0; i < 3; i++) { 80 upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 81 ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 82 vbfp += filevec[i].len / sizeof(TYPE); 83 upc_barrier; 84 } 85 86 /* Check the data integrity based on the memvec */ 87 vbfp = vbf; 88 for (i = 0; i < 2; i++) { 89 for (j = 0; j < memvec[i].len; j++) { 90 if (*vbfp != (offsets[i] + j) % 0x80) 91 GULA_FAIL("Data integrity is violated!"); 92 vbfp ++; 93 } 94 } 95 upc_barrier; 96 97 #if BLOCKSIZE != 0 98 if (MYTHREAD == 0) 96 99 upc_free(buffer); 97 100 #endif … … 99 102 return 0; 100 103 } 104
