1fi_cntr(3)                     Libfabric v1.7.0                     fi_cntr(3)
2
3
4

NAME

6       fi_cntr - Completion and event counter operations
7
8       fi_cntr_open / fi_close
9              Allocate/free a counter
10
11       fi_cntr_read
12              Read the current value of a counter
13
14       fi_cntr_readerr
15              Reads the number of operations which have completed in error.
16
17       fi_cntr_add
18              Increment a counter by a specified value
19
20       fi_cntr_set
21              Set a counter to a specified value
22
23       fi_cntr_wait
24              Wait for a counter to be greater or equal to a threshold value
25

SYNOPSIS

27              #include <rdma/fi_domain.h>
28
29              int fi_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
30                  struct fid_cntr **cntr, void *context);
31
32              int fi_close(struct fid *cntr);
33
34              uint64_t fi_cntr_read(struct fid_cntr *cntr);
35
36              uint64_t fi_cntr_readerr(struct fid_cntr *cntr);
37
38              int fi_cntr_add(struct fid_cntr *cntr, uint64_t value);
39
40              int fi_cntr_adderr(struct fid_cntr *cntr, uint64_t value);
41
42              int fi_cntr_set(struct fid_cntr *cntr, uint64_t value);
43
44              int fi_cntr_seterr(struct fid_cntr *cntr, uint64_t value);
45
46              int fi_cntr_wait(struct fid_cntr *cntr, uint64_t threshold,
47                  int timeout);
48

ARGUMENTS

50       domain Fabric domain
51
52       cntr   Fabric counter
53
54       attr   Counter attributes
55
56       context
57              User specified context associated with the counter
58
59       value  Value to increment or set counter
60
61       threshold
62              Value to compare counter against
63
64       timeout
65              Time  in milliseconds to wait.  A negative value indicates infi‐
66              nite timeout.
67

DESCRIPTION

69       Counters record the number of requested operations that have completed.
70       Counters can provide a light-weight completion mechanism by suppressing
71       the generation of a full completion event.  They are useful for  appli‐
72       cations  that  only  need to know the number of requests that have com‐
73       pleted, and not details about each request.  For example, counters  may
74       be  useful  for  implementing credit based flow control or tracking the
75       number of remote processes which have responded to a request.
76
77       Counters typically only count successful completions.  However,  if  an
78       operation completes in error, it may increment an associated error val‐
79       ue.  That is, a counter actually stores two distinct values, with error
80       completions updating an error specific value.
81
82   fi_cntr_open
83       fi_cntr_open allocates a new fabric counter.  The properties and behav‐
84       ior of the counter are defined by struct fi_cntr_attr.
85
86              struct fi_cntr_attr {
87                  enum fi_cntr_events  events;    /* type of events to count */
88                  enum fi_wait_obj     wait_obj;  /* requested wait object */
89                  struct fid_wait     *wait_set;  /* optional wait set */
90                  uint64_t             flags;     /* operation flags */
91              };
92
93       events A counter captures different types of events.  The specific type
94              which is to counted are one of the following:
95
96       - FI_CNTR_EVENTS_COMP
97              The  counter increments for every successful completion that oc‐
98              curs on an associated bound endpoint.  The type  of  completions
99              --  sends and/or receives -- which are counted may be restricted
100              using control flags when binding the counter and  the  endpoint.
101              Counters  increment  on  all  successful completions, separately
102              from whether the operation generates an entry in an event queue.
103
104       wait_obj
105              Counters may be associated with a specific  wait  object.   Wait
106              objects  allow  applications  to  block until the wait object is
107              signaled, indicating that  a  counter  has  reached  a  specific
108              threshold.   Users may use fi_control to retrieve the underlying
109              wait object associated with a counter, in order  to  use  it  in
110              other system calls.  The following values may be used to specify
111              the type of wait object associated with a counter: FI_WAIT_NONE,
112              FI_WAIT_UNSPEC, FI_WAIT_SET, FI_WAIT_FD, and FI_WAIT_MUTEX_COND.
113              The default is FI_WAIT_NONE.
114
115       - FI_WAIT_NONE
116              Used to indicate that the user will not block (wait) for  events
117              on the counter.
118
119       - FI_WAIT_UNSPEC
120              Specifies that the user will only wait on the counter using fab‐
121              ric interface calls, such as fi_cntr_wait.  In  this  case,  the
122              underlying  provider  may select the most appropriate or highest
123              performing wait object available, including custom  wait  mecha‐
124              nisms.   Applications that select FI_WAIT_UNSPEC are not guaran‐
125              teed to retrieve the underlying wait object.
126
127       - FI_WAIT_SET
128              Indicates that the event counter should use a wait set object to
129              wait  for  events.  If specified, the wait_set field must refer‐
130              ence an existing wait set object.
131
132       - FI_WAIT_FD
133              Indicates that the counter should use a file descriptor  as  its
134              wait mechanism.  A file descriptor wait object must be usable in
135              select, poll, and epoll routines.  However, a provider may  sig‐
136              nal  an  FD  wait object by marking it as readable, writable, or
137              with an error.
138
139       - FI_WAIT_MUTEX_COND
140              Specifies that the counter should use a pthread mutex  and  cond
141              variable as a wait object.
142
143       wait_set
144              If  wait_obj is FI_WAIT_SET, this field references a wait object
145              to which the event counter should  attach.   When  an  event  is
146              added  to  the event counter, the corresponding wait set will be
147              signaled if all necessary conditions are  met.   The  use  of  a
148              wait_set  enables  an  optimized  method  of  waiting for events
149              across multiple  event  counters.   This  field  is  ignored  if
150              wait_obj is not FI_WAIT_SET.
151
152       flags  Flags are reserved for future use, and must be set to 0.
153
154   fi_close
155       The  fi_close  call  releases  all resources associated with a counter.
156       When closing the counter, there must be no opened  endpoints,  transmit
157       contexts,  receive  contexts  or  memory  regions  associated  with the
158       counter.  If resources are still associated with the counter  when  at‐
159       tempting to close, the call will return -FI_EBUSY.
160
161   fi_cntr_control
162       The  fi_cntr_control  call is used to access provider or implementation
163       specific details of the counter.  Access to the counter should be seri‐
164       alized  across all calls when fi_cntr_control is invoked, as it may re‐
165       direct the implementation of counter operations.  The following control
166       commands are usable with a counter:
167
168       FI_GETOPSFLAG (uint64_t *)
169              Returns  the  current  default operational flags associated with
170              the counter.
171
172       FI_SETOPSFLAG (uint64_t *)
173              Modifies the current default operational flags  associated  with
174              the counter.
175
176       FI_GETWAIT (void **)
177              This  command allows the user to retrieve the low-level wait ob‐
178              ject associated with the counter.  The format of the wait-object
179              is  specified  during  counter creation, through the counter at‐
180              tributes.  See fi_eq.3 for addition details using  control  with
181              FI_GETWAIT.
182
183   fi_cntr_read
184       The fi_cntr_read call returns the current value of the counter.
185
186   fi_cntr_readerr
187       The  read error call returns the number of operations that completed in
188       error and were unable to update the counter.
189
190   fi_cntr_add
191       This adds the user-specified value to the counter.
192
193   fi_cntr_adderr
194       This adds the user-specified value to the error value of the counter.
195
196   fi_cntr_set
197       This sets the counter to the specified value.
198
199   fi_cntr_seterr
200       This sets the error value of the counter to the specified value.
201
202   fi_cntr_wait
203       This call may be used to wait until the counter reaches  the  specified
204       threshold, or until an error or timeout occurs.  Upon successful return
205       from this call, the counter will be greater than or equal to the  input
206       threshold value.
207
208       If  an  operation  associated  with the counter encounters an error, it
209       will increment the error value associated with the counter.  Any change
210       in a counter's error value will unblock any thread inside fi_cntr_wait.
211
212       If  the  call  returns  due to timeout, -FI_ETIMEDOUT will be returned.
213       The error value associated with the counter remains unchanged.
214
215       It is invalid for applications to call this function if the counter has
216       been configured with a wait object of FI_WAIT_NONE or FI_WAIT_SET.
217

RETURN VALUES

219       Returns 0 on success.  On error, a negative value corresponding to fab‐
220       ric errno is returned.
221
222       fi_cntr_read / fi_cntr_readerr
223              Returns the current value of the counter.
224
225       Fabric errno values are defined in rdma/fi_errno.h.
226

NOTES

228       In order to support a variety of counter implementations, updates  made
229       to counter values (e.g.  fi_cntr_set or fi_cntr_add) may not be immedi‐
230       ately visible to counter read operations (i.e.  fi_cntr_read or  fi_cn‐
231       tr_readerr).   A  small,  but  undefined,  delay  may occur between the
232       counter changing and the reported value being updated.  However, a  fi‐
233       nal updated value will eventually be reflected in the read counter val‐
234       ue.
235
236       Additionally, applications should ensure that the value of a counter is
237       stable and not subject to change prior to calling fi_cntr_set or fi_cn‐
238       tr_seterr.  Otherwise, the resulting value of the counter after  fi_cn‐
239       tr_set  / fi_cntr_seterr is undefined, as updates to the counter may be
240       lost.  A counter value is considered stable if all previous updates us‐
241       ing  fi_cntr_set / fi_cntr_seterr and results of related operations are
242       reflected in the observed value of the counter.
243

SEE ALSO

245       fi_getinfo(3), fi_endpoint(3), fi_domain(3), fi_eq(3), fi_poll(3)
246

AUTHORS

248       OpenFabrics.
249
250
251
252Libfabric Programmer's Manual     2018-10-05                        fi_cntr(3)
Impressum