Changeset 116
- Timestamp:
- 03/21/07 19:09:05
- Files:
-
- src/io_fwrite_shared_async_comm.upc (modified) (5 diffs)
- src/io_fwrite_shared_async_ind.upc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fwrite_shared_async_comm.upc
r112 r116 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 … … 18 19 main(int argc, char *argv[]){ 19 20 20 int i, j;21 int i,j; 21 22 int nmemb = 60; 22 23 int blocksize = BLOCKSIZE; 23 int memoff = 6;24 upc_off_t fileoff = 19;25 ssize_t bytes;26 upc_off_t offset;24 int memoff = 6; 25 upc_off_t fileoff = 19; 26 ssize_t bytes; 27 upc_off_t offset; 27 28 28 29 #if BLOCKSIZE != 0 … … 30 31 #endif 31 32 33 if( MYTHREAD == 0) 34 for( i = 0; i< 180; i++ ) 35 buffer[i] = i % 256; 36 upc_barrier; 37 32 38 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 33 34 if (fd == NULL) { 39 if (fd == NULL) { 35 40 #if BLOCKSIZE != 0 36 if (MYTHREAD == 0)41 if (MYTHREAD == 0) 37 42 upc_free(buffer); 38 43 #endif … … 44 49 upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 45 50 46 upc_all_fwrite_shared_async(fd, buffer +memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC);51 upc_all_fwrite_shared_async(fd, buffer + memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 47 52 bytes = upc_all_fwait_async(fd); 48 53 49 54 if (bytes != nmemb * sizeof(TYPE)) 50 GULA_FAIL("Short write is not expected, is disc full ?");55 GULA_FAIL("Short write is not expected, is disc full ?"); 51 56 52 57 offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 53 58 if (offset != (fileoff + nmemb) * sizeof(TYPE)) 54 GULA_FAIL("Fail to setup the file pointer");55 upc_barrier;59 GULA_FAIL("Fail to setup the file pointer"); 60 upc_barrier; 56 61 57 /* Validation for data integrity */58 upc_all_fsync(fd);59 upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET);60 upc_all_fread_shared(fd, vfb, 0, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC);62 /* Validation for data integrity */ 63 upc_all_fsync(fd); 64 upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 65 upc_all_fread_shared(fd, vfb, 0, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 61 66 62 for (i = 0; i < nmemb; i++) { 63 if (vfb[i] != (memoff + i) % 0x80) 64 GULA_FAIL("Data integrity is violated!"); 65 } 66 67 upc_barrier; 68 67 for (i = 0; i < nmemb; i++) { 68 if (vfb[i] != (memoff + i) % 0x80) 69 GULA_FAIL("Data integrity is violated!"); 70 } 71 72 upc_barrier; 69 73 #if BLOCKSIZE != 0 70 74 if (MYTHREAD == 0) … … 75 79 } 76 80 81 src/io_fwrite_shared_async_ind.upc
r110 r116 14 14 #endif 15 15 16 16 17 /* nmembs and offsets, this only works for up to 4 threads */ 17 18 static int nmembs [] = { 23, 5, 37, 6, 8, 12 }; … … 19 20 static TYPE vfb[180]; 20 21 21 int 22 int 22 23 main(int argc, char *argv[]){ 23 24 int i, j;25 int nmemb = nmembs[MYTHREAD];26 upc_off_t offset = offsets[MYTHREAD];27 int blocksize = BLOCKSIZE;28 s ize_t bytes;24 25 int i, j; 26 int nmemb = nmembs[MYTHREAD]; 27 upc_off_t offset = offsets[MYTHREAD]; 28 int blocksize = BLOCKSIZE; 29 ssize_t bytes; 29 30 upc_off_t vo; 30 31 31 32 #if BLOCKSIZE != 0 32 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE));33 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 33 34 #endif 34 35 … … 39 40 40 41 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_INDIVIDUAL_FP, 0, NULL); 41 if (fd == NULL) {42 if (fd == NULL) { 42 43 #if BLOCKSIZE != 0 43 44 if (MYTHREAD == 0) 44 upc_free(buffer);45 upc_free(buffer); 45 46 #endif 46 47 GULA_FAIL("failed to open the file using UPC_RDWR | UPC_INDIVIDUAL_FP"); 47 48 } 48 upc_barrier;49 49 50 vo = upc_all_fseek(fd, offset, UPC_SEEK_SET); 51 52 upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 50 upc_barrier; 51 52 vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 53 upc_all_fwrite_shared_async(fd, buffer + offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 53 54 bytes = upc_all_fwait_async(fd); 54 55 55 56 if (bytes != nmemb * sizeof(TYPE)) 56 GULA_FAIL("Short write is not expected, is disc full ?");57 GULA_FAIL("Short write is not expected, is disc full ?"); 57 58 58 59 vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 59 60 if (vo != (offset + nmemb) * sizeof(TYPE)) 60 GULA_FAIL("Fail to setup the file pointer"); 61 61 GULA_FAIL("Fail to setup the file pointer"); 62 62 upc_barrier; 63 63 64 /* Validation for data integrity */ 65 upc_all_fsync(fd); 66 vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 67 upc_all_fread_local(fd, vfb, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 68 for (i = 0; i < nmemb; i++) { 69 if (vfb[i] != (offset + i) % 0x80) 70 GULA_FAIL("Data integrity is violated!"); 71 } 72 73 upc_barrier; 74 75 #if BLOCKSIZE != 0 76 if (MYTHREAD == 0) 64 /* Validation for data integrity */ 65 upc_all_fsync(fd); 66 vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 67 upc_all_fread_local(fd, vfb, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 68 for (i = 0; i < nmemb; i++) { 69 if (vfb[i] != (offset + i) % 0x80) 70 GULA_FAIL("Data integrity is violated!"); 71 } 72 73 upc_barrier; 74 #if BLOCKSIZE != 0 75 if (MYTHREAD == 0) 77 76 upc_free(buffer); 78 77 #endif … … 80 79 return 0; 81 80 } 81 82
