photon  1.1
photon_request.h
Go to the documentation of this file.
1 // =============================================================================
2 // Photon RDMA Library (libphoton)
3 //
4 // Copyright (c) 2016, Trustees of Indiana University,
5 // All rights reserved.
6 //
7 // This software may be modified and distributed under the terms of the BSD
8 // license. See the COPYING file for details.
9 //
10 // This software was created at the Indiana University Center for Research in
11 // Extreme Scale Technologies (CREST).
12 // =============================================================================
13 
14 #ifndef PHOTON_REQUEST_H
15 #define PHOTON_REQUEST_H
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include "photon_backend.h"
22 #include "photon_rdma_ledger.h"
24 #include "bit_array/bit_array.h"
25 #include "libsync/locks.h"
26 #include "libsync/queues.h"
27 
28 #define DEF_NR_LEVELS (14) // up to 14 levels of request buffers
29 #define DEF_NUM_REQUESTS (1024) // 1K pre-allocated requests per rank, power of 2
30 #define DEF_MAX_REQUESTS (1<<20) // Allows up to 1M requests per pank
31 
32 #define NULL_REQUEST 0x0
33 #define DEF_MAX_BUF_ENTRIES 64 // The number msgbuf entries for UD mode
34 
35 #define REQUEST_NEW 0x01
36 #define REQUEST_PENDING 0x02
37 #define REQUEST_FAILED 0x03
38 #define REQUEST_COMPLETED 0x04
39 #define REQUEST_FREE 0x05
40 
41 #define REQUEST_COOK_MASK 0xfff00000
42 #define REQUEST_COOK_NIL 0xff000000
43 #define REQUEST_COOK_SEND 0xff100000
44 #define REQUEST_COOK_RECV 0xff200000
45 #define REQUEST_COOK_EAGER 0xff300000
46 #define REQUEST_COOK_ELEDG 0xff400000
47 #define REQUEST_COOK_PLEDG 0xff500000
48 #define REQUEST_COOK_EBUF 0xff600000
49 #define REQUEST_COOK_PBUF 0xff700000
50 #define REQUEST_COOK_FIN 0xff800000
51 #define REQUEST_COOK_SINFO 0xff900000
52 #define REQUEST_COOK_RINFO 0xffa00000
53 #define REQUEST_COOK_GPWC 0xffb00000
54 
55 #define REQUEST_OP_DEFAULT 0x0000
56 #define REQUEST_OP_SENDBUF (1<<1)
57 #define REQUEST_OP_SENDREQ (1<<2)
58 #define REQUEST_OP_SENDFIN (1<<3)
59 #define REQUEST_OP_RECVBUF (1<<4)
60 #define REQUEST_OP_PWC (1<<5)
61 #define REQUEST_OP_COLL (1<<6)
62 
63 #define REQUEST_FLAG_NIL 0x0000
64 #define REQUEST_FLAG_WFIN (1<<1)
65 #define REQUEST_FLAG_EAGER (1<<2)
66 #define REQUEST_FLAG_EDONE (1<<3)
67 #define REQUEST_FLAG_LDONE (1<<4)
68 #define REQUEST_FLAG_NO_LCE (1<<5)
69 #define REQUEST_FLAG_NO_RCE (1<<6)
70 #define REQUEST_FLAG_ROP (1<<7)
71 #define REQUEST_FLAG_1PWC (1<<8)
72 #define REQUEST_FLAG_2PWC (1<<9)
73 #define REQUEST_FLAG_CMD (1<<10)
74 
75 #define MARK_DONE(e,s) (sync_fadd(&e->tail, s, SYNC_RELAXED))
76 #define PROC_REQUEST_ID(p,id) (((uint64_t)p<<32) | id)
77 #define IS_VALID_PROC(p) ((p >= 0) && (p < _photon_nproc))
78 
79 typedef struct photon_req_t {
81  int proc;
82  int tag;
83  uint16_t op;
84  uint16_t type;
85  uint16_t state;
86  uint16_t flags;
87  uint64_t size; // requested size
88  uint32_t psize; // the amount actually sent
89  struct {
90  struct photon_buffer_t buf;
92  } local_info;
93  struct {
94  struct photon_buffer_t buf;
95  photon_cid id;
96  } remote_info;
97  struct {
98  volatile uint16_t events;
99  uint16_t rflags;
100  uint64_t cookie;
101  } rattr;
102  void *ctx;
104 } photon_req;
105 
106 typedef struct photon_req_table_t {
107  uint64_t count;
108  uint64_t next;
109  uint32_t *free;
110  uint32_t size;
111  uint16_t level;
112  struct photon_req_t **reqs;
113  two_lock_queue_t *pwc_q;
114  two_lock_queue_t *gwc_q;
115  two_lock_queue_t *gwc_pwc_q;
116  two_lock_queue_t *comp_q;
117  volatile uint32_t pcount;
118  volatile uint32_t gcount;
119  volatile uint32_t gpcount;
120  tatas_lock_t tloc;
121  tatas_lock_t pq_loc;
122  tatas_lock_t gq_loc;
123  tatas_lock_t pack_loc;
125 
126 typedef struct photon_req_t * photonRequest;
127 typedef struct photon_req_table_t * photonRequestTable;
128 
129 PHOTON_INTERNAL int photon_request_init(photonConfig cfg);
130 PHOTON_INTERNAL photonRequest photon_get_request(int proc);
131 PHOTON_INTERNAL int photon_free_request(photonRequest req);
133 photonRequest photon_lookup_request(photon_rid rid);
134 
135 PHOTON_INTERNAL photonRequest photon_setup_request_direct(photonBuffer lbuf, photonBuffer rbuf, uint64_t size,
136  int proc, int events);
137 PHOTON_INTERNAL photonRequest photon_setup_request_ledger_info(photonRILedgerEntry ri_entry, int curr, int proc);
138 PHOTON_INTERNAL photonRequest photon_setup_request_ledger_eager(photonRDMALedgerEntry l_entry, int curr, int proc);
139 PHOTON_INTERNAL photonRequest photon_setup_request_send(photonAddr addr, int *bufs, int nbufs);
140 PHOTON_INTERNAL photonRequest photon_setup_request_recv(photonAddr addr, int msn, int msize, int bindex, int nbufs);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif
Convenience pointer type for the buffer structure.
Definition: photon.h:105
tatas_lock_t pq_loc
The Photon completion ID used by the PWC API.
Definition: photon.h:78
two_lock_queue_t * gwc_q
volatile uint32_t pcount
struct photon_ri_ledger_entry_t * photonRILedgerEntry
PHOTON_INTERNAL int photon_request_init(photonConfig cfg)
photon_cid_hdr chdr
PHOTON_INTERNAL photonRequest photon_setup_request_ledger_info(photonRILedgerEntry ri_entry, int curr, int proc)
volatile uint16_t events
two_lock_queue_t * pwc_q
photon_rid id
struct photon_req_t ** reqs
tatas_lock_t tloc
uint64_t cookie
struct photon_rdma_ledger_entry_t * photonRDMALedgerEntry
volatile uint32_t gcount
uint16_t flags
struct photon_req_table_t * photonRequestTable
uint64_t photon_rid
The Photon request ID.
Definition: photon.h:75
photonRequest photon_lookup_request(photon_rid rid)
tatas_lock_t gq_loc
PHOTON_INTERNAL photonRequest photon_get_request(int proc)
two_lock_queue_t * comp_q
PHOTON_INTERNAL int photon_count_request(int proc)
photon_cid id
uint64_t size
union photon_addr_t * photonAddr
Convenience pointer type for the address union.
Definition: photon.h:112
uint16_t op
tatas_lock_t pack_loc
PHOTON_INTERNAL photonRequest photon_setup_request_direct(photonBuffer lbuf, photonBuffer rbuf, uint64_t size, int proc, int events)
struct photon_req_t * photonRequest
uint16_t rflags
uint16_t type
#define PHOTON_INTERNAL
uint32_t psize
PHOTON_INTERNAL photonRequest photon_setup_request_recv(photonAddr addr, int msn, int msize, int bindex, int nbufs)
volatile uint32_t gpcount
uint16_t state
PHOTON_INTERNAL photonRequest photon_setup_request_ledger_eager(photonRDMALedgerEntry l_entry, int curr, int proc)
two_lock_queue_t * gwc_pwc_q
PHOTON_INTERNAL photonRequest photon_setup_request_send(photonAddr addr, int *bufs, int nbufs)
PHOTON_INTERNAL int photon_free_request(photonRequest req)