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-pattern2.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  4KB  |  170 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.     PVFS_Request_contiguous(256, PVFS_BYTE, &file_req);
  47.  
  48.     /* setup mem datatype */
  49.     len_array[0] = 0;
  50.     off_array[0] = 135295720;
  51.     for(i=0; i<64; i++)
  52.     {
  53.         len_array[i] = 4;
  54.         off_array[i] = 135313976 + i*8;
  55.     }
  56.     PVFS_Request_hindexed(64, len_array, off_array, PVFS_BYTE, &mem_req);
  57.  
  58.     mem_state = PINT_new_request_state(mem_req);
  59.     file_state = PINT_new_request_state(file_req);
  60.     file_state_server = PINT_new_request_state(file_req);
  61.  
  62.     /* set up file data for request */
  63.     PINT_dist_initialize(NULL);
  64.     rf1.server_nr = 0;
  65.     rf1.server_ct = 1;
  66.     rf1.fsize = 0;
  67.     rf1.dist = PINT_dist_create("simple_stripe");
  68.     rf1.extend_flag = 1;
  69.     PINT_dist_lookup(rf1.dist);
  70.  
  71.     /* set up result struct */
  72.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  73.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  74.     seg1.bytemax = BYTEMAX;
  75.     seg1.segmax = SEGMAX;
  76.     seg1.bytes = 0;
  77.     seg1.segs = 0;
  78.     
  79.  
  80.     PINT_REQUEST_STATE_SET_TARGET(file_state, 0);
  81.     PINT_REQUEST_STATE_SET_FINAL(file_state, PINT_REQUEST_TOTAL_BYTES(mem_req));
  82.     PINT_REQUEST_STATE_SET_TARGET(file_state_server, 0);
  83.     PINT_REQUEST_STATE_SET_FINAL(file_state_server, PINT_REQUEST_TOTAL_BYTES(mem_req));
  84.  
  85.  
  86.    /* Turn on debugging */
  87.     // gossip_enable_stderr();
  88.     // gossip_set_debug_mask(1,REQUEST_DEBUG); 
  89.  
  90.     printf("\nCLIENT ************************************\n");
  91.     do
  92.     {
  93.         seg1.bytes = 0;
  94.         seg1.segs = 0;
  95.  
  96.         /* process request */
  97.         retval = PINT_process_request(file_state, mem_state, &rf1, &seg1, PINT_CLIENT);
  98.  
  99.         if(retval >= 0)
  100.         {
  101.             printf("results of PINT_process_request():\n");
  102.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  103.             total_bytes_client += seg1.bytes;
  104.             for(i=0; i<seg1.segs; i++)
  105.             {
  106.                 printf("  segment %d: offset: %d size: %d\n",
  107.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  108.             }
  109.         }
  110.  
  111.     } while(!PINT_REQUEST_DONE(file_state) && retval >= 0);
  112.     
  113.     if(retval < 0)
  114.     {
  115.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  116.         return(-1);
  117.     }
  118.     if(PINT_REQUEST_DONE(file_state))
  119.     {
  120.         printf("**** request done.\n");
  121.     }
  122.     
  123.     printf("\nSERVER ************************************\n");
  124.     do
  125.     {
  126.         seg1.bytes = 0;
  127.         seg1.segs = 0;
  128.  
  129.         /* process request */
  130.         retval = PINT_process_request(file_state_server, NULL, &rf1, &seg1, PINT_SERVER);
  131.  
  132.         if(retval >= 0)
  133.         {
  134.             printf("results of PINT_process_request():\n");
  135.             printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  136.             total_bytes_server += seg1.bytes;
  137.             for(i=0; i<seg1.segs; i++)
  138.             {
  139.                 printf("  segment %d: offset: %d size: %d\n",
  140.                     i, (int)seg1.offset_array[i], (int)seg1.size_array[i]);
  141.             }
  142.         }
  143.  
  144.     } while(!PINT_REQUEST_DONE(file_state_server) && retval >= 0);
  145.  
  146.     if(retval < 0)
  147.     {
  148.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  149.         return(-1);
  150.     }
  151.     if(PINT_REQUEST_DONE(file_state_server))
  152.     {
  153.         printf("**** request done.\n");
  154.     }
  155.  
  156.     printf("total bytes processed on client side: %lld\n", (long long)total_bytes_client);
  157.     printf("total bytes processed on server side: %lld\n", (long long)total_bytes_server);
  158.  
  159.     if(total_bytes_client == total_bytes_server)
  160.     {
  161.         printf("SUCCESS.\n");
  162.     }
  163.     else
  164.     {
  165.         printf("FAILURE!!!\n");
  166.     }
  167.  
  168.     return 0;
  169. }
  170.