Changeset 110
- Timestamp:
- 03/19/07 01:38:27
- Files:
-
- src/io_fwrite_shared_async_ind.upc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fwrite_shared_async_ind.upc
r103 r110 14 14 #endif 15 15 16 17 /* 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};16 /* nmembs and offsets, this only works for up to 4 threads */ 17 static int nmembs [] = { 23, 5, 37, 6, 8, 12 }; 18 static int offsets [] = { 2, 120, 30, 102, 110, 81 }; 19 static TYPE vfb[180]; 20 20 21 21 int … … 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 35 if( MYTHREAD == 0) 35 36 for( i = 0; i< 180; i++ ) 36 buffer[i] = i % 256; 37 38 fprintf(stderr, "start writing Th%d \n", MYTHREAD); 37 buffer[i] = i % 0x80; 39 38 upc_barrier; 40 39 41 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_ WRONLY| UPC_INDIVIDUAL_FP, 0, NULL);40 upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_INDIVIDUAL_FP, 0, NULL); 42 41 if (fd == NULL) { 43 42 #if BLOCKSIZE != 0 … … 45 44 upc_free(buffer); 46 45 #endif 47 GULA_FAIL("failed to open the file using UPC_ WRONLY| UPC_INDIVIDUAL_FP");46 GULA_FAIL("failed to open the file using UPC_RDWR | UPC_INDIVIDUAL_FP"); 48 47 } 49 48 upc_barrier; … … 51 50 vo = upc_all_fseek(fd, offset, UPC_SEEK_SET); 52 51 53 upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof( char), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC);52 upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 54 53 bytes = upc_all_fwait_async(fd); 54 55 if (bytes != nmemb * sizeof(TYPE)) 56 GULA_FAIL("Short write is not expected, is disc full ?"); 57 55 58 vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 56 fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, offsets[MYTHREAD], bytes, vo); 59 if (vo != (offset + nmemb) * sizeof(TYPE)) 60 GULA_FAIL("Fail to setup the file pointer"); 61 57 62 upc_barrier; 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; 58 74 59 75 #if BLOCKSIZE != 0
