diff --git a/config/m4/ucm.m4 b/config/m4/ucm.m4 index 01de82c9697..fd3750d56a4 100644 --- a/config/m4/ucm.m4 +++ b/config/m4/ucm.m4 @@ -42,3 +42,8 @@ esac AM_CONDITIONAL([HAVE_UCM_PTMALLOC286],[test "x$HAVE_UCM_PTMALLOC286" = "xyes"]) +AC_CHECK_FUNCS([malloc_get_state malloc_set_state], + [], + [], + [#include ]) + diff --git a/src/ucp/api/ucp.h b/src/ucp/api/ucp.h index 4d24cd68bc2..202dec16eb1 100644 --- a/src/ucp/api/ucp.h +++ b/src/ucp/api/ucp.h @@ -14,8 +14,10 @@ #include #include #include +#include #include +BEGIN_C_DECLS /** * @defgroup UCP_API Unified Communication Protocol (UCP) API @@ -2446,5 +2448,6 @@ ucs_status_t ucp_worker_flush(ucp_worker_h worker); * UCP hello world client / server example utility. */ +END_C_DECLS #endif diff --git a/src/ucp/api/ucp_compat.h b/src/ucp/api/ucp_compat.h index cd0efc24519..7cb577ad8a8 100644 --- a/src/ucp/api/ucp_compat.h +++ b/src/ucp/api/ucp_compat.h @@ -10,7 +10,9 @@ #include +#include +BEGIN_C_DECLS /** * @ingroup UCP_COMM @@ -32,5 +34,6 @@ void ucp_request_release(void *request); */ void ucp_ep_destroy(ucp_ep_h ep); +END_C_DECLS #endif diff --git a/src/ucp/wireup/wireup.c b/src/ucp/wireup/wireup.c index 16e1303746d..ce50cfaa3b0 100644 --- a/src/ucp/wireup/wireup.c +++ b/src/ucp/wireup/wireup.c @@ -452,7 +452,7 @@ ucs_status_t ucp_wireup_init_lanes(ucp_ep_h ep, unsigned address_count, key.reachable_md_map |= ucp_ep_config(ep)->key.reachable_md_map; new_cfg_index = ucp_worker_get_ep_config(worker, &key); - if ((ep->cfg_index == new_cfg_index)) { + if (ep->cfg_index == new_cfg_index) { return UCS_OK; /* No change */ } diff --git a/src/ucs/algorithm/crc.h b/src/ucs/algorithm/crc.h index 89535b4ace8..42da1b50a4f 100644 --- a/src/ucs/algorithm/crc.h +++ b/src/ucs/algorithm/crc.h @@ -10,6 +10,10 @@ #include #include +#include + +BEGIN_C_DECLS + /** * Calculate CRC16 of an arbitrary buffer. * @@ -26,5 +30,6 @@ uint16_t ucs_crc16(const void *buffer, size_t size); */ uint16_t ucs_crc16_string(const char *s); +END_C_DECLS #endif diff --git a/src/ucs/algorithm/qsort_r.h b/src/ucs/algorithm/qsort_r.h index 564140ada52..9894c875a2d 100644 --- a/src/ucs/algorithm/qsort_r.h +++ b/src/ucs/algorithm/qsort_r.h @@ -37,6 +37,9 @@ #include +#include + +BEGIN_C_DECLS /** * Compare callback for @ref qsort_r. @@ -59,5 +62,6 @@ typedef int ucs_qsort_r_compare_cb_t(const void *elem1, const void *elem2, void ucs_qsort_r(void *base, size_t nmemb, size_t size, ucs_qsort_r_compare_cb_t *compare, void *arg); +END_C_DECLS #endif diff --git a/src/ucs/arch/aarch64/cpu.h b/src/ucs/arch/aarch64/cpu.h index c40d179a05a..431c02519b2 100644 --- a/src/ucs/arch/aarch64/cpu.h +++ b/src/ucs/arch/aarch64/cpu.h @@ -11,6 +11,7 @@ #include "config.h" #include #include +#include #include #if __ARM_NEON #include @@ -19,6 +20,8 @@ #define UCS_ARCH_CACHE_LINE_SIZE 64 +BEGIN_C_DECLS + /** * Assume the worst - weak memory ordering. */ @@ -63,8 +66,6 @@ static inline int ucs_arch_get_cpu_flag() return UCS_CPU_FLAG_UNKNOWN; } -#endif - static inline void ucs_arch_wait_mem(void *address) { unsigned long tmp; @@ -73,3 +74,8 @@ static inline void ucs_arch_wait_mem(void *address) : "=&r"(tmp) : "r"(address)); } + +END_C_DECLS + +#endif + diff --git a/src/ucs/arch/ppc64/cpu.h b/src/ucs/arch/ppc64/cpu.h index 77ae29f98de..ae067c576ab 100644 --- a/src/ucs/arch/ppc64/cpu.h +++ b/src/ucs/arch/ppc64/cpu.h @@ -13,9 +13,11 @@ #ifdef HAVE_SYS_PLATFORM_PPC_H # include #endif +#include #include #include +BEGIN_C_DECLS #define UCS_ARCH_CACHE_LINE_SIZE 128 @@ -53,4 +55,6 @@ double ucs_arch_get_clocks_per_sec(); #define ucs_arch_wait_mem ucs_arch_generic_wait_mem +END_C_DECLS + #endif diff --git a/src/ucs/arch/x86_64/cpu.h b/src/ucs/arch/x86_64/cpu.h index 8b24b524474..583b06ad80f 100644 --- a/src/ucs/arch/x86_64/cpu.h +++ b/src/ucs/arch/x86_64/cpu.h @@ -10,6 +10,7 @@ #include #include +#include #include #ifdef __SSE4_1__ @@ -19,6 +20,7 @@ # include #endif +BEGIN_C_DECLS #define UCS_ARCH_CACHE_LINE_SIZE 64 @@ -48,6 +50,7 @@ ucs_cpu_flag_t ucs_arch_get_cpu_flag() UCS_F_NOOPTIMIZE; #define ucs_arch_wait_mem ucs_arch_generic_wait_mem +END_C_DECLS #endif diff --git a/src/ucs/async/async.h b/src/ucs/async/async.h index 27278995cd0..5a2115f4f1a 100644 --- a/src/ucs/async/async.h +++ b/src/ucs/async/async.h @@ -11,10 +11,12 @@ #include "signal.h" #include "async_fwd.h" +#include #include #include #include +BEGIN_C_DECLS /** * Async event context. Manages timer and fd notifications. @@ -119,4 +121,6 @@ static inline int ucs_async_check_miss(ucs_async_context_t *async) } while (0) +END_C_DECLS + #endif diff --git a/src/ucs/async/async_fwd.h b/src/ucs/async/async_fwd.h index 281dc0a2347..20732ec29b8 100644 --- a/src/ucs/async/async_fwd.h +++ b/src/ucs/async/async_fwd.h @@ -10,6 +10,7 @@ #include #include +BEGIN_C_DECLS typedef struct ucs_async_context ucs_async_context_t; @@ -121,5 +122,6 @@ void ucs_async_poll(ucs_async_context_t *async); void __ucs_async_poll_missed(ucs_async_context_t *async); +END_C_DECLS #endif diff --git a/src/ucs/config/global_opts.c b/src/ucs/config/global_opts.c index b313e680d29..db0db2ec965 100644 --- a/src/ucs/config/global_opts.c +++ b/src/ucs/config/global_opts.c @@ -29,9 +29,7 @@ ucs_global_opts_t ucs_global_opts = { .stats_dest = "", .tuning_path = "", .memtrack_dest = "", - .stats_dest = "", .stats_trigger = "exit", - .memtrack_dest = "", .profile_mode = 0, .profile_file = "", .stats_filter = { NULL, 0 }, diff --git a/src/ucs/config/global_opts.h b/src/ucs/config/global_opts.h index aa82249a2e7..92252e4c249 100644 --- a/src/ucs/config/global_opts.h +++ b/src/ucs/config/global_opts.h @@ -11,9 +11,11 @@ #include #include +#include #include #include +BEGIN_C_DECLS /** @@ -108,4 +110,6 @@ ucs_status_t ucs_global_opts_clone(void *dst); void ucs_global_opts_release(); void ucs_global_opts_print(FILE *stream, ucs_config_print_flags_t print_flags); +END_C_DECLS + #endif diff --git a/src/ucs/config/parser.h b/src/ucs/config/parser.h index 0a3916f1e81..62b95139d35 100644 --- a/src/ucs/config/parser.h +++ b/src/ucs/config/parser.h @@ -11,12 +11,14 @@ #include #include +#include #include #define UCS_CONFIG_PREFIX "UCX_" #define UCS_CONFIG_ARRAY_MAX 128 +BEGIN_C_DECLS /* * Configuration varaibles syntax: @@ -326,4 +328,6 @@ size_t ucs_config_memunits_get(size_t config_size, size_t auto_size, int ucs_config_names_search(ucs_config_names_array_t config_names, const char *str); +END_C_DECLS + #endif diff --git a/src/ucs/datastruct/callbackq.h b/src/ucs/datastruct/callbackq.h index 4c10dd583c2..f36990880a8 100644 --- a/src/ucs/datastruct/callbackq.h +++ b/src/ucs/datastruct/callbackq.h @@ -11,6 +11,9 @@ #include #include #include +#include + +BEGIN_C_DECLS /* * @@ -236,6 +239,7 @@ void ucs_callbackq_add_slow_path(ucs_callbackq_t *cbq, void ucs_callbackq_remove_slow_path(ucs_callbackq_t *cbq, ucs_callbackq_slow_elem_t* elem); +END_C_DECLS /** * Remove all slow path elements with a given callback function from the list. diff --git a/src/ucs/datastruct/mpool.h b/src/ucs/datastruct/mpool.h index e739d762a2b..860d3822395 100644 --- a/src/ucs/datastruct/mpool.h +++ b/src/ucs/datastruct/mpool.h @@ -11,6 +11,9 @@ #include #include #include +#include + +BEGIN_C_DECLS typedef struct ucs_mpool_chunk ucs_mpool_chunk_t; @@ -235,5 +238,6 @@ void ucs_mpool_chunk_munmap(ucs_mpool_t *mp, void *chunk); ucs_status_t ucs_mpool_hugetlb_malloc(ucs_mpool_t *mp, size_t *size_p, void **chunk_p); void ucs_mpool_hugetlb_free(ucs_mpool_t *mp, void *chunk); +END_C_DECLS #endif /* MPOOL_H_ */ diff --git a/src/ucs/debug/log.h b/src/ucs/debug/log.h index 359508b68f5..91ef2461485 100644 --- a/src/ucs/debug/log.h +++ b/src/ucs/debug/log.h @@ -16,6 +16,7 @@ #include #include +BEGIN_C_DECLS #define ucs_log_enabled(_level) \ ucs_unlikely(((_level) <= UCS_MAX_LOG_LEVEL) && ((_level) <= (ucs_global_opts.log_level))) @@ -144,5 +145,7 @@ const char *ucs_log_dump_hex(const void* data, size_t length, char *buf, size_t void ucs_log_push_handler(ucs_log_func_t handler); void ucs_log_pop_handler(); +END_C_DECLS + #endif diff --git a/src/ucs/debug/memtrack.h b/src/ucs/debug/memtrack.h index efc45339838..695620ecbc7 100644 --- a/src/ucs/debug/memtrack.h +++ b/src/ucs/debug/memtrack.h @@ -11,11 +11,14 @@ # include "config.h" #endif +#include + #include #include #include #include +BEGIN_C_DECLS enum { UCS_MEMTRACK_STAT_ALLOCATION_COUNT, @@ -158,5 +161,6 @@ char *ucs_strdup(const char *src, const char *name); #endif /* ENABLE_MEMTRACK */ +END_C_DECLS #endif diff --git a/src/ucs/debug/profile.c b/src/ucs/debug/profile.c index aab55a6b9bb..aaad6a551eb 100644 --- a/src/ucs/debug/profile.c +++ b/src/ucs/debug/profile.c @@ -32,9 +32,9 @@ static void ucs_profile_file_write_data(int fd, void *data, size_t size) { ssize_t written = write(fd, data, size); if (written < 0) { - ucs_warn("failed to write %Zu bytes to profiling file: %m", size); + ucs_warn("failed to write %zu bytes to profiling file: %m", size); } else if (size != written) { - ucs_warn("wrote only %Zd of %Zu bytes to profiling file: %m", + ucs_warn("wrote only %zd of %zu bytes to profiling file: %m", written, size); } } diff --git a/src/ucs/stats/client_server.c b/src/ucs/stats/client_server.c index 8c35fca5688..0c392dbe67f 100644 --- a/src/ucs/stats/client_server.c +++ b/src/ucs/stats/client_server.c @@ -333,7 +333,7 @@ ucs_stats_server_entity_update(ucs_stats_server_h server, stats_entity_t *entity frag_hole_t *hole, *new_hole; void *frag_start, *frag_end, *hole_end; - ucs_debug("From %s:%d - timestamp %"PRIu64", %Zu..%Zu / %Zu", + ucs_debug("From %s:%d - timestamp %"PRIu64", %zu..%zu / %zu", inet_ntoa(entity->in_addr.sin_addr), ntohs(entity->in_addr.sin_port), timestamp, frag_offset, frag_offset + frag_size, total_size); @@ -341,20 +341,20 @@ ucs_stats_server_entity_update(ucs_stats_server_h server, stats_entity_t *entity ucs_debug("Dropping - old timestamp"); return 0; } else if (timestamp > entity->timestamp) { - ucs_debug("New timestamp, resetting buffer with size %Zu", total_size); + ucs_debug("New timestamp, resetting buffer with size %zu", total_size); entity->timestamp = timestamp; ucs_stats_server_entity_reset_buffer(entity, total_size); } else { /* Make sure all packets in this timestamp have the same 'total_size' */ if (entity->buffer_size != total_size) { - ucs_error("Total size in the packet is %Zu, but expected is %Zu", + ucs_error("Total size in the packet is %zu, but expected is %zu", total_size, entity->buffer_size); } } hole = find_frag_hole(entity, frag_size, frag_offset); if (hole == NULL) { - ucs_error("cannot fill fragment (offset %Zu size %Zu)", frag_offset, frag_size); + ucs_error("cannot fill fragment (offset %zu size %zu)", frag_offset, frag_size); return UCS_ERR_MESSAGE_TRUNCATED; } @@ -362,7 +362,7 @@ ucs_stats_server_entity_update(ucs_stats_server_h server, stats_entity_t *entity frag_end = entity->inprogress_buffer + frag_offset + frag_size; hole_end = (void*)hole + hole->size; - ucs_debug("inserting into a hole of %Zu..%Zu", + ucs_debug("inserting into a hole of %zu..%zu", (void*)hole - entity->inprogress_buffer, hole_end - entity->inprogress_buffer); @@ -414,7 +414,7 @@ ucs_stats_server_update_context(ucs_stats_server_h server, struct sockaddr_in *s /* Validate fragment size */ if (pkt_len != pkt->frag_size + sizeof(ucs_stats_packet_hdr_t)) { - ucs_error("Invalid receive size: expected %Zu, got %Zu", + ucs_error("Invalid receive size: expected %zu, got %zu", pkt->frag_size + sizeof(ucs_stats_packet_hdr_t), pkt_len); return UCS_ERR_MESSAGE_TRUNCATED; } diff --git a/src/ucs/stats/libstats.c b/src/ucs/stats/libstats.c index 66570af9bd1..c469d1567a0 100644 --- a/src/ucs/stats/libstats.c +++ b/src/ucs/stats/libstats.c @@ -21,13 +21,13 @@ static ucs_status_t ucs_stats_name_check(const char *name) length = strlen(name); if (length > UCS_STAT_NAME_MAX) { - ucs_error("stats name '%s' is too long (%Zu)", name, length); + ucs_error("stats name '%s' is too long (%zu)", name, length); return UCS_ERR_INVALID_PARAM; } valid_length = strspn(name, UCS_STATS_NAME_VALID_CHARS); if (valid_length != length) { - ucs_error("stats name '%s' contains invalid character at offset %Zu", + ucs_error("stats name '%s' contains invalid character at offset %zu", name, valid_length); return UCS_ERR_INVALID_PARAM; } diff --git a/src/ucs/stats/libstats.h b/src/ucs/stats/libstats.h index c0e244eb069..db1e2effba3 100644 --- a/src/ucs/stats/libstats.h +++ b/src/ucs/stats/libstats.h @@ -127,7 +127,7 @@ struct ucs_stats_node { ucs_list_link_t type_list; /* nodes with same class/es hierarchy */ ucs_stats_filter_node_t *filter_node; /* ptr to type list head */ - ucs_stats_counter_t counters[]; /* instance counters */ + ucs_stats_counter_t counters[1]; /* instance counters */ }; struct ucs_stats_filter_node { diff --git a/src/ucs/stats/stats.c b/src/ucs/stats/stats.c index 636596efea2..ff9ceb1cc77 100644 --- a/src/ucs/stats/stats.c +++ b/src/ucs/stats/stats.c @@ -178,7 +178,8 @@ static ucs_status_t ucs_stats_node_new(ucs_stats_class_t *cls, ucs_stats_node_t ucs_stats_node_t *node; node = ucs_malloc(sizeof(ucs_stats_node_t) + - sizeof(ucs_stats_counter_t) * cls->num_counters, + sizeof(ucs_stats_counter_t) * + (cls->num_counters > 0 ? cls->num_counters - 1 : 0), "stats node"); if (node == NULL) { ucs_error("Failed to allocate stats node for %s", cls->name); diff --git a/src/ucs/stats/stats.h b/src/ucs/stats/stats.h index fe339ecc08c..9e9c5fa5144 100644 --- a/src/ucs/stats/stats.h +++ b/src/ucs/stats/stats.h @@ -12,6 +12,10 @@ # include "config.h" #endif +#include + +BEGIN_C_DECLS + void ucs_stats_init(); void ucs_stats_cleanup(); void ucs_stats_dump(); @@ -104,4 +108,6 @@ void ucs_stats_node_free(ucs_stats_node_t *node); #endif +END_C_DECLS + #endif diff --git a/src/ucs/stats/stats_fwd.h b/src/ucs/stats/stats_fwd.h index 0d9fb4d3043..69a0d722013 100644 --- a/src/ucs/stats/stats_fwd.h +++ b/src/ucs/stats/stats_fwd.h @@ -9,6 +9,9 @@ #include +#include + +BEGIN_C_DECLS typedef uint64_t ucs_stats_counter_t; /* Stats counter*/ typedef struct ucs_stats_class ucs_stats_class_t; /* Stats class */ @@ -25,4 +28,6 @@ typedef enum { extern const char *ucs_stats_formats_names[]; ucs_stats_node_t * ucs_stats_get_root(); +END_C_DECLS + #endif /* STATS_FD_H_ */ diff --git a/src/ucs/sys/math.h b/src/ucs/sys/math.h index e22fe352296..14944598455 100644 --- a/src/ucs/sys/math.h +++ b/src/ucs/sys/math.h @@ -15,6 +15,7 @@ #include #include +BEGIN_C_DECLS #define UCS_KBYTE (1ull << 10) #define UCS_MBYTE (1ull << 20) @@ -147,5 +148,6 @@ uint32_t ucs_calc_crc32(uint32_t crc, const void *buf, size_t size); */ uint64_t ucs_get_prime(unsigned index); +END_C_DECLS #endif /* MACROS_H_ */ diff --git a/src/ucs/sys/string.h b/src/ucs/sys/string.h index 6fad8b816ad..8d8a240b804 100644 --- a/src/ucs/sys/string.h +++ b/src/ucs/sys/string.h @@ -11,7 +11,9 @@ #include #include +#include +BEGIN_C_DECLS /** * Expand a partial path to full path. @@ -71,4 +73,6 @@ uint64_t ucs_string_to_id(const char *str); void ucs_memunits_to_str(size_t value, char *buf, size_t max); +END_C_DECLS + #endif diff --git a/src/ucs/sys/sys.h b/src/ucs/sys/sys.h index 3899304e80e..ef2daa83d69 100644 --- a/src/ucs/sys/sys.h +++ b/src/ucs/sys/sys.h @@ -44,6 +44,7 @@ #include #include +BEGIN_C_DECLS /** * @return Host name. @@ -254,4 +255,6 @@ ucs_status_t ucs_empty_function_return_ep_timeout(); ssize_t ucs_empty_function_return_bc_ep_timeout(); ucs_status_t ucs_empty_function_return_busy(); +END_C_DECLS + #endif diff --git a/src/ucs/time/time.h b/src/ucs/time/time.h index 4c154c23091..1725e6f1c18 100644 --- a/src/ucs/time/time.h +++ b/src/ucs/time/time.h @@ -12,6 +12,7 @@ #include #include +BEGIN_C_DECLS /** * Short time type @@ -132,4 +133,6 @@ static inline void ucs_sec_to_timespec(double seconds, struct timespec *ts) ts->tv_nsec = nsec % UCS_NSEC_PER_SEC; } +END_C_DECLS + #endif diff --git a/src/ucs/type/class.h b/src/ucs/type/class.h index 92eda395565..1adffbabbe9 100644 --- a/src/ucs/type/class.h +++ b/src/ucs/type/class.h @@ -11,6 +11,7 @@ #include #include +BEGIN_C_DECLS typedef struct ucs_class ucs_class_t; @@ -302,4 +303,6 @@ void ucs_class_free(void *obj); */ UCS_CLASS_DECLARE(void); +END_C_DECLS + #endif diff --git a/src/ucs/type/component.h b/src/ucs/type/component.h index d0d98f2b1da..6963537a6fd 100644 --- a/src/ucs/type/component.h +++ b/src/ucs/type/component.h @@ -12,6 +12,7 @@ #include #include +BEGIN_C_DECLS /* * Component definition - used internally. @@ -143,6 +144,7 @@ size_t __ucs_components_total_size(ucs_list_link_t *list, size_t base_size); ucs_status_t __ucs_components_init_all(ucs_list_link_t *list, void *base_ptr); void __ucs_components_cleanup_all(ucs_list_link_t *list, void *base_ptr); +END_C_DECLS #endif /* COMPONENT_H_ */ diff --git a/src/ucs/type/spinlock.h b/src/ucs/type/spinlock.h index eabc503770a..2a7d77b55bf 100644 --- a/src/ucs/type/spinlock.h +++ b/src/ucs/type/spinlock.h @@ -10,6 +10,7 @@ #include #include +BEGIN_C_DECLS /** * Reentrant spinlock. @@ -93,4 +94,6 @@ static inline void ucs_spin_unlock(ucs_spinlock_t *lock) } } +END_C_DECLS + #endif diff --git a/src/ucs/type/status.h b/src/ucs/type/status.h index 9107f6e2f7e..85b35ad5795 100644 --- a/src/ucs/type/status.h +++ b/src/ucs/type/status.h @@ -11,6 +11,7 @@ #include +BEGIN_C_DECLS /** * @defgroup UCS_API Unified Communication Services (UCS) API @@ -111,5 +112,6 @@ typedef void *ucs_status_ptr_t; */ const char *ucs_status_string(ucs_status_t status); +END_C_DECLS #endif diff --git a/src/uct/api/tl.h b/src/uct/api/tl.h index 1fc131b20ae..132a0275a80 100644 --- a/src/uct/api/tl.h +++ b/src/uct/api/tl.h @@ -17,6 +17,7 @@ #include #include +BEGIN_C_DECLS /** * Transport iface operations. @@ -226,5 +227,6 @@ struct uct_recv_desc { #define uct_recv_desc(_desc) \ ( *( ( (uct_recv_desc_t**)(_desc) ) - 1) ) +END_C_DECLS #endif diff --git a/src/uct/api/uct.h b/src/uct/api/uct.h index 8633539bfb0..668bd19163e 100644 --- a/src/uct/api/uct.h +++ b/src/uct/api/uct.h @@ -19,11 +19,14 @@ #include #include #include +#include #include #include #include +BEGIN_C_DECLS + /** * @defgroup UCT_API Unified Communication Transport (UCT) API * @{ @@ -2087,5 +2090,6 @@ UCT_INLINE_API ucs_status_t uct_iface_tag_recv_cancel(uct_iface_h iface, * UCT hello world client / server example utility. */ +END_C_DECLS #endif diff --git a/src/uct/base/uct_md.h b/src/uct/base/uct_md.h index 1dc604fc745..8fd9e63eb1d 100644 --- a/src/uct/base/uct_md.h +++ b/src/uct/base/uct_md.h @@ -45,6 +45,9 @@ struct uct_md_component { * Specific MDs extend this structure. */ struct uct_md_config { +#ifdef __cplusplus + char __dummy; +#endif }; diff --git a/src/uct/ib/base/ib_device.c b/src/uct/ib/base/ib_device.c index 6505438fdfd..ce65a4c1ffd 100644 --- a/src/uct/ib/base/ib_device.c +++ b/src/uct/ib/base/ib_device.c @@ -33,9 +33,11 @@ static uct_ib_device_spec_t uct_ib_builtin_device_specs[] = { {0x02c9, 4103, "ConnectX-3 Pro", UCT_IB_DEVICE_FLAG_MLX4_PRM, 11}, {0x02c9, 4113, "Connect-IB", UCT_IB_DEVICE_FLAG_MLX5_PRM, 20}, {0x02c9, 4115, "ConnectX-4", UCT_IB_DEVICE_FLAG_MLX5_PRM, 30}, + {0x02c9, 4116, "ConnectX-4", UCT_IB_DEVICE_FLAG_MLX5_PRM, 29}, {0x02c9, 4117, "ConnectX-4 LX", UCT_IB_DEVICE_FLAG_MLX5_PRM, 28}, {0x02c9, 4119, "ConnectX-5", UCT_IB_DEVICE_FLAG_MLX5_PRM, 38}, {0x02c9, 4121, "ConnectX-5", UCT_IB_DEVICE_FLAG_MLX5_PRM, 40}, + {0x02c9, 4120, "ConnectX-5", UCT_IB_DEVICE_FLAG_MLX5_PRM, 39}, {0, 0, "Generic HCA", 0, 0} }; diff --git a/src/uct/ib/base/ib_iface.c b/src/uct/ib/base/ib_iface.c index ca7b83ff801..096c238ef94 100644 --- a/src/uct/ib/base/ib_iface.c +++ b/src/uct/ib/base/ib_iface.c @@ -341,8 +341,8 @@ static ucs_status_t uct_ib_iface_init_lmc(uct_ib_iface_t *iface, /* count the number of lid_path_bits */ num_path_bits = 0; for (i = 0; i < config->lid_path_bits.count; i++) { - num_path_bits += 1 + abs(config->lid_path_bits.ranges[i].first - - config->lid_path_bits.ranges[i].last); + num_path_bits += 1 + abs((int)(config->lid_path_bits.ranges[i].first - + config->lid_path_bits.ranges[i].last)); } iface->path_bits = ucs_calloc(1, num_path_bits * sizeof(*iface->path_bits), diff --git a/src/uct/ib/base/ib_md.c b/src/uct/ib/base/ib_md.c index 8cf9f74d154..14d84ce974a 100644 --- a/src/uct/ib/base/ib_md.c +++ b/src/uct/ib/base/ib_md.c @@ -346,7 +346,7 @@ static ucs_status_t uct_ib_md_reg_mr(uct_ib_md_t *md, void *address, mr = UCS_PROFILE_CALL(ibv_exp_reg_mr, &in); if (mr == NULL) { - ucs_log(level, "ibv_exp_reg_mr(address=%p, length=%Zu, exp_access=0x%lx) failed: %m", + ucs_log(level, "ibv_exp_reg_mr(address=%p, length=%zu, exp_access=0x%lx) failed: %m", in.addr, in.length, in.exp_access); return UCS_ERR_IO_ERROR; } @@ -357,7 +357,7 @@ static ucs_status_t uct_ib_md_reg_mr(uct_ib_md_t *md, void *address, mr = UCS_PROFILE_CALL(ibv_reg_mr, md->pd, address, length, UCT_IB_MEM_ACCESS_FLAGS); if (mr == NULL) { - ucs_log(level, "ibv_reg_mr(address=%p, length=%Zu, access=0x%x) failed: %m", + ucs_log(level, "ibv_reg_mr(address=%p, length=%zu, access=0x%x) failed: %m", address, length, UCT_IB_MEM_ACCESS_FLAGS); return UCS_ERR_IO_ERROR; } diff --git a/src/uct/ib/dc/verbs/dc_verbs.c b/src/uct/ib/dc/verbs/dc_verbs.c index 894e0a441b9..7d9b31d24aa 100644 --- a/src/uct/ib/dc/verbs/dc_verbs.c +++ b/src/uct/ib/dc/verbs/dc_verbs.c @@ -205,8 +205,8 @@ ucs_status_t uct_dc_verbs_ep_get_bcopy(uct_ep_h tl_ep, UCT_DC_CHECK_RES(&iface->super, &ep->super); UCT_RC_IFACE_GET_TX_GET_BCOPY_DESC(&iface->super.super, &iface->super.super.tx.mp, desc, unpack_cb, comp, arg, length); - UCT_RC_VERBS_FILL_RDMA_WR(wr, wr.exp_opcode, IBV_WR_RDMA_READ, sge, length, remote_addr, - rkey); + UCT_RC_VERBS_FILL_RDMA_WR(wr, wr.exp_opcode, IBV_EXP_WR_RDMA_READ, sge, + length, remote_addr, rkey); UCT_TL_EP_STAT_OP(&ep->super.super, GET, BCOPY, length); uct_dc_verbs_iface_post_send_desc(iface, ep, &wr, desc, IBV_SEND_SIGNALED); @@ -267,7 +267,7 @@ ssize_t uct_dc_verbs_ep_put_bcopy(uct_ep_h tl_ep, uct_pack_callback_t pack_cb, UCT_DC_CHECK_RES(&iface->super, &ep->super); UCT_RC_IFACE_GET_TX_PUT_BCOPY_DESC(&iface->super.super, &iface->super.super.tx.mp, desc, pack_cb, arg, length); - UCT_RC_VERBS_FILL_RDMA_WR(wr, wr.exp_opcode, IBV_WR_RDMA_WRITE, sge, + UCT_RC_VERBS_FILL_RDMA_WR(wr, wr.exp_opcode, IBV_EXP_WR_RDMA_WRITE, sge, length, remote_addr, rkey); UCT_TL_EP_STAT_OP(&ep->super.super, PUT, BCOPY, length); uct_dc_verbs_iface_post_send_desc(iface, ep, &wr, desc, IBV_SEND_SIGNALED); @@ -660,7 +660,7 @@ ucs_status_t uct_dc_verbs_ep_fc_ctrl(uct_ep_h tl_ep, unsigned op, if (status != UCS_OK) { return status; } - wr.exp_opcode = IBV_WR_SEND; + wr.exp_opcode = IBV_EXP_WR_SEND; iface->verbs_common.inl_sge[1].addr = (uintptr_t)&dc_req->sender_ep; iface->verbs_common.inl_sge[1].length = sizeof(dc_req->sender_ep); uct_dc_verbs_iface_post_send_to_dci(iface, &wr, dc_ep->dci, ah, @@ -671,7 +671,7 @@ ucs_status_t uct_dc_verbs_ep_fc_ctrl(uct_ep_h tl_ep, unsigned op, ucs_assert(op == UCT_RC_EP_FC_FLAG_HARD_REQ); iface->verbs_common.inl_sge[1].addr = (uintptr_t)&dc_ep; iface->verbs_common.inl_sge[1].length = sizeof(dc_ep); - wr.exp_opcode = IBV_WR_SEND_WITH_IMM; + wr.exp_opcode = IBV_EXP_WR_SEND_WITH_IMM; /* Send out DCT number to the peer, so it will be able * to send grants back */ @@ -791,14 +791,14 @@ void uct_dc_verbs_iface_init_wrs(uct_dc_verbs_iface_t *self) memset(&self->inl_am_wr, 0, sizeof(self->inl_am_wr)); self->inl_am_wr.sg_list = self->verbs_common.inl_sge; self->inl_am_wr.num_sge = 2; - self->inl_am_wr.exp_opcode = IBV_WR_SEND; + self->inl_am_wr.exp_opcode = IBV_EXP_WR_SEND; self->inl_am_wr.exp_send_flags = IBV_SEND_INLINE; self->inl_am_wr.dc.dct_access_key = UCT_IB_KEY; memset(&self->inl_rwrite_wr, 0, sizeof(self->inl_rwrite_wr)); self->inl_rwrite_wr.sg_list = self->verbs_common.inl_sge; self->inl_rwrite_wr.num_sge = 1; - self->inl_rwrite_wr.exp_opcode = IBV_WR_RDMA_WRITE; + self->inl_rwrite_wr.exp_opcode = IBV_EXP_WR_RDMA_WRITE; self->inl_rwrite_wr.exp_send_flags = IBV_SEND_SIGNALED | IBV_SEND_INLINE; self->inl_rwrite_wr.dc.dct_access_key = UCT_IB_KEY; } diff --git a/src/uct/ib/mlx5/ib_mlx5.c b/src/uct/ib/mlx5/ib_mlx5.c index 221165a4f44..5031a9a1038 100644 --- a/src/uct/ib/mlx5/ib_mlx5.c +++ b/src/uct/ib/mlx5/ib_mlx5.c @@ -209,7 +209,7 @@ ucs_status_t uct_ib_mlx5_get_compact_av(uct_ib_iface_t *iface, int *compact_av) int is_global; /* coverity[result_independent_of_operands] */ - ib_addr = ucs_alloca(iface->addr_size); + ib_addr = ucs_alloca((size_t)iface->addr_size); status = uct_ib_iface_get_device_address(&iface->super.super, (uct_device_addr_t*)ib_addr); diff --git a/src/uct/ib/rc/verbs/rc_verbs_common.h b/src/uct/ib/rc/verbs/rc_verbs_common.h index e8751f29227..261dc96ff21 100644 --- a/src/uct/ib/rc/verbs/rc_verbs_common.h +++ b/src/uct/ib/rc/verbs/rc_verbs_common.h @@ -199,12 +199,12 @@ uct_rc_verbs_iface_fill_inl_am_sge(uct_rc_verbs_iface_common_t *iface, #define UCT_RC_VERBS_FILL_AM_BCOPY_WR(_wr, _sge, _length, _wr_opcode) \ UCT_RC_VERBS_FILL_SGE(_wr, _sge, _length) \ - _wr_opcode = IBV_WR_SEND; + _wr_opcode = (typeof(_wr_opcode))IBV_WR_SEND; #define UCT_RC_VERBS_FILL_AM_ZCOPY_WR_IOV(_wr, _sge, _iovlen, _wr_opcode) \ _wr.sg_list = _sge; \ _wr.num_sge = _iovlen; \ - _wr_opcode = IBV_WR_SEND; + _wr_opcode = (typeof(_wr_opcode))IBV_WR_SEND; #define UCT_RC_VERBS_FILL_RDMA_WR(_wr, _wr_opcode, _opcode, \ _sge, _length, _raddr, _rkey) \ diff --git a/src/uct/ib/rc/verbs/rc_verbs_ep.c b/src/uct/ib/rc/verbs/rc_verbs_ep.c index 2d6ad42c85a..bbde9013da1 100644 --- a/src/uct/ib/rc/verbs/rc_verbs_ep.c +++ b/src/uct/ib/rc/verbs/rc_verbs_ep.c @@ -37,7 +37,7 @@ uct_rc_verbs_ep_post_send(uct_rc_verbs_iface_t* iface, uct_rc_verbs_ep_t* ep, uct_rc_verbs_txqp_posted(&ep->super.txqp, &ep->txcnt, &iface->super, send_flags & IBV_SEND_SIGNALED); } -#if HAVE_DECL_IBV_EXP_POST_SEND +#if HAVE_DECL_IBV_EXP_POST_SEND && (HAVE_DECL_IBV_EXP_WR_NOP || HAVE_IB_EXT_ATOMICS) static UCS_F_ALWAYS_INLINE void uct_rc_verbs_exp_post_send(uct_rc_verbs_ep_t *ep, struct ibv_exp_send_wr *wr, uint64_t signal) diff --git a/src/uct/ib/ud/base/ud_ep.c b/src/uct/ib/ud/base/ud_ep.c index 6df21b31123..4c3911d17f2 100644 --- a/src/uct/ib/ud/base/ud_ep.c +++ b/src/uct/ib/ud/base/ud_ep.c @@ -600,7 +600,7 @@ void uct_ud_ep_process_rx(uct_ud_iface_t *iface, uct_ud_neth_t *neth, unsigned b } if (ucs_unlikely(!is_am)) { - if ((byte_len == sizeof(*neth))) { + if ((size_t)byte_len == sizeof(*neth)) { goto out; } if (neth->packet_type & UCT_UD_PACKET_FLAG_CTL) { diff --git a/src/uct/ib/ud/base/ud_iface.h b/src/uct/ib/ud/base/ud_iface.h index dda9579401d..82e362e42ed 100644 --- a/src/uct/ib/ud/base/ud_iface.h +++ b/src/uct/ib/ud/base/ud_iface.h @@ -16,10 +16,12 @@ #include #include #include +#include #include "ud_def.h" #include "ud_ep.h" +BEGIN_C_DECLS #define UCT_UD_MIN_INLINE 48 @@ -447,4 +449,6 @@ uct_ud_iface_dispatch_zcopy_comps(uct_ud_iface_t *iface) #define UCT_UD_CHECK_BCOPY_LENGTH(iface, len) #endif +END_C_DECLS + #endif diff --git a/test/examples/uct_hello_world.c b/test/examples/uct_hello_world.c index b847ddb0bad..7d7129c99a7 100644 --- a/test/examples/uct_hello_world.c +++ b/test/examples/uct_hello_world.c @@ -542,10 +542,10 @@ int main(int argc, char **argv) CHKERR_JUMP(0 != status, "ifaces exchange", out_free_if_addrs); } - own_ep = (uct_ep_addr_t*)calloc(1, if_info.attr.ep_addr_len); - CHKERR_JUMP(NULL == own_ep, "allocate memory for ep addrs", out_free_if_addrs); - if (if_info.attr.cap.flags & UCT_IFACE_FLAG_CONNECT_TO_EP) { + own_ep = (uct_ep_addr_t*)calloc(1, if_info.attr.ep_addr_len); + CHKERR_JUMP(NULL == own_ep, "allocate memory for ep addrs", out_free_if_addrs); + /* Create new endpoint */ status = uct_ep_create(if_info.iface, &ep); CHKERR_JUMP(UCS_OK != status, "create endpoint", out_free_ep_addrs); @@ -553,13 +553,11 @@ int main(int argc, char **argv) /* Get endpoint address */ status = uct_ep_get_address(ep, own_ep); CHKERR_JUMP(UCS_OK != status, "get endpoint address", out_free_ep); - } - status = sendrecv(oob_sock, own_ep, if_info.attr.ep_addr_len, - (void **)&peer_ep); - CHKERR_JUMP(0 != status, "EPs exchange", out_free_ep); + status = sendrecv(oob_sock, own_ep, if_info.attr.ep_addr_len, + (void **)&peer_ep); + CHKERR_JUMP(0 != status, "EPs exchange", out_free_ep); - if (if_info.attr.cap.flags & UCT_IFACE_FLAG_CONNECT_TO_EP) { /* Connect endpoint to a remote endpoint */ status = uct_ep_connect_to_ep(ep, peer_dev, peer_ep); barrier(oob_sock); diff --git a/test/gtest/common/gtest-all.cc b/test/gtest/common/gtest-all.cc index 418282f53be..704b9f64101 100644 --- a/test/gtest/common/gtest-all.cc +++ b/test/gtest/common/gtest-all.cc @@ -7921,7 +7921,6 @@ const char kCurrentDirectoryString[] = ".\\"; # endif // GTEST_OS_WINDOWS_MOBILE #else const char kPathSeparator = '/'; -const char kPathSeparatorString[] = "/"; const char kCurrentDirectoryString[] = "./"; #endif // GTEST_OS_WINDOWS diff --git a/test/gtest/common/main.cc b/test/gtest/common/main.cc index 913d4f53f8d..fe7ca2b50a8 100644 --- a/test/gtest/common/main.cc +++ b/test/gtest/common/main.cc @@ -4,13 +4,11 @@ * See file LICENSE for terms. */ -extern "C" { #ifdef HAVE_CONFIG_H # include "config.h" #endif #include #include -} #include #include "test_helpers.h" #include "tap.h" diff --git a/test/gtest/common/test.cc b/test/gtest/common/test.cc index c9d502180bf..4ad77f337c4 100644 --- a/test/gtest/common/test.cc +++ b/test/gtest/common/test.cc @@ -6,11 +6,9 @@ #include "test.h" -extern "C" { #include #include #include -} namespace ucs { diff --git a/test/gtest/common/test.h b/test/gtest/common/test.h index ce408c02a81..b5bbe82b2ca 100644 --- a/test/gtest/common/test.h +++ b/test/gtest/common/test.h @@ -9,11 +9,9 @@ #include "test_helpers.h" -extern "C" { #include #include #include -} #include #include @@ -31,6 +29,9 @@ class test_base { void set_num_threads(unsigned num_threads); unsigned num_threads() const; + + void get_config(const std::string& name, std::string& value, + size_t max); virtual void set_config(const std::string& config_str); virtual void modify_config(const std::string& name, const std::string& value); virtual void push_config(); diff --git a/test/gtest/common/test_helpers.cc b/test/gtest/common/test_helpers.cc index 126edba6a84..4b660cc1481 100644 --- a/test/gtest/common/test_helpers.cc +++ b/test/gtest/common/test_helpers.cc @@ -6,11 +6,9 @@ #include "test_helpers.h" -extern "C" { #include #include #include -} namespace ucs { diff --git a/test/gtest/ucm/malloc_hook.cc b/test/gtest/ucm/malloc_hook.cc index 18b16587c92..b0df9b2b628 100644 --- a/test/gtest/ucm/malloc_hook.cc +++ b/test/gtest/ucm/malloc_hook.cc @@ -21,6 +21,11 @@ extern "C" { #include } +#if HAVE_MALLOC_SET_STATE && HAVE_MALLOC_GET_STATE +# define HAVE_MALLOC_STATES 1 +#endif /* HAVE_MALLOC_SET_STATE && HAVE_MALLOC_GET_STATE */ + + class malloc_hook : public ucs::test { protected: virtual void init() { @@ -256,10 +261,13 @@ void test_thread::test() { malloc_trim(0); ptr = malloc(large_alloc_size); + +#if HAVE_MALLOC_STATES if (!RUNNING_ON_VALGRIND) { void *state = malloc_get_state(); malloc_set_state(state); } +#endif /* HAVE_MALLOC_STATES */ free(ptr); /* shmat/shmdt */ diff --git a/test/gtest/ucp/test_ucp_wireup.cc b/test/gtest/ucp/test_ucp_wireup.cc index 211cc90d0b9..bf335c08ae3 100644 --- a/test/gtest/ucp/test_ucp_wireup.cc +++ b/test/gtest/ucp/test_ucp_wireup.cc @@ -58,7 +58,6 @@ class test_ucp_wireup : public ucp_test { private: vec_type m_send_data; vec_type m_recv_data; - size_t m_max_send; ucp_mem_h m_memh1, m_memh2; ucp_rkey_h m_rkey1, m_rkey2; diff --git a/test/gtest/ucp/ucp_test.cc b/test/gtest/ucp/ucp_test.cc index f83a416692e..2cd147f3084 100644 --- a/test/gtest/ucp/ucp_test.cc +++ b/test/gtest/ucp/ucp_test.cc @@ -6,10 +6,8 @@ #include "ucp_test.h" #include -extern "C" { #include #include -} std::string ucp_test::m_last_err_msg; diff --git a/test/gtest/ucp/ucp_test.h b/test/gtest/ucp/ucp_test.h index 069f8e35e36..ddadfae5754 100644 --- a/test/gtest/ucp/ucp_test.h +++ b/test/gtest/ucp/ucp_test.h @@ -6,7 +6,6 @@ #ifndef UCP_TEST_H_ #define UCP_TEST_H_ -extern "C" { #include #include @@ -15,7 +14,6 @@ extern "C" { #error possible bug in UCP version #endif -} #include #define MT_TEST_NUM_THREADS 4 diff --git a/test/gtest/ucs/test_datatype.cc b/test/gtest/ucs/test_datatype.cc index c86b698481b..ebfe18cb589 100644 --- a/test/gtest/ucs/test_datatype.cc +++ b/test/gtest/ucs/test_datatype.cc @@ -419,7 +419,7 @@ UCS_TEST_F(test_datatype, ptr_array_random) { std::advance(iter, to_remove); unsigned index = iter->first; - void *ptr; + void *ptr = NULL; EXPECT_TRUE(ucs_ptr_array_lookup(&pa, index, ptr)); EXPECT_EQ(ptr, map[index]); free(ptr); diff --git a/test/gtest/ucs/test_log.cc b/test/gtest/ucs/test_log.cc new file mode 100644 index 00000000000..731179dddf0 --- /dev/null +++ b/test/gtest/ucs/test_log.cc @@ -0,0 +1,95 @@ +/** +* Copyright (C) Mellanox Technologies Ltd. 2001-2017. ALL RIGHTS RESERVED. +* See file LICENSE for terms. +*/ + +#include +extern "C" { +#include +} + +class log_test : public ucs::test { + +public: + virtual void init() { + char ucs_log_spec[70]; + ucs::test::init(); + + /* skip because logger does not support file + * output on valgrind + */ + if (RUNNING_ON_VALGRIND) { + UCS_TEST_SKIP_R("skipping on valgrind"); + } + + ucs_log_cleanup(); + push_config(); + snprintf(logfile, sizeof(logfile), "/tmp/gtest_ucs_log.%d", getpid()); + unlink(logfile); + snprintf(ucs_log_spec, sizeof(ucs_log_spec), "file:%s", logfile); + modify_config("LOG_FILE", ucs_log_spec); + modify_config("LOG_LEVEL", "info"); + ucs_log_init(); + } + + virtual void cleanup() { + ucs_log_cleanup(); + pop_config(); + check_log_file(); + unlink(logfile); + ucs_log_init(); + ucs::test::cleanup(); + } + + virtual void check_log_file() { + ADD_FAILURE(); + } + + int do_grep(const char *needle) { + char cmd[128]; + + snprintf(cmd, sizeof(cmd), "grep '%s' %s", needle, logfile); + return system(cmd); + } + +protected: + char logfile[64]; +}; + +class log_test_info : public log_test { + virtual void check_log_file() { + if (do_grep("UCX INFO hello world")) { + ADD_FAILURE(); + } + } +}; + +UCS_TEST_F(log_test_info, hello) { + ucs_info("hello world"); +} + + +class log_test_print : public log_test { + virtual void check_log_file() { + if (do_grep("UCX PRINT debug message")) { + if (ucs_global_opts.log_print_enable) { + /* not found but it should be there */ + ADD_FAILURE(); + } + } else { + if (!ucs_global_opts.log_print_enable) { + /* found but prints disabled!!! */ + ADD_FAILURE(); + } + } + } +}; + +UCS_TEST_F(log_test_print, print_on, "LOG_PRINT_ENABLE=y") { + ucs_print("debug message"); +} + +UCS_TEST_F(log_test_print, print_off) { + ucs_print("debug message"); +} + diff --git a/test/gtest/uct/test_rc.h b/test/gtest/uct/test_rc.h index 9743504bec9..c10e9e84798 100644 --- a/test/gtest/uct/test_rc.h +++ b/test/gtest/uct/test_rc.h @@ -7,13 +7,12 @@ #ifndef UCT_RC_TEST_H_ #define UCT_RC_TEST_H_ -extern "C" { +#include +#include + #include #include #include -} -#include -#include "uct_test.h" class test_rc : public uct_test { public: diff --git a/test/gtest/uct/uct_test.cc b/test/gtest/uct/uct_test.cc index 56745600551..3707db4ed80 100644 --- a/test/gtest/uct/uct_test.cc +++ b/test/gtest/uct/uct_test.cc @@ -6,9 +6,8 @@ #include "uct_test.h" -extern "C" { #include -} +#include #include #include #include diff --git a/test/gtest/uct/uct_test.h b/test/gtest/uct/uct_test.h index cc311c6fed5..31145c3ef88 100644 --- a/test/gtest/uct/uct_test.h +++ b/test/gtest/uct/uct_test.h @@ -9,11 +9,9 @@ #ifndef UCT_TEST_H_ #define UCT_TEST_H_ -extern "C" { #include #include #include -} #include #include @@ -188,6 +186,7 @@ class uct_test : public testing::TestWithParam, virtual void init(); virtual void cleanup(); virtual void modify_config(const std::string& name, const std::string& value); + bool get_config(const std::string& name, std::string& value) const; void stats_activate(); void stats_restore(); diff --git a/test/gtest/uct/ud_base.h b/test/gtest/uct/ud_base.h index a5f1bd25a17..8f6c33bd8ce 100644 --- a/test/gtest/uct/ud_base.h +++ b/test/gtest/uct/ud_base.h @@ -6,13 +6,11 @@ #ifndef _UD_BASE_TEST #define _UD_BASE_TEST -#include "uct_test.h" -extern "C" { +#include #include #include #include #include -}; #define TEST_UD_PROGRESS_TIMEOUT 300.0 #define TEST_UD_TIMEOUT_IN_SEC 10.0