1 /*
2  * Copyright (c) 2016-2017 Cray Inc. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <errno.h>
36 #include <getopt.h>
37 #include <poll.h>
38 #include <time.h>
39 #include <string.h>
40 #include <pthread.h>
41 #include <unistd.h>
42 #include <limits.h>
43 #include <assert.h>
44 
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <inttypes.h>
48 
49 #include <criterion/criterion.h>
50 #include "gnix_rdma_headers.h"
51 #include "fi_ext_gni.h"
52 #include "common.h"
53 
54 #if 1
55 #define dbg_printf(...)
56 #else
57 #define dbg_printf(...)				\
58 	do {					\
59 		printf(__VA_ARGS__);		\
60 		fflush(stdout);			\
61 	} while (0)
62 #endif
63 
64 #define NUMEPS 2
65 
66 /* Note: Set to ~FI_NOTIFY_FLAGS_ONLY since this was written before api 1.5 */
67 static uint64_t mode_bits = ~FI_NOTIFY_FLAGS_ONLY;
68 static struct fid_fabric *fab;
69 static struct fid_domain *dom[NUMEPS];
70 struct fi_gni_ops_domain *gni_domain_ops[NUMEPS];
71 static struct fid_ep *ep[NUMEPS];
72 static struct fid_av *av[NUMEPS];
73 void *ep_name[NUMEPS];
74 fi_addr_t gni_addr[NUMEPS];
75 static struct fi_info *fi[NUMEPS];
76 struct fi_info *hints[NUMEPS];
77 
78 #define BUF_SZ (1<<20)
79 char *target, *target_base;
80 char *source, *source_base;
81 char *uc_target;
82 char *uc_source;
83 struct fid_mr *rem_mr[NUMEPS], *loc_mr[NUMEPS];
84 uint64_t mr_key[NUMEPS];
85 uint64_t cntr_bind_flags;
86 
87 static struct fid_cntr *send_cntr[NUMEPS], *recv_cntr[NUMEPS];
88 static struct fid_cntr *write_cntr[NUMEPS], *read_cntr[NUMEPS];
89 static struct fi_cntr_attr cntr_attr = {
90 	.events = FI_CNTR_EVENTS_COMP,
91 	.flags = 0
92 };
93 
94 #define RMA_WRITE_ALLOWED(flags) \
95 	(flags & FI_WRITE)
96 #define RMA_READ_ALLOWED(flags) \
97 	(flags & FI_READ)
98 #define MSG_SEND_ALLOWED(flags) \
99 	(flags & FI_SEND)
100 #define MSG_RECV_ALLOWED(flags) \
101 	(flags & FI_RECV)
102 
api_cntr_bind(uint64_t flags)103 void api_cntr_bind(uint64_t flags)
104 {
105 	int ret, i;
106 
107 	for (i = 0; i < NUMEPS; i++) {
108 		if (RMA_WRITE_ALLOWED(flags)) {
109 			ret = fi_ep_bind(ep[i], &write_cntr[i]->fid, FI_WRITE);
110 			cr_assert(!ret, "fi_ep_bind");
111 		}
112 
113 		if (RMA_READ_ALLOWED(flags)) {
114 			ret = fi_ep_bind(ep[i], &read_cntr[i]->fid, FI_READ);
115 			cr_assert(!ret, "fi_ep_bind");
116 		}
117 
118 		if (MSG_SEND_ALLOWED(flags)) {
119 			ret = fi_ep_bind(ep[i], &send_cntr[i]->fid, FI_SEND);
120 			cr_assert(!ret, "fi_ep_bind");
121 		}
122 
123 		if (MSG_RECV_ALLOWED(flags)) {
124 			ret = fi_ep_bind(ep[i], &recv_cntr[i]->fid, FI_RECV);
125 			cr_assert(!ret, "fi_ep_bind");
126 		}
127 
128 		ret = fi_enable(ep[i]);
129 		cr_assert(!ret, "fi_enable");
130 	}
131 }
132 
__api_cntr_setup(uint32_t version,int mr_mode)133 static inline void __api_cntr_setup(uint32_t version, int mr_mode)
134 {
135 	int ret, i, j;
136 	struct fi_av_attr attr = {0};
137 	size_t addrlen = 0;
138 
139 	for (i = 0; i < NUMEPS; i++) {
140 		hints[i] = fi_allocinfo();
141 		cr_assert(hints[i], "fi_allocinfo");
142 
143 		hints[i]->domain_attr->data_progress = FI_PROGRESS_AUTO;
144 		hints[i]->mode = mode_bits;
145 		hints[i]->fabric_attr->prov_name = strdup("gni");
146 		hints[i]->domain_attr->mr_mode = mr_mode;
147 	}
148 
149 	/* Get info about fabric services with the provided hints */
150 	for (i = 0; i < NUMEPS; i++) {
151 		ret = fi_getinfo(version, NULL, 0, 0, hints[i],
152 				 &fi[i]);
153 		cr_assert(!ret, "fi_getinfo");
154 	}
155 
156 	attr.type = FI_AV_MAP;
157 	attr.count = NUMEPS;
158 
159 	/* 3x BUF_SZ for multi recv testing */
160 	target_base = malloc(GNIT_ALIGN_LEN(BUF_SZ * 3));
161 	assert(target_base);
162 	target = GNIT_ALIGN_BUFFER(char *, target_base);
163 
164 	source_base = malloc(GNIT_ALIGN_LEN(BUF_SZ));
165 	assert(source_base);
166 	source = GNIT_ALIGN_BUFFER(char *, source_base);
167 
168 	uc_target = malloc(BUF_SZ);
169 	assert(uc_target);
170 
171 	uc_source = malloc(BUF_SZ);
172 	assert(uc_source);
173 
174 	ret = fi_fabric(fi[0]->fabric_attr, &fab, NULL);
175 	cr_assert(!ret, "fi_fabric");
176 
177 	for (i = 0; i < NUMEPS; i++) {
178 		ret = fi_domain(fab, fi[i], dom + i, NULL);
179 		cr_assert(!ret, "fi_domain");
180 
181 		ret = fi_open_ops(&dom[i]->fid, FI_GNI_DOMAIN_OPS_1,
182 				  0, (void **) (gni_domain_ops + i), NULL);
183 
184 		ret = fi_av_open(dom[i], &attr, av + i, NULL);
185 		cr_assert(!ret, "fi_av_open");
186 
187 		ret = fi_endpoint(dom[i], fi[i], ep + i, NULL);
188 		cr_assert(!ret, "fi_endpoint");
189 
190 		ret = fi_cntr_open(dom[i], &cntr_attr, write_cntr + i, 0);
191 		cr_assert(!ret, "fi_cntr_open");
192 
193 		ret = fi_cntr_open(dom[i], &cntr_attr, read_cntr + i, 0);
194 		cr_assert(!ret, "fi_cntr_open");
195 
196 		ret = fi_cntr_open(dom[i], &cntr_attr, send_cntr + i, 0);
197 		cr_assert(!ret, "fi_cntr_open");
198 
199 		ret = fi_cntr_open(dom[i], &cntr_attr, recv_cntr + i, 0);
200 		cr_assert(!ret, "fi_cntr_open");
201 
202 		ret = fi_getname(&ep[i]->fid, NULL, &addrlen);
203 		cr_assert(addrlen > 0);
204 
205 		ep_name[i] = malloc(addrlen);
206 		cr_assert(ep_name[i] != NULL);
207 
208 		ret = fi_getname(&ep[i]->fid, ep_name[i], &addrlen);
209 		cr_assert(ret == FI_SUCCESS);
210 	}
211 
212 	for (i = 0; i < NUMEPS; i++) {
213 		/* Insert all gni addresses into each av */
214 		for (j = 0; j < NUMEPS; j++) {
215 			ret = fi_av_insert(av[i], ep_name[j], 1, &gni_addr[j],
216 					   0, NULL);
217 			cr_assert(ret == 1);
218 		}
219 
220 		ret = fi_ep_bind(ep[i], &av[i]->fid, 0);
221 		cr_assert(!ret, "fi_ep_bind");
222 
223 	}
224 
225 	 for (i = 0; i < NUMEPS; i++) {
226 		int target_requested_key =
227 			USING_SCALABLE(fi[i]) ? (i * 2) : 0;
228 		int source_requested_key =
229 			USING_SCALABLE(fi[i]) ? (i * 2) + 1 : 0;
230 
231 		ret = fi_mr_reg(dom[i],
232 				  target,
233 				  3 * BUF_SZ,
234 				  FI_REMOTE_WRITE,
235 				  0,
236 				  target_requested_key,
237 				  0,
238 				  rem_mr + i,
239 				  &target);
240 		cr_assert_eq(ret, 0);
241 
242 		ret = fi_mr_reg(dom[i],
243 				  source,
244 				  BUF_SZ,
245 				  FI_REMOTE_WRITE,
246 				  0,
247 				  source_requested_key,
248 				  0,
249 				  loc_mr + i,
250 				  &source);
251 		cr_assert_eq(ret, 0);
252 
253 		if (USING_SCALABLE(fi[i])) {
254 			MR_ENABLE(rem_mr[i], target, 3 * BUF_SZ);
255 			MR_ENABLE(loc_mr[i], source, BUF_SZ);
256 		}
257 		mr_key[i] = fi_mr_key(rem_mr[i]);
258 	}
259 }
260 
api_cntr_setup_basic(void)261 static void api_cntr_setup_basic(void)
262 {
263 	__api_cntr_setup(fi_version(), GNIX_MR_BASIC);
264 }
265 
api_cntr_setup_scalable(void)266 static void api_cntr_setup_scalable(void)
267 {
268 	__api_cntr_setup(fi_version(), GNIX_MR_SCALABLE);
269 }
270 
api_cntr_teardown_common(bool unreg)271 static void api_cntr_teardown_common(bool unreg)
272 {
273 	int ret = 0, i = 0;
274 
275 	for (; i < NUMEPS; i++) {
276 		fi_close(&write_cntr[i]->fid);
277 		fi_close(&read_cntr[i]->fid);
278 		fi_close(&send_cntr[i]->fid);
279 		fi_close(&recv_cntr[i]->fid);
280 
281 		if (unreg) {
282 			fi_close(&loc_mr[i]->fid);
283 			fi_close(&rem_mr[i]->fid);
284 		}
285 
286 		ret = fi_close(&ep[i]->fid);
287 		cr_assert(!ret, "failure in closing ep.");
288 
289 		ret = fi_close(&av[i]->fid);
290 		cr_assert(!ret, "failure in closing av.");
291 
292 		ret = fi_close(&dom[i]->fid);
293 		cr_assert(!ret, "failure in closing domain.");
294 
295 		fi_freeinfo(fi[i]);
296 		free(ep_name[i]);
297 		fi_freeinfo(hints[i]);
298 	}
299 
300 	free(uc_source);
301 	free(uc_target);
302 	free(target_base);
303 	free(source_base);
304 
305 	ret = fi_close(&fab->fid);
306 	cr_assert(!ret, "failure in closing fabric.");
307 }
308 
api_cntr_teardown(void)309 static void api_cntr_teardown(void)
310 {
311 	api_cntr_teardown_common(true);
312 }
313 
api_cntr_init_data(char * buf,int len,char seed)314 void api_cntr_init_data(char *buf, int len, char seed)
315 {
316 	int i;
317 
318 	for (i = 0; i < len; i++)
319 		buf[i] = seed++;
320 }
321 
api_cntr_check_data(char * buf1,char * buf2,int len)322 int api_cntr_check_data(char *buf1, char *buf2, int len)
323 {
324 	int i;
325 
326 	for (i = 0; i < len; i++) {
327 		if (buf1[i] != buf2[i]) {
328 			printf("data mismatch, elem: %d, exp: %hhx, act: %hhx\n"
329 			       , i, buf1[i], buf2[i]);
330 			return 0;
331 		}
332 	}
333 
334 	return 1;
335 }
336 
api_cntr_write_allowed(ssize_t sz,uint64_t flags,char * fn)337 void api_cntr_write_allowed(ssize_t sz, uint64_t flags, char *fn)
338 {
339 	if (RMA_WRITE_ALLOWED(flags)) {
340 		cr_assert(sz == 0, "%s failed flags:0x%lx sz:%ld",
341 			  fn, flags, sz);
342 	} else {
343 		cr_assert(sz < 0, "%s should fail flags:0x%lx sz:%ld",
344 			  fn, flags, sz);
345 	}
346 }
347 
api_cntr_read_allowed(ssize_t sz,uint64_t flags,char * fn)348 void api_cntr_read_allowed(ssize_t sz, uint64_t flags, char *fn)
349 {
350 	if (RMA_READ_ALLOWED(cntr_bind_flags)) {
351 		cr_assert(sz == 0, "%s failed flags:0x%lx sz:%ld",
352 			  fn, flags, sz);
353 	} else {
354 		cr_assert(sz < 0, "%s should fail flags:0x%lx sz:%ld",
355 			  fn, flags, sz);
356 	}
357 }
358 
api_cntr_send_allowed(ssize_t sz,uint64_t flags,char * fn)359 void api_cntr_send_allowed(ssize_t sz, uint64_t flags, char *fn)
360 {
361 	if (MSG_SEND_ALLOWED(flags)) {
362 		cr_assert(sz == 0, "%s failed flags:0x%lx sz:%ld",
363 			  fn, flags, sz);
364 	} else {
365 		cr_assert(sz < 0, "%s should fail flags:0x%lx sz:%ld",
366 			  fn, flags, sz);
367 	}
368 }
369 
api_cntr_recv_allowed(ssize_t sz,uint64_t flags,char * fn)370 void api_cntr_recv_allowed(ssize_t sz, uint64_t flags, char *fn)
371 {
372 	if (MSG_RECV_ALLOWED(cntr_bind_flags)) {
373 		cr_assert(sz == 0, "%s failed flags:0x%lx sz:%ld",
374 			  fn, flags, sz);
375 	} else {
376 		cr_assert(sz < 0, "%s should fail flags:0x%lx sz:%ld",
377 			  fn, flags, sz);
378 	}
379 }
380 
381 TestSuite(api_cntr_basic,
382 	  .init = api_cntr_setup_basic,
383 	  .fini = api_cntr_teardown,
384 	  .disabled = false);
385 
386 TestSuite(api_cntr_scalable,
387 	  .init = api_cntr_setup_scalable,
388 	  .fini = api_cntr_teardown,
389 	  .disabled = false);
390 
api_cntr_send_recv(int len)391 void api_cntr_send_recv(int len)
392 {
393 	ssize_t sz;
394 
395 	api_cntr_init_data(source, len, 0xab);
396 	api_cntr_init_data(target, len, 0);
397 
398 	sz = fi_send(ep[0], source, len, loc_mr[0], gni_addr[1], target);
399 	api_cntr_send_allowed(sz, cntr_bind_flags, "fi_send");
400 
401 	sz = fi_recv(ep[1], target, len, rem_mr[1], gni_addr[0], source);
402 	api_cntr_recv_allowed(sz, cntr_bind_flags, "fi_recv");
403 }
404 
api_cntr_write_read(int len)405 void api_cntr_write_read(int len)
406 {
407 	ssize_t sz;
408 	struct iovec iov;
409 	struct fi_msg_rma rma_msg;
410 	struct fi_rma_iov rma_iov;
411 
412 	api_cntr_init_data(source, len, 0xab);
413 	api_cntr_init_data(target, len, 0);
414 
415 	iov.iov_base = NULL;
416 	iov.iov_len = 0;
417 
418 	sz = fi_write(ep[0], source, len,
419 		      loc_mr[0], gni_addr[1], (uint64_t)target, mr_key[1],
420 		      target);
421 	api_cntr_write_allowed(sz, cntr_bind_flags, "fi_write");
422 
423 	sz = fi_writev(ep[0], &iov, (void **)loc_mr, 1,
424 		       gni_addr[1], (uint64_t)target, mr_key[1],
425 		       target);
426 	api_cntr_write_allowed(sz, cntr_bind_flags, "fi_writev");
427 
428 	iov.iov_len = len;
429 	iov.iov_base = source;
430 
431 	rma_iov.addr = (uint64_t)target;
432 	rma_iov.len = len;
433 	rma_iov.key = mr_key[1];
434 	rma_msg.msg_iov = &iov;
435 	rma_msg.desc = (void **)loc_mr;
436 	rma_msg.iov_count = 1;
437 	rma_msg.addr = gni_addr[1];
438 	rma_msg.rma_iov = &rma_iov;
439 	rma_msg.rma_iov_count = 1;
440 	rma_msg.context = target;
441 	rma_msg.data = (uint64_t)target;
442 
443 	sz = fi_writemsg(ep[0], &rma_msg, 0);
444 	api_cntr_write_allowed(sz, cntr_bind_flags, "fi_writemsg");
445 
446 #define WRITE_DATA 0x5123da1a145
447 	sz = fi_writedata(ep[0], source, len, loc_mr[0], WRITE_DATA,
448 			  gni_addr[1], (uint64_t)target, mr_key[1],
449 			  target);
450 	api_cntr_write_allowed(sz, cntr_bind_flags, "fi_writedata");
451 
452 #define READ_CTX 0x4e3dda1aULL
453 	sz = fi_read(ep[0], source, len,
454 		     loc_mr[0], gni_addr[1], (uint64_t)target, mr_key[1],
455 		     (void *)READ_CTX);
456 	api_cntr_read_allowed(sz, cntr_bind_flags, "fi_read");
457 
458 	sz = fi_readv(ep[0], &iov, (void **)loc_mr, 1,
459 		      gni_addr[1], (uint64_t)target, mr_key[1],
460 		      target);
461 	api_cntr_read_allowed(sz, cntr_bind_flags, "fi_readv");
462 
463 	sz = fi_readmsg(ep[0], &rma_msg, 0);
464 	api_cntr_read_allowed(sz, cntr_bind_flags, "fi_readmsg");
465 
466 	sz = fi_inject_write(ep[0], source, 64,
467 			     gni_addr[1], (uint64_t)target, mr_key[1]);
468 	cr_assert_eq(sz, 0);
469 }
470 
__msg(void)471 static inline void __msg(void)
472 {
473 	cntr_bind_flags = FI_SEND | FI_RECV;
474 	api_cntr_bind(cntr_bind_flags);
475 	api_cntr_send_recv(BUF_SZ);
476 }
477 
Test(api_cntr_basic,msg)478 Test(api_cntr_basic, msg)
479 {
480 	__msg();
481 }
482 
__msg_send_only(void)483 static inline void __msg_send_only(void)
484 {
485 	cntr_bind_flags = FI_SEND;
486 	api_cntr_bind(cntr_bind_flags);
487 	api_cntr_send_recv(BUF_SZ);
488 }
489 
Test(api_cntr_basic,msg_send_only)490 Test(api_cntr_basic, msg_send_only)
491 {
492 	__msg_send_only();
493 }
494 
__msg_recv_only(void)495 static inline void __msg_recv_only(void)
496 {
497 	cntr_bind_flags = FI_RECV;
498 	api_cntr_bind(cntr_bind_flags);
499 	api_cntr_send_recv(BUF_SZ);
500 }
501 
Test(api_cntr_basic,msg_recv_only)502 Test(api_cntr_basic, msg_recv_only)
503 {
504 	__msg_recv_only();
505 }
506 
__msg_no_cntr(void)507 static inline void __msg_no_cntr(void)
508 {
509 	cntr_bind_flags = 0;
510 	api_cntr_bind(cntr_bind_flags);
511 	api_cntr_send_recv(BUF_SZ);
512 }
513 
Test(api_cntr_basic,msg_no_cntr)514 Test(api_cntr_basic, msg_no_cntr)
515 {
516 	__msg_no_cntr();
517 }
518 
519 
__rma(void)520 static inline void __rma(void)
521 {
522 	cntr_bind_flags = FI_WRITE | FI_READ;
523 	api_cntr_bind(cntr_bind_flags);
524 	api_cntr_write_read(BUF_SZ);
525 }
526 
Test(api_cntr_basic,rma)527 Test(api_cntr_basic, rma)
528 {
529 	__rma();
530 }
531 
__rma_write_only(void)532 static inline void __rma_write_only(void)
533 {
534 	cntr_bind_flags = FI_WRITE;
535 	api_cntr_bind(cntr_bind_flags);
536 	api_cntr_write_read(BUF_SZ);
537 }
538 
Test(api_cntr_basic,rma_write_only)539 Test(api_cntr_basic, rma_write_only)
540 {
541 	__rma_write_only();
542 }
543 
__rma_read_only(void)544 static inline void __rma_read_only(void)
545 {
546 	cntr_bind_flags = FI_READ;
547 	api_cntr_bind(cntr_bind_flags);
548 	api_cntr_write_read(BUF_SZ);
549 }
550 
Test(api_cntr_basic,rma_read_only)551 Test(api_cntr_basic, rma_read_only)
552 {
553 	__rma_read_only();
554 }
555 
__rma_no_cntr(void)556 static inline void __rma_no_cntr(void)
557 {
558 	cntr_bind_flags = 0;
559 	api_cntr_bind(cntr_bind_flags);
560 	api_cntr_send_recv(BUF_SZ);
561 }
562 
Test(api_cntr_basic,rma_no_cntr)563 Test(api_cntr_basic, rma_no_cntr)
564 {
565 	__rma_no_cntr();
566 }
567 
568 #define SOURCE_DATA	0xBBBB0000CCCCULL
569 #define TARGET_DATA	0xAAAA0000DDDDULL
570 #define FETCH_SOURCE_DATA	0xACEDACEDULL
571 
api_cntr_atomic(void)572 void api_cntr_atomic(void)
573 {
574 	ssize_t sz;
575 
576 	/* u64 */
577 	*((uint64_t *)source) = SOURCE_DATA;
578 	*((uint64_t *)target) = TARGET_DATA;
579 	sz = fi_atomic(ep[0], source, 1, loc_mr[0],
580 		       gni_addr[1], (uint64_t)target, mr_key[1],
581 		       FI_UINT64, FI_ATOMIC_WRITE, target);
582 	api_cntr_write_allowed(sz, cntr_bind_flags, "fi_atomic");
583 
584 	*((uint64_t *)source) = SOURCE_DATA;
585 	*((uint64_t *)target) = TARGET_DATA;
586 	sz = fi_fetch_atomic(ep[0], source, 1, loc_mr[0],
587 			     source, loc_mr[0],
588 			     gni_addr[1], (uint64_t)target, mr_key[1],
589 			     FI_UINT64, FI_ATOMIC_WRITE, target);
590 	api_cntr_read_allowed(sz, cntr_bind_flags, "fi_atomic");
591 
592 	sz = fi_inject_atomic(ep[0], source, 1,
593 			      gni_addr[1], (uint64_t)target, mr_key[1],
594 			      FI_INT64, FI_MIN);
595 	cr_assert_eq(sz, 0);
596 }
597 
Test(api_cntr_basic,atomic)598 Test(api_cntr_basic, atomic)
599 {
600 	cntr_bind_flags = FI_WRITE | FI_READ;
601 	api_cntr_bind(cntr_bind_flags);
602 	api_cntr_atomic();
603 }
604 
Test(api_cntr_basic,atomic_send_only)605 Test(api_cntr_basic, atomic_send_only)
606 {
607 	cntr_bind_flags = FI_WRITE;
608 	api_cntr_bind(cntr_bind_flags);
609 	api_cntr_atomic();
610 }
611 
Test(api_cntr_basic,atomic_recv_only)612 Test(api_cntr_basic, atomic_recv_only)
613 {
614 	cntr_bind_flags = FI_READ;
615 	api_cntr_bind(cntr_bind_flags);
616 	api_cntr_atomic();
617 }
618 
Test(api_cntr_scalable,msg)619 Test(api_cntr_scalable, msg)
620 {
621 	cntr_bind_flags = FI_SEND | FI_RECV;
622 	api_cntr_bind(cntr_bind_flags);
623 	api_cntr_send_recv(BUF_SZ);
624 }
625 
Test(api_cntr_scalable,msg_send_only)626 Test(api_cntr_scalable, msg_send_only)
627 {
628 	cntr_bind_flags = FI_SEND;
629 	api_cntr_bind(cntr_bind_flags);
630 	api_cntr_send_recv(BUF_SZ);
631 }
632 
Test(api_cntr_scalable,msg_recv_only)633 Test(api_cntr_scalable, msg_recv_only)
634 {
635 	cntr_bind_flags = FI_RECV;
636 	api_cntr_bind(cntr_bind_flags);
637 	api_cntr_send_recv(BUF_SZ);
638 }
639 
Test(api_cntr_scalable,msg_no_cntr)640 Test(api_cntr_scalable, msg_no_cntr)
641 {
642 	__msg_no_cntr();
643 }
644 
Test(api_cntr_scalable,atomic)645 Test(api_cntr_scalable, atomic)
646 {
647 	cntr_bind_flags = FI_WRITE | FI_READ;
648 	api_cntr_bind(cntr_bind_flags);
649 	api_cntr_atomic();
650 }
651 
Test(api_cntr_scalable,atomic_send_only)652 Test(api_cntr_scalable, atomic_send_only)
653 {
654 	cntr_bind_flags = FI_WRITE;
655 	api_cntr_bind(cntr_bind_flags);
656 	api_cntr_atomic();
657 }
658 
Test(api_cntr_scalable,atomic_recv_only)659 Test(api_cntr_scalable, atomic_recv_only)
660 {
661 	cntr_bind_flags = FI_READ;
662 	api_cntr_bind(cntr_bind_flags);
663 	api_cntr_atomic();
664 }
665 
Test(api_cntr_scalable,rma)666 Test(api_cntr_scalable, rma)
667 {
668 	__rma();
669 }
670 
Test(api_cntr_scalable,rma_write_only)671 Test(api_cntr_scalable, rma_write_only)
672 {
673 	__rma_write_only();
674 }
675 
Test(api_cntr_scalable,rma_read_only)676 Test(api_cntr_scalable, rma_read_only)
677 {
678 	__rma_read_only();
679 }
680 
Test(api_cntr_scalable,rma_no_cntr)681 Test(api_cntr_scalable, rma_no_cntr)
682 {
683 	__rma_no_cntr();
684 }
685 
686