home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / test-romio-noncontig-pattern.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  4KB  |  175 lines

  1. /*
  2.  * (C) 2002 Clemson University.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */       
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <pvfs2-types.h>
  10. #include <gossip.h>
  11. #include <pvfs2-debug.h>
  12.  
  13. #include <pint-distribution.h>
  14. #include <pint-dist-utils.h>
  15. #include <pvfs2-request.h>
  16. #include <pint-request.h>
  17. #include <assert.h>
  18. #include "pvfs2-internal.h"
  19.  
  20. #define SEGMAX 16
  21. #define BYTEMAX (4*1024*1024)
  22.  
  23. int main(int argc, char **argv)
  24. {
  25.     int i;
  26.     PINT_Request *file_req;
  27.     PINT_Request *mem_req;
  28.     PINT_Request_state *mem_state;
  29.     PINT_Request_state *file_state;
  30.     PINT_Request_state *file_state_server;
  31.     PINT_request_file_data rf1;
  32.     PINT_Request_result seg1;
  33.     int32_t* len_array = NULL;
  34.     PVFS_offset* off_array = NULL;
  35.     PVFS_size total_bytes_client = 0;
  36.     PVFS_size total_bytes_server = 0;
  37.  
  38.     /* PVFS_Process_request arguments */
  39.     int retval;
  40.  
  41.     len_array = (int32_t*)malloc(64*sizeof(int32_t));
  42.     off_array = (PVFS_offset*)malloc(64*sizeof(PVFS_offset));
  43.     assert(len_array != NULL && off_array != NULL);
  44.  
  45.     /* setup file datatype */
  46.     for(i=0; i<63; i++)
  47.     {
  48.         len_array[i] = 4;
  49.         off_array[i] = 4 + (8*i);
  50.     }
  51.     PVFS_Request_hindexed(63, len_array, off_array, PVFS_BYTE, &file_req);
  52.  
  53.     /* setup mem datatype */
  54.     len_array[0] = 0;
  55.     off_array[0] = 135295720;
  56.     for(i=1; i<64; i++)
  57.     {
  58.         len_array[i] = 4;
  59.         off_array[i] = off_array[0] + 4 + ((i-1)*8);
  60.     }
  61.     PVFS_Request_hindexed(64, len_array, off_array, PVFS_BYTE, &mem_req);
  62.  
  63.     mem_state = PINT_new_request_state(mem_req);
  64.     file_state = PINT_new_request_state(file_req);
  65.     file_state_server = PINT_new_request_state(file_req);
  66.  
  67.     /* set up file data for request */
  68.     PINT_dist_initialize(NULL);
  69.     rf1.server_nr = 0;
  70.     rf1.server_ct = 1;
  71.     rf1.fsize = 0;
  72.     rf1.dist = PINT_dist_create("simple_stripe");
  73.     rf1.extend_flag = 1;
  74.     PINT_dist_lookup(rf1.dist);
  75.  
  76.     /* set up result struct */
  77.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  78.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  79.     seg1.bytemax = BYTEMAX;
  80.     seg1.segmax = SEGMAX;
  81.     seg1.bytes = 0;
  82.     seg1.segs = 0;
  83.     
  84.  
  85.     PINT_REQUEST_STATE_SET_TARGET(file_state, 0);
  86.     PINT_REQUEST_STATE_SET_FINAL(file_state, PINT_REQUEST_TOTAL_BYTES(mem_req));
  87.     PINT_REQUEST_STATE_SET_TARGET(file_state_server, 0);
  88.     PINT_REQUEST_STATE_SET_FINAL(file_state_server, PINT_REQUEST_TOTAL_BYTES(mem_req));
  89.  
  90.  
  91.    /* Turn on debugging */
  92.     // gossip_enable_stderr();
  93.     // gossip_set_debug_mask(1,REQUEST_DEBUG); 
  94.  
  95.     printf("\nCLIENT ************************************\n");
  96.     do
  97.     {
  98.         seg1.bytes = 0;
  99.         seg1.segs = 0;
  100.  
  101.         /* process request */
  102.         retval = PINT_process_request(file_state, mem_state, &rf1, &seg1, PINT_CLIENT);
  103.  
  104.         if(retval >= 0)
  105.         {
  106.             printf("results of PINT_process_request():\n");
  107.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  108.             total_bytes_client += seg1.bytes;
  109.             for(i=0; i<seg1.segs; i++)
  110.             {
  111.                 printf("  segment %d: offset: %d size: %d\n",
  112.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  113.             }
  114.         }
  115.  
  116.     } while(!PINT_REQUEST_DONE(file_state) && retval >= 0);
  117.     
  118.     if(retval < 0)
  119.     {
  120.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  121.         return(-1);
  122.     }
  123.     if(PINT_REQUEST_DONE(file_state))
  124.     {
  125.         printf("**** request done.\n");
  126.     }
  127.     
  128.     printf("\nSERVER ************************************\n");
  129.     do
  130.     {
  131.         seg1.bytes = 0;
  132.         seg1.segs = 0;
  133.  
  134.         /* process request */
  135.         retval = PINT_process_request(file_state_server, NULL, &rf1, &seg1, PINT_SERVER);
  136.  
  137.         if(retval >= 0)
  138.         {
  139.             printf("results of PINT_process_request():\n");
  140.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  141.             total_bytes_server += seg1.bytes;
  142.             for(i=0; i<seg1.segs; i++)
  143.             {
  144.                 printf("  segment %d: offset: %d size: %d\n",
  145.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  146.             }
  147.         }
  148.  
  149.     } while(!PINT_REQUEST_DONE(file_state_server) && retval >= 0);
  150.  
  151.     if(retval < 0)
  152.     {
  153.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  154.         return(-1);
  155.     }
  156.     if(PINT_REQUEST_DONE(file_state_server))
  157.     {
  158.         printf("**** request done.\n");
  159.     }
  160.  
  161.     printf("total bytes processed on client side: %lld\n", (long long)total_bytes_client);
  162.     printf("total bytes processed on server side: %lld\n", (long long)total_bytes_server);
  163.  
  164.     if(total_bytes_client == total_bytes_server)
  165.     {
  166.         printf("SUCCESS.\n");
  167.     }
  168.     else
  169.     {
  170.         printf("FAILURE!!!\n");
  171.     }
  172.  
  173.     return 0;
  174. }
  175.