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-pattern3.c < prev    next >
C/C++ Source or Header  |  2005-11-11  |  4KB  |  150 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 <string.h>
  10. #include <assert.h>
  11.  
  12. #include "pvfs2-types.h"
  13. #include "gossip.h"
  14. #include "pvfs2-debug.h"
  15. #include "pint-distribution.h"
  16. #include "pint-dist-utils.h"
  17. #include "pvfs2-request.h"
  18. #include "pint-request.h"
  19. #include "pvfs2-internal.h"
  20.  
  21. #define SEGMAX 16
  22. #define BYTEMAX (256*1024)
  23.  
  24. int main(
  25.     int argc,
  26.     char **argv)
  27. {
  28.     int i;
  29.     PINT_Request *file_req;
  30.     PINT_Request *mem_req;
  31.     PINT_Request_state *file_state;
  32.     PINT_request_file_data rf1;
  33.     PINT_Request_result seg1;
  34.     int32_t *len_array = NULL;
  35.     PVFS_offset *off_array = NULL;
  36.     PVFS_size total_bytes_client = 0;
  37.  
  38.     /* PVFS_Process_request arguments */
  39.     int retval;
  40.  
  41.     len_array = (int32_t *) malloc(17 * sizeof(int32_t));
  42.     off_array = (PVFS_offset *) malloc(17 * sizeof(PVFS_offset));
  43.     assert(len_array != NULL && off_array != NULL);
  44.  
  45.     /* setup file datatype */
  46.     len_array[0] = 4;
  47.     off_array[0] = 327552;
  48.     for (i = 1; i < 17; i++)
  49.     {
  50.     len_array[i] = 4;
  51.     off_array[i] = off_array[0] + i * 8;
  52.     }
  53.     PVFS_Request_hindexed(17, len_array, off_array, PVFS_BYTE, &file_req);
  54.  
  55.     /* setup mem datatype */
  56.     len_array[0] = 4;
  57.     off_array[0] = 135295720;
  58.     for (i = 1; i < 17; i++)
  59.     {
  60.     len_array[i] = 4;
  61.     off_array[i] = off_array[0] + i * 8;
  62.     }
  63.     PVFS_Request_hindexed(17, len_array, off_array, PVFS_BYTE, &mem_req);
  64.  
  65.     file_state = 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 = 4;
  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.     PINT_REQUEST_STATE_RESET(file_state);
  85.  
  86.  
  87.     PINT_REQUEST_STATE_SET_TARGET(file_state, 0);
  88.     PINT_REQUEST_STATE_SET_FINAL(file_state, 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.     /* process request */
  96.     retval = PINT_process_request(file_state, NULL, &rf1, &seg1, PINT_SERVER);
  97.  
  98.     assert(retval >= 0);
  99.  
  100.     printf("results of PINT_process_request():\n");
  101.     printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  102.     total_bytes_client += seg1.bytes;
  103.     for (i = 0; i < seg1.segs; i++)
  104.     {
  105.     printf("  segment %d: offset: %d size: %d\n",
  106.            i, (int) seg1.offset_array[i], (int) seg1.size_array[i]);
  107.     }
  108.  
  109.     printf("PINT_REQUEST_DONE: %d\n", PINT_REQUEST_DONE(file_state));
  110.  
  111.     if (!PINT_REQUEST_DONE(file_state))
  112.     {
  113.     fprintf(stderr,
  114.         "NEXT call to PINT_REQUEST_DONE should return 0.\n");
  115.  
  116.     seg1.bytemax = BYTEMAX;
  117.     seg1.segmax = SEGMAX;
  118.     seg1.bytes = 0;
  119.     seg1.segs = 0;
  120.  
  121.     /* process request */
  122.     retval = PINT_process_request(file_state, NULL, &rf1,
  123.                       &seg1, PINT_SERVER);
  124.  
  125.     assert(retval >= 0);
  126.  
  127.     printf("results of PINT_process_request():\n");
  128.     printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes));
  129.     total_bytes_client += seg1.bytes;
  130.     for (i = 0; i < seg1.segs; i++)
  131.     {
  132.         printf("  segment %d: offset: %d size: %d\n",
  133.            i, (int) seg1.offset_array[i], (int) seg1.size_array[i]);
  134.     }
  135.  
  136.     printf("PINT_REQUEST_DONE: %d\n", PINT_REQUEST_DONE(file_state));
  137.     }
  138.  
  139.     return 0;
  140. }
  141.  
  142. /*
  143.  * Local variables:
  144.  *  c-indent-level: 4
  145.  *  c-basic-offset: 4
  146.  * End:
  147.  *
  148.  * vim: ts=8 sts=4 sw=4 expandtab
  149.  */
  150.