1 /** 2 * Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED. 3 * 4 * See file LICENSE for terms. 5 */ 6 7 #ifndef UCT_P2P_TEST_H_ 8 #define UCT_P2P_TEST_H_ 9 10 #include "uct_test.h" 11 12 /** 13 * Point-to-point UCT test. 14 */ 15 class uct_p2p_test : public uct_test { 16 public: 17 uct_p2p_test(size_t rx_headroom, uct_error_handler_t err_handler = NULL); 18 19 static std::vector<const resource*> enum_resources(const std::string& tl_name); 20 21 virtual void init(); 22 virtual void cleanup(); 23 24 UCS_TEST_BASE_IMPL; 25 protected: 26 typedef ucs_status_t (uct_p2p_test::* send_func_t)(uct_ep_h ep, 27 const mapped_buffer &, 28 const mapped_buffer &); 29 30 enum uct_p2p_test_flags { 31 TEST_UCT_FLAG_DIR_SEND_TO_RECV = UCS_BIT(0), 32 TEST_UCT_FLAG_SEND_ZCOPY = UCS_BIT(1), 33 TEST_UCT_FLAG_RECV_ZCOPY = UCS_BIT(2), 34 }; 35 36 struct completion { 37 uct_p2p_test *self; 38 uct_completion_t uct; 39 }; 40 41 struct p2p_resource : public resource { 42 virtual std::string name() const; 43 bool loopback; 44 p2p_resourcep2p_resource45 p2p_resource(const resource& res) : 46 resource(res.component, res.md_name, res.local_cpus, 47 res.tl_name, res.dev_name, res.dev_type), 48 loopback(false) { } 49 }; 50 51 virtual void test_xfer(send_func_t send, size_t length, unsigned flags, 52 ucs_memory_type_t mem_type); 53 void test_xfer_multi(send_func_t send, size_t min_length, size_t max_length, 54 unsigned flags); 55 void test_xfer_multi_mem_type(send_func_t send, size_t min_length, size_t max_length, 56 unsigned flags, ucs_memory_type_t mem_type); 57 void blocking_send(send_func_t send, uct_ep_h ep, const mapped_buffer &sendbuf, 58 const mapped_buffer &recvbuf, bool wait_for_completion); 59 void wait_for_remote(); 60 entity& sender(); 61 uct_ep_h sender_ep(); 62 entity& receiver(); 63 uct_completion_t *comp(); 64 65 private: 66 template <typename O> 67 void test_xfer_print(O& os, send_func_t send, size_t length, 68 unsigned flags, ucs_memory_type_t mem_type); 69 70 static void completion_cb(uct_completion_t *self, ucs_status_t status); 71 72 static ucs_log_func_rc_t 73 log_handler(const char *file, unsigned line, const char *function, 74 ucs_log_level_t level, 75 const ucs_log_component_config_t *comp_conf, 76 const char *prefix, va_list ap); 77 78 static int log_data_count; 79 static ucs_log_level_t orig_log_level; 80 81 const size_t m_rx_headroom; 82 uct_error_handler_t m_err_handler; 83 bool m_null_completion; 84 completion m_completion; 85 unsigned m_completion_count; 86 }; 87 88 89 #endif 90