Changeset 118
- Timestamp:
- 03/21/07 21:52:03
- Files:
-
- src/io_fread_list_shared_async.upc (modified) (7 diffs)
- src/io_fread_list_shared_async_comm.upc (modified) (1 diff)
- src/io_fread_list_shared_async_ind.upc (modified) (3 diffs)
- src/io_fwrite_list_shared_async_comm.upc (modified) (1 diff)
- src/io_fwrite_list_shared_async_ind.upc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/io_fread_list_shared_async.upc
r51 r118 1 1 /* 2 * Copyright (C) 2006 Abdullah Kayi 2 3 * Copyright (C) 2006 Kun Xi 3 * Copyright (C) 2006 Abdullah Kayi4 4 * Copyright (C) 2006 The George Washington University 5 5 * All rights reserved. … … 32 32 33 33 #include <io.h> 34 35 34 #include <stdio.h> 36 35 … … 39 38 40 39 static char fname[] = "read.test"; 40 41 41 static upc_file_t* fd = NULL; 42 static int flags[] ={ UPC_RDONLY | UPC_INDIVIDUAL_FP, 43 UPC_RDONLY | UPC_COMMON_FP }; 44 static int flag; 42 45 43 static upc_flag_t sync_mode = NULL; 44 static upc_flag_t sync = NULL; 45 46 static int i, j, ret, flag; 47 static int flags[] ={ UPC_RDONLY | UPC_INDIVIDUAL_FP, 48 UPC_RDONLY | UPC_COMMON_FP }; 49 50 static shared[] char **buffer; 51 52 static size_t size, nmemb, blocksize; 53 static upc_off_t offset, ret_offset; 46 54 47 55 static struct upc_shared_memvec memvec[]; 48 56 static struct upc_filevec filevec[]; 49 50 static upc_flag_t sync = 0;51 static int i,j, ret;52 static size_t size = 0;53 54 static shared[] char **buffer;55 static shared[] unsigned unsigned char *pd;56 static shared[] unsigned unsigned char *base;57 57 58 58 static int … … 68 68 break; 69 69 } 70 71 70 shift = pfv[i].len - ( size - offset ); 72 71 return ( x == (pfv[i].offset + shift)% 128 ); … … 74 73 75 74 static int 76 verify(size_t me, struct upc_shared_memvec *pmv, size_t fe, struct upc_filevec *pfv)75 verify(size_t me, struct upc_shared_memvec* pmv, size_t fe, struct upc_filevec* pfv) 77 76 { 78 77 int i, j, k; 79 base = (shared[BLOCKSIZE] unsigned char*) upc_all_alloc(1, BLOCKSIZE); 80 base = NULL; 81 78 shared [BLOCKSIZE] unsigned char* base = NULL; 82 79 int count = 0; 83 80 for( i = 0; i < me; i++ ) { 84 base = (shared [BLOCKSIZE] unsigned char*) pmv[i].baseaddr;81 base = (shared [BLOCKSIZE] unsigned char*) pmv[i].baseaddr; 85 82 for( j = 0; j < pmv[i].len; j++ ) { 86 83 /* Read the data */ … … 96 93 main() 97 94 { 98 /* To check that each thread reads correct data according to the memvec and filevec from specified file 99 * to the shared buffer, regardless of whether the current file pointer type is individual or common 100 * Also make sure that this function call does not update the offset of the file pointer 101 */ 102 pd = (shared[BLOCKSIZE] char*) upc_all_alloc(1, BLOCKSIZE*sizeof(char)); 103 104 pd = NULL; 95 /* To check that each thread reads correct data according to the memvec and filevec 96 * from specified file to the shared buffer, regardless of whether the current file 97 * pointer type is individual or common. And this function call does not update the 98 * offset of the file pointer 99 */ 105 100 buffer = upc_all_alloc(THREADS*NMEMB, BLOCKSIZE*sizeof(char *)); 106 101 … … 120 115 size += memvec[i].len; 121 116 122 for( i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) 123 { 117 for( i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) { 124 118 flag = flags[i]; 125 126 119 fd = upc_all_fopen( fname, flag, 0, NULL); 127 120 if( fd == NULL ) 128 121 GULA_FAIL("failed to open the file"); 122 129 123 upc_barrier; 130 124 131 125 /* Now, we are going to launch upc_fread */ 132 upc_all_fread_list_shared_async(fd, sizeof(memvec)/sizeof(memvec[0]), memvec, 133 sizeof(filevec)/sizeof(filevec[0]), filevec, sync); 134 upc_barrier; 135 136 ret = upc_all_fwait_async(fd); 137 if( ret == -1 ) { 138 GULA_FAIL("failed on fwait_async"); 139 } 140 else { 141 if( ret != size) { 142 GULA_FAIL("failed to read data equal to the amount requested"); 143 } 144 } 145 upc_barrier; 146 147 if( -1 == verify(sizeof(memvec)/sizeof(memvec[0]), memvec, sizeof(filevec)/sizeof(filevec[0]), filevec)) 148 GULA_FAIL("failed to read correct data"); 126 ret = upc_all_fread_list_shared(fd, sizeof(memvec)/sizeof(memvec[0]), &memvec,sizeof(filevec)/sizeof(filevec[0]), &filevec, sync); 149 127 150 128 upc_barrier; 129 /* 130 if( ret != size ) 131 GULA_FAIL("failed to return the requested bytes"); 151 132 152 if( upc_all_fclose(fd) != 0 ) 153 GULA_FAIL("failed to close the file"); 154 133 if( -1 == verify(sizeof(memvec)/sizeof(memvec[0]), memvec,sizeof(filevec)/sizeof(filevec[0]), filevec)) 134 GULA_FAIL("failed to read correct data"); 155 135 upc_barrier; 136 137 if( upc_all_fclose(fd) != 0 ) 138 GULA_FAIL("failed to close the file"); 139 140 upc_barrier; 141 */ 156 142 } 157 158 143 return 0; 159 144 } src/io_fread_list_shared_async_comm.upc
r113 r118 63 63 upc_barrier; 64 64 65 upc_all_fread_list_shared_async(fd, 2, memvec, 1, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC);65 upc_all_fread_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 66 66 bytes = upc_all_fwait_async(fd); 67 67 upc_barrier; src/io_fread_list_shared_async_ind.upc
r113 r118 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 … … 16 16 static TYPE vbf[180]; 17 17 18 /* nmembs and offsets, this only works for up to 6 threads */ 18 19 /* nmembs and offsets, this only works for up to 3 threads */ 20 /* Please consider the overlapping for list operation */ 21 22 /* XXX: we need to test whether elemsize is enable for list operation ! */ 23 19 24 static int nmembs [] = { 23, 2, 37, 5, 41, 7}; 20 25 static int offsets [] = { 2, 130, 30, 140, 77, 150}; 21 26 22 int 27 28 29 int 23 30 main(int argc, char *argv[]){ 24 31 25 32 int i, j; 26 33 int nmemb = nmembs[MYTHREAD]; 27 int offset = offsets[MYTHREAD];28 int blocksize = BLOCKSIZE; 29 TYPE *vbfp; 30 34 upc_off_t offset = offsets[MYTHREAD]; 35 int blocksize = BLOCKSIZE; 36 TYPE *vbfp; 37 31 38 #if BLOCKSIZE != 0 32 39 shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 33 40 #endif 34 41 35 42 struct upc_shared_memvec memvec[2]; 36 memvec[0].baseaddr = buffer + offsets[MYTHREAD * 2];37 memvec[0].blocksize = blocksize;38 memvec[0].len = nmembs[MYTHREAD * 2];39 memvec[0].elemsize = sizeof(TYPE);43 memvec[0].baseaddr = buffer + offsets[MYTHREAD * 2]; 44 memvec[0].blocksize = blocksize; 45 memvec[0].len = nmembs[MYTHREAD * 2]; 46 memvec[0].elemsize = sizeof(TYPE); 40 47 41 memvec[1].baseaddr = buffer + offsets[MYTHREAD * 2 + 1];42 memvec[1].blocksize = blocksize;43 memvec[1].len = nmembs[MYTHREAD * 2 + 1];44 memvec[1].elemsize = sizeof(TYPE);48 memvec[1].baseaddr = buffer + offsets[MYTHREAD * 2 + 1]; 49 memvec[1].blocksize = blocksize; 50 memvec[1].len = nmembs[MYTHREAD * 2 + 1]; 51 memvec[1].elemsize = sizeof(TYPE); 45 52 46 struct upc_filevec filevec[3];47 filevec[0].offset = offsets[MYTHREAD] * sizeof(TYPE);48 filevec[0].len = 10 * sizeof(TYPE);49 filevec[1].offset = offsets[MYTHREAD+1] * sizeof(TYPE);50 filevec[1].len = 10 * sizeof(TYPE);51 filevec[2].offset = offsets[MYTHREAD+2] * sizeof(TYPE);52 filevec[2].len = (memvec[0].len + memvec[1].len - 20) * sizeof(TYPE);53 struct upc_filevec filevec[3]; 54 filevec[0].offset = offsets[MYTHREAD] * sizeof(TYPE); 55 filevec[0].len = 10 * sizeof(TYPE); 56 filevec[1].offset = offsets[MYTHREAD+1] * sizeof(TYPE); 57 filevec[1].len = 10 * sizeof(TYPE); 58 filevec[2].offset = offsets[MYTHREAD+2] * sizeof(TYPE); 59 filevec[2].len = (memvec[0].len + memvec[1].len - 20) * sizeof(TYPE); 53 60 54 61 upc_file_t* fd = upc_all_fopen(argv[1], UPC_RDONLY | UPC_INDIVIDUAL_FP, 0, NULL); … … 56 63 #if BLOCKSIZE != 0 57 64 if (MYTHREAD == 0) 58 upc_free(buffer);65 upc_free(buffer); 59 66 #endif 60 67 GULA_FAIL("failed to open the file using UPC_RDONLY | UPC_INDIVIDUAL_FP"); 61 } 68 } 69 62 70 upc_barrier; 63 71 64 72 upc_all_fread_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 73 upc_all_fwait_async(fd); 65 74 upc_barrier; 66 75 67 76 /* Validation start */ 68 77 69 /* copy the chunks to vbf */ 70 vbfp = vbf; 71 gupc_memget(vbfp, memvec[0].baseaddr, blocksize, sizeof(TYPE), memvec[0].len); 72 vbfp += memvec[0].len; 73 gupc_memget(vbfp, memvec[1].baseaddr, blocksize, sizeof(TYPE), memvec[1].len); 78 /* copy the chunks to vbf */ 79 vbfp = vbf; 80 gupc_memget(vbfp, memvec[0].baseaddr, blocksize, sizeof(TYPE), memvec[0].len); 81 vbfp += memvec[0].len; 82 gupc_memget(vbfp, memvec[1].baseaddr, blocksize, sizeof(TYPE), memvec[1].len); 83 84 /* verify the data using the filevec information */ 85 vbfp = vbf; 86 for (i = 0; i < 3; i++) { 87 for (j = 0; j < filevec[i].len/sizeof(TYPE); j++) { 88 if (*vbfp != (filevec[i].offset / sizeof(TYPE) + j) % 0x80) 89 GULA_FAIL("Data integrity is violated!"); 90 vbfp ++; 91 } 92 } 74 93 75 /* verify the data using the filevec information */ 76 vbfp = vbf; 77 for (i = 0; i < 3; i++) { 78 for (j = 0; j < filevec[i].len/sizeof(TYPE); j++) { 79 if (*vbfp != (filevec[i].offset / sizeof(TYPE) + j) % 0x80) 80 GULA_FAIL("Data integrity is violated!"); 81 vbfp ++; 82 } 83 } 84 85 #if BLOCKSIZE != 0 86 if (MYTHREAD == 0) 87 upc_free(buffer); 94 #if BLOCKSIZE != 0 95 if (MYTHREAD == 0) 96 upc_free(buffer); 88 97 #endif 89 90 98 return 0; 91 99 } src/io_fwrite_list_shared_async_comm.upc
r117 r118 68 68 69 69 upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 70 ssize_tbytes = upc_all_fwait_async(fd);70 bytes = upc_all_fwait_async(fd); 71 71 upc_barrier; 72 72 src/io_fwrite_list_shared_async_ind.upc
r113 r118 70 70 71 71 upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 72 upc_all_fwait_async(fd); 72 73 upc_barrier; 73 74
