| 1 | /** @file Split buffer implementation. |
| 2 | * @author Sriram Krishnamoorthy |
| 3 | * |
| 4 | * Supports multiple short/immediate buffers posted per client and a |
| 5 | * client-independent number of buffers to handle large messages. |
| 6 | */ |
| 7 | #ifndef _PENDBUFS_H_ |
| 8 | #define _PENDBUFS_H_ |
| 9 | |
| 10 | #if defined(PEND_BUFS) |
| 11 | |
| 12 | #include "armcip.h" |
| 13 | #include "request.h" |
| 14 | |
| 15 | #define PBUF_RGUARD_SIZE 256 |
| 16 | |
| 17 | /**The buf should be the first field in immbuf_t and pendbuf_t. For |
| 18 | example, look at openib.c:armci_rcv_req and maybe other places*/ |
| 19 | typedef struct immbuf_t { |
| 20 | char *buf; /*immediate buffer[IMMBUF_LEN]*/ |
| 21 | /* IMMBUF_NW_T fields; */ |
| 22 | char rguard[PBUF_RGUARD_SIZE]; |
| 23 | IMMBUF_NW_T |
| 24 | struct immbuf_t *immbuf_list_next; |
| 25 | } immbuf_t; |
| 26 | |
| 27 | typedef struct pendbuf_t { |
| 28 | char *buf; /*pending buffer[PENDBUF_LEN]*/ |
| 29 | /* PENDBUF_NW_T fields; */ |
| 30 | char rguard[PBUF_RGUARD_SIZE]; |
| 31 | PENDBUF_NW_T |
| 32 | int status; /*<Finite State Machine status*/ |
| 33 | int avail; /*<Buffer is available*/ |
| 34 | immbuf_t *vbuf; /*<Immediate buffer corresponding to this pending buffer*/ |
| 35 | struct pendbuf_t *order_next,*order_prev; /*Order among pending buffers processing requests from same client*/ |
| 36 | int commit_me; /*This buffer needs to be committed (by calling |
| 37 | progresson it)*/ |
| 38 | } pendbuf_t; |
| 39 | |
| 40 | int get_immbuf_len(); |
| 41 | int get_immbuf_num(); |
| 42 | int get_pendbuf_len(); |
| 43 | int get_pendbuf_num(); |
| 44 | #define IMM_BUF_LEN get_immbuf_len() |
| 45 | #define PENDING_BUF_LEN get_pendbuf_len() |
| 46 | #define IMM_BUF_NUM get_immbuf_num() |
| 47 | #define PENDING_BUF_NUM get_pendbuf_num() |
| 48 | |
| 49 | /*Initialize number and length of pending and initialized |
| 50 | * buffers. Called when initializing the network connections |
| 51 | */ |
| 52 | void armci_pbuf_init_buffer_env(); |
| 53 | |
| 54 | /*----------------Stuff to enforce server-side ordering----------------*/ |
| 55 | |
| 56 | /**Ordering rules. Each is (usually) more relaxed than the one |
| 57 | * above. Change order with care. |
| 58 | */ |
| 59 | enum PendBufOrderingRule { |
| 60 | ONE_PBUF_MESG, /**<Only one pending mesg progressed at any time*/ |
| 61 | ONE_PBUF_MESG_PER_PROC,/**<One pending mesg per client proc*/ |
| 62 | ACC_NO_ORDER, /**<Consecutive ACCs from same client proc |
| 63 | can overlap*/ |
| 64 | PUTACC_SPLIT_ORDER, /**<ACC_NO_ORDER+concurrent get of data from |
| 65 | client for non-immediate PUTs*/ |
| 66 | GET_GET_REORDER /**<PUTACC_SPLIT_ORDER+two consecutive GETs can |
| 67 | progress out-of-order*/ |
| 68 | }; |
| 69 | |
| 70 | |
| 71 | extern pendbuf_t *serv_pendbuf_arr; /**<Array of pending buffers*/ |
| 72 | |
| 73 | void armci_pendbuf_service_req(immbuf_t *immbuf); |
| 74 | void armci_pendbuf_init(); |
| 75 | void armci_pendbuf_done_put(int pbufid); |
| 76 | void armci_pendbuf_done_get(int pbufid); |
| 77 | |
| 78 | #endif /*PEND_BUFS*/ |
| 79 | #endif /*_PENDBUFS_H_*/ |
| 80 |