Changeset 112
- Timestamp:
- 03/20/07 17:32:46
- Files:
-
- src/io_fwrite_shared_async_comm.upc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fwrite_shared_async_comm.upc
r103 r112 13 13 #endif 14 14 15 shared [0] TYPE vfb[180]; 16 15 17 int 16 18 main(int argc, char *argv[]){ … … 18 20 int i, j; 19 21 int nmemb = 60; 20 upc_off_t offset = 6;21 22 int blocksize = BLOCKSIZE; 23 int memoff = 6; 24 upc_off_t fileoff = 19; 22 25 ssize_t bytes; 23 upc_off_t vo;26 upc_off_t offset; 24 27 25 28 #if BLOCKSIZE != 0 26 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(1 00, blocksize*sizeof(TYPE));29 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 27 30 #endif 28 31 29 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_ WRONLY| UPC_COMMON_FP, 0, NULL);32 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 30 33 31 34 if (fd == NULL) { 32 35 #if BLOCKSIZE != 0 33 36 if (MYTHREAD == 0) 34 upc_free(buffer);37 upc_free(buffer); 35 38 #endif 36 GULA_FAIL("failed to open the file using UPC_ WRONLY| UPC_COMMON_FP");39 GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); 37 40 } 38 41 39 42 upc_barrier; 40 43 41 upc_all_fseek(fd, 16, UPC_SEEK_SET);44 upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 42 45 43 upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(char), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 44 fprintf(stderr, "start writing Th%d \n", MYTHREAD); 46 upc_all_fwrite_shared_async(fd, buffer+memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 45 47 bytes = upc_all_fwait_async(fd); 46 vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 47 fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, 16, bytes, vo); 48 49 if (bytes != nmemb * sizeof(TYPE)) 50 GULA_FAIL("Short write is not expected, is disc full ?"); 51 52 offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 53 if (offset != (fileoff + nmemb) * sizeof(TYPE)) 54 GULA_FAIL("Fail to setup the file pointer"); 55 upc_barrier; 56 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); 61 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; 48 68 49 69 #if BLOCKSIZE != 0
