/* * Copyright (c) 2013-2015 Intel Corporation. All rights reserved. * Copyright (c) 2014-2017 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2020-2021 Amazon.com, Inc. or its affiliates. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include #include #include #include #include #include "shared.h" #include "benchmark_shared.h" static int run(void) { int i, ret; ret = ft_init_fabric(); if (ret) return ret; /* Post an extra receive to avoid lacking a posted receive in the * finalize. */ ret = fi_recv(ep, rx_buf, rx_size + ft_rx_prefix_size(), mr_desc, 0, &rx_ctx); if (ret) return ret; if (!(opts.options & FT_OPT_SIZE)) { for (i = 0; i < TEST_CNT; i++) { if (!ft_use_size(i, opts.sizes_enabled)) continue; opts.transfer_size = test_size[i].size; init_test(&opts, test_name, sizeof(test_name)); ret = pingpong(); if (ret) return ret; } } else { init_test(&opts, test_name, sizeof(test_name)); ret = pingpong(); if (ret) return ret; } return ft_finalize(); } int main(int argc, char **argv) { int ret, op; opts = INIT_OPTS; timeout = 5; hints = fi_allocinfo(); if (!hints) return EXIT_FAILURE; while ((op = getopt_long(argc, argv, "hT:" CS_OPTS INFO_OPTS BENCHMARK_OPTS, long_opts, &lopt_idx)) != -1) { switch (op) { case 'T': timeout = atoi(optarg); break; default: if (!ft_parse_long_opts(op, optarg)) continue; ft_parse_benchmark_opts(op, optarg); ft_parseinfo(op, optarg, hints, &opts); ft_parsecsopts(op, optarg, &opts); break; case '?': case 'h': ft_csusage(argv[0], "Ping pong client and server using UD."); ft_benchmark_usage(); FT_PRINT_OPTS_USAGE("-T ", "seconds before timeout on receive"); ft_longopts_usage(); return EXIT_FAILURE; } } if (optind < argc) opts.dst_addr = argv[optind]; /* * Because dgram endpoint is not reliable, we * must use out-of-band sync */ opts.options |= FT_OPT_OOB_SYNC; hints->ep_attr->type = FI_EP_DGRAM; if (opts.options & FT_OPT_SIZE) hints->ep_attr->max_msg_size = opts.transfer_size; hints->caps = FI_MSG; hints->mode |= FI_CONTEXT; hints->domain_attr->mr_mode = opts.mr_mode; hints->domain_attr->threading = FI_THREAD_DOMAIN; hints->tx_attr->tclass = FI_TC_LOW_LATENCY; hints->addr_format = opts.address_format; ret = run(); ft_free_res(); return ft_exit_code(ret); }