diff --git a/openmp/runtime/src/thirdparty/ittnotify/LICENSE.txt b/openmp/runtime/src/thirdparty/ittnotify/LICENSE.txt new file mode 100644 --- /dev/null +++ b/openmp/runtime/src/thirdparty/ittnotify/LICENSE.txt @@ -0,0 +1,8 @@ +Copyright (c) 2019 Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. 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. +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/openmp/runtime/src/thirdparty/ittnotify/disable_warnings.h b/openmp/runtime/src/thirdparty/ittnotify/disable_warnings.h --- a/openmp/runtime/src/thirdparty/ittnotify/disable_warnings.h +++ b/openmp/runtime/src/thirdparty/ittnotify/disable_warnings.h @@ -1,4 +1,4 @@ -// clang-format off + //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -11,20 +11,22 @@ #if ITT_PLATFORM == ITT_PLATFORM_WIN -#pragma warning(disable: 593) /* parameter "XXXX" was set but never used */ -#pragma warning(disable: 344) /* typedef name has already been declared (with +#pragma warning(disable : 593) /* parameter "XXXX" was set but never used */ +#pragma warning(disable : 344) /* typedef name has already been declared (with \ same type) */ -#pragma warning(disable: 174) /* expression has no effect */ -#pragma warning(disable: 4127) /* conditional expression is constant */ -#pragma warning(disable: 4306) /* conversion from '?' to '?' of greater size */ +#pragma warning(disable : 174) /* expression has no effect */ +#pragma warning(disable : 4127) /* conditional expression is constant */ +#pragma warning( \ + disable : 4306) /* conversion from '?' to '?' of greater size */ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ #if defined __INTEL_COMPILER -#pragma warning(disable: 869) /* parameter "XXXXX" was never referenced */ -#pragma warning(disable: 1418) /* external function definition with no prior - declaration */ -#pragma warning(disable: 1419) /* external declaration in primary source file */ +#pragma warning(disable : 869) /* parameter "XXXXX" was never referenced */ +#pragma warning(disable : 1418) /* external function definition with no prior \ + declaration */ +#pragma warning( \ + disable : 1419) /* external declaration in primary source file */ #endif /* __INTEL_COMPILER */ diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify.h b/openmp/runtime/src/thirdparty/ittnotify/ittnotify.h --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify.h +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify.h @@ -15,7 +15,8 @@ @brief Public User API functions and types @mainpage -The ITT API is used to annotate a user's program with additional information +The Instrumentation and Tracing Technology API (ITT API) is used to +annotate a user's program with additional information that can be used by correctness and performance tools. The user inserts calls in their program. Those calls generate information that is collected at runtime, and used by Intel(R) Threading Tools. @@ -180,7 +181,13 @@ #if ITT_PLATFORM == ITT_PLATFORM_WIN /* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline +#if defined(__MINGW32__) && !defined(__cplusplus) +#define ITT_INLINE \ + static __inline__ __attribute__((__always_inline__, __gnu_inline__)) +#else +#define ITT_INLINE static __forceinline +#endif /* __MINGW32__ */ + #define ITT_INLINE_ATTRIBUTE /* nothing */ #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ /* @@ -372,6 +379,91 @@ /** @} control group */ /** @endcond */ +/** + * @defgroup Intel Processor Trace control + * API from this group provides control over collection and analysis of Intel + * Processor Trace (Intel PT) data Information about Intel Processor Trace + * technology can be found here (Volume 3 chapter 35): + * https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf + * Use this API to mark particular code regions for loading detailed performance + * statistics. This mode makes your analysis faster and more accurate. + * @{ + */ +typedef unsigned char __itt_pt_region; + +/** + * @brief function saves a region name marked with Intel PT API and returns a + * region id. Only 7 names can be registered. Attempts to register more names + * will be ignored and a region id with auto names will be returned. For + * automatic naming of regions pass NULL as function parameter + */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +__itt_pt_region ITTAPI __itt_pt_region_createA(const char *name); +__itt_pt_region ITTAPI __itt_pt_region_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +#define __itt_pt_region_create __itt_pt_region_createW +#else /* UNICODE */ +#define __itt_pt_region_create __itt_pt_region_createA +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_pt_region ITTAPI __itt_pt_region_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM == ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_pt_region_createA ITTNOTIFY_DATA(pt_region_createA) +#define __itt_pt_region_createA_ptr ITTNOTIFY_NAME(pt_region_createA) +#define __itt_pt_region_createW ITTNOTIFY_DATA(pt_region_createW) +#define __itt_pt_region_createW_ptr ITTNOTIFY_NAME(pt_region_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_pt_region_create ITTNOTIFY_DATA(pt_region_create) +#define __itt_pt_region_create_ptr ITTNOTIFY_NAME(pt_region_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_pt_region_createA(name) (__itt_pt_region)0 +#define __itt_pt_region_createA_ptr 0 +#define __itt_pt_region_createW(name) (__itt_pt_region)0 +#define __itt_pt_region_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_pt_region_create(name) (__itt_pt_region)0 +#define __itt_pt_region_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_pt_region_createA_ptr 0 +#define __itt_pt_region_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_pt_region_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief function contains a special code pattern identified on the + * post-processing stage and marks the beginning of a code region targeted for + * Intel PT analysis + * @param[in] region - region id, 0 <= region < 8 + */ +void __itt_mark_pt_region_begin(__itt_pt_region region); +/** + * @brief function contains a special code pattern identified on the + * post-processing stage and marks the end of a code region targeted for Intel + * PT analysis + * @param[in] region - region id, 0 <= region < 8 + */ +void __itt_mark_pt_region_end(__itt_pt_region region); +/** @} Intel PT control group*/ + /** * @defgroup threads Threads * @ingroup public @@ -467,11 +559,9 @@ * @{ */ -// clang-format off -/*****************************************************************//** +/********************************************************************* * @name group of functions used for error suppression in correctness tools *********************************************************************/ -// clang-format on /** @{ */ /** * @hideinitializer @@ -765,11 +855,9 @@ #endif /* INTEL_NO_MACRO_BODY */ /** @endcond */ -// clang-format off -/*****************************************************************//** +/********************************************************************* * @name group of functions is used for performance measurement tools *********************************************************************/ -// clang-format on /** @{ */ /** * @brief Enter spin loop on user-defined sync object @@ -855,11 +943,9 @@ /** @} sync group */ -// clang-format off -/**************************************************************//** +/****************************************************************** * @name group of functions is used for correctness checking tools ******************************************************************/ -// clang-format on /** @{ */ /** * @ingroup legacy @@ -2449,7 +2535,7 @@ * name of the metadata), and a value (the actual data). The encoding of * the value depends on the type of the metadata. * - * The type of metadata is specified by an enumerated type __itt_metadata_type. + * The type of metadata is specified by an enumerated type __itt_metdata_type. * @{ */ @@ -3530,7 +3616,7 @@ ITTNOTIFY_VOID_D5(relation_add_ex, d, x, y, z, a, b) #define __itt_relation_add_ex_ptr ITTNOTIFY_NAME(relation_add_ex) #else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_relation_add_to_current_ex(domain, clock_domain, timestamp, \ +#define __itt_relation_add_to_current_ex(domain, clock_domain, timestame, \ relation, tail) #define __itt_relation_add_to_current_ex_ptr 0 #define __itt_relation_add_ex(domain, clock_domain, timestamp, head, relation, \ @@ -3903,11 +3989,13 @@ /** @endcond */ /** - * @brief Module load info - * This API is used to report necessary information in case of module relocation - * @param[in] start_addr - relocated module start address - * @param[in] end_addr - relocated module end address - * @param[in] path - file system path to the module + * @brief Module load notification + * This API is used to report necessary information in case of bypassing default + * system loader. Notification should be done immidiatelly after this module is + * loaded to process memory. + * @param[in] start_addr - module start address + * @param[in] end_addr - module end address + * @param[in] path - file system full path to the module */ #if ITT_PLATFORM == ITT_PLATFORM_WIN void ITTAPI __itt_module_loadA(void *start_addr, void *end_addr, @@ -3968,6 +4056,319 @@ #endif /* INTEL_NO_MACRO_BODY */ /** @endcond */ +/** + * @brief Report module unload + * This API is used to report necessary information in case of bypassing default + * system loader. Notification should be done just before the module is unloaded + * from process memory. + * @param[in] addr - base address of loaded module + */ +void ITTAPI __itt_module_unload(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, module_unload, (void *addr)) +#define __itt_module_unload ITTNOTIFY_VOID(module_unload) +#define __itt_module_unload_ptr ITTNOTIFY_NAME(module_unload) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_module_unload(addr) +#define __itt_module_unload_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_module_unload_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef enum { + __itt_module_type_unknown = 0, + __itt_module_type_elf, + __itt_module_type_coff +} __itt_module_type; +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef enum { + itt_section_type_unknown, + itt_section_type_bss, /* notifies that the section contains uninitialized + * data. These are the relevant section types and the + * modules that contain them: ELF module: SHT_NOBITS + * section type COFF module: + * IMAGE_SCN_CNT_UNINITIALIZED_DATA section type + */ + itt_section_type_data, /* notifies that section contains initialized data. + * These are the relevant section types and the modules + * that contain them: ELF module: SHT_PROGBITS section + * type COFF module: IMAGE_SCN_CNT_INITIALIZED_DATA + * section type + */ + itt_section_type_text /* notifies that the section contains executable code. + * These are the relevant section types and the modules + * that contain them: ELF module: SHT_PROGBITS section + * type COFF module: IMAGE_SCN_CNT_CODE section type + */ +} __itt_section_type; +/** @endcond */ + +/** + * @hideinitializer + * @brief bit-mask, detects a section attribute that indicates whether a section + * can be executed as code: These are the relevant section attributes and the + * modules that contain them: ELF module: PF_X section attribute COFF module: + * IMAGE_SCN_MEM_EXECUTE attribute + */ +#define __itt_section_exec 0x20000000 + +/** + * @hideinitializer + * @brief bit-mask, detects a section attribute that indicates whether a section + * can be read. These are the relevant section attributes and the modules that + * contain them: ELF module: PF_R attribute COFF module: IMAGE_SCN_MEM_READ + * attribute + */ +#define __itt_section_read 0x40000000 + +/** + * @hideinitializer + * @brief bit-mask, detects a section attribute that indicates whether a section + * can be written to. These are the relevant section attributes and the modules + * that contain them: ELF module: PF_W attribute COFF module: + * IMAGE_SCN_MEM_WRITE attribute + */ +#define __itt_section_write 0x80000000 + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_section_info { + const char *name; /*!< Section name in UTF8 */ + __itt_section_type type; /*!< Section content and semantics description */ + size_t flags; /*!< Section bit flags that describe attributes using bit mask + * Zero if disabled, non-zero if enabled + */ + void *start_addr; /*!< Section load(relocated) start address */ + size_t size; /*!< Section file offset */ + size_t file_offset; /*!< Section size */ +} __itt_section_info; + +#pragma pack(pop) +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_module_object { + unsigned int version; /*!< API version*/ + __itt_id module_id; /*!< Unique identifier. This is unchanged for sections + that belong to the same module */ + __itt_module_type module_type; /*!< Binary module format */ + const char *module_name; /*!< Unique module name or path to module in UTF8 + * Contains module name when module_bufer and + * module_size exist Contains module path when + * module_bufer and module_size absent module_name + * remains the same for the certain module_id + */ + void *module_buffer; /*!< Module buffer content */ + size_t module_size; /*!< Module buffer size */ + /*!< If module_buffer and module_size exist, the binary module is dumped onto + * the system. If module_buffer and module_size do not exist, the binary + * module exists on the system already. The module_name parameter contains the + * path to the module. + */ + __itt_section_info *section_array; /*!< Reference to section information */ + size_t section_number; +} __itt_module_object; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Load module content and its loaded(relocated) sections. + * This API is useful to save a module, or specify its location on the system + * and report information about loaded sections. The target module is saved on + * the system if module buffer content and size are available. If module buffer + * content and size are unavailable, the module name contains the path to the + * existing binary module. + * @param[in] module_obj - provides module and section information, along with + * unique module identifiers (name,module ID) which bind the binary module to + * particular sections. + */ +void ITTAPI __itt_module_load_with_sections(__itt_module_object *module_obj); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, module_load_with_sections, + (__itt_module_object * module_obj)) +#define __itt_module_load_with_sections \ + ITTNOTIFY_VOID(module_load_with_sections) +#define __itt_module_load_with_sections_ptr \ + ITTNOTIFY_NAME(module_load_with_sections) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_module_load_with_sections(module_obj) +#define __itt_module_load_with_sections_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_module_load_with_sections_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Unload a module and its loaded(relocated) sections. + * This API notifies that the module and its sections were unloaded. + * @param[in] module_obj - provides module and sections information, along with + * unique module identifiers (name,module ID) which bind the binary module to + * particular sections. + */ +void ITTAPI __itt_module_unload_with_sections(__itt_module_object *module_obj); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, module_unload_with_sections, + (__itt_module_object * module_obj)) +#define __itt_module_unload_with_sections \ + ITTNOTIFY_VOID(module_unload_with_sections) +#define __itt_module_unload_with_sections_ptr \ + ITTNOTIFY_NAME(module_unload_with_sections) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_module_unload_with_sections(module_obj) +#define __itt_module_unload_with_sections_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_module_unload_with_sections_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_histogram { + const __itt_domain *domain; /*!< Domain of the histogram*/ + const char *nameA; /*!< Name of the histogram */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t *nameW; +#else /* UNICODE || _UNICODE */ + void *nameW; +#endif /* UNICODE || _UNICODE */ + __itt_metadata_type x_type; /*!< Type of the histogram X axis */ + __itt_metadata_type y_type; /*!< Type of the histogram Y axis */ + int extra1; /*!< Reserved to the runtime */ + void *extra2; /*!< Reserved to the runtime */ + struct ___itt_histogram *next; +} __itt_histogram; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Create a typed histogram instance with given name/domain. + * @param[in] domain The domain controlling the call. + * @param[in] name The name of the histogram. + * @param[in] x_type The type of the X axis in histogram (may be 0 to calculate + * batch statistics). + * @param[in] y_type The type of the Y axis in histogram. + */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +__itt_histogram *ITTAPI __itt_histogram_createA(const __itt_domain *domain, + const char *name, + __itt_metadata_type x_type, + __itt_metadata_type y_type); +__itt_histogram *ITTAPI __itt_histogram_createW(const __itt_domain *domain, + const wchar_t *name, + __itt_metadata_type x_type, + __itt_metadata_type y_type); +#if defined(UNICODE) || defined(_UNICODE) +#define __itt_histogram_create __itt_histogram_createW +#define __itt_histogram_create_ptr __itt_histogram_createW_ptr +#else /* UNICODE */ +#define __itt_histogram_create __itt_histogram_createA +#define __itt_histogram_create_ptr __itt_histogram_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_histogram *ITTAPI __itt_histogram_create(const __itt_domain *domain, + const char *name, + __itt_metadata_type x_type, + __itt_metadata_type y_type); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM == ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_histogram *, histogram_createA, + (const __itt_domain *domain, const char *name, + __itt_metadata_type x_type, __itt_metadata_type y_type)) +ITT_STUB(ITTAPI, __itt_histogram *, histogram_createW, + (const __itt_domain *domain, const wchar_t *name, + __itt_metadata_type x_type, __itt_metadata_type y_type)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_histogram *, histogram_create, + (const __itt_domain *domain, const char *name, + __itt_metadata_type x_type, __itt_metadata_type y_type)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_histogram_createA ITTNOTIFY_DATA(histogram_createA) +#define __itt_histogram_createA_ptr ITTNOTIFY_NAME(histogram_createA) +#define __itt_histogram_createW ITTNOTIFY_DATA(histogram_createW) +#define __itt_histogram_createW_ptr ITTNOTIFY_NAME(histogram_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_histogram_create ITTNOTIFY_DATA(histogram_create) +#define __itt_histogram_create_ptr ITTNOTIFY_NAME(histogram_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_histogram_createA(domain, name, x_type, y_type) \ + (__itt_histogram *)0 +#define __itt_histogram_createA_ptr 0 +#define __itt_histogram_createW(domain, name, x_type, y_type) \ + (__itt_histogram *)0 +#define __itt_histogram_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_histogram_create(domain, name, x_type, y_type) \ + (__itt_histogram *)0 +#define __itt_histogram_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#define __itt_histogram_createA_ptr 0 +#define __itt_histogram_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_histogram_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Submit statistics for a histogram instance. + * @param[in] hist Pointer to the histogram instance to which the histogram + * statistic is to be dumped. + * @param[in] length The number of elements in dumped axis data array. + * @param[in] x_data The X axis dumped data itself (may be NULL to calculate + * batch statistics). + * @param[in] y_data The Y axis dumped data itself. + */ +void ITTAPI __itt_histogram_submit(__itt_histogram *hist, size_t length, + void *x_data, void *y_data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, histogram_submit, + (__itt_histogram * hist, size_t length, void *x_data, void *y_data)) +#define __itt_histogram_submit ITTNOTIFY_VOID(histogram_submit) +#define __itt_histogram_submit_ptr ITTNOTIFY_NAME(histogram_submit) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_histogram_submit(hist, length, x_data, y_data) +#define __itt_histogram_submit_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_histogram_submit_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h @@ -114,7 +114,13 @@ #if ITT_PLATFORM == ITT_PLATFORM_WIN /* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline +#if defined(__MINGW32__) && !defined(__cplusplus) +#define ITT_INLINE \ + static __inline__ __attribute__((__always_inline__, __gnu_inline__)) +#else +#define ITT_INLINE static __forceinline +#endif /* __MINGW32__ */ + #define ITT_INLINE_ATTRIBUTE /* nothing */ #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ /* @@ -140,10 +146,9 @@ #define ITT_ARCH_IA32E 2 #endif /* ITT_ARCH_IA32E */ -/* Was there a magical reason we didn't have 3 here before? */ -#ifndef ITT_ARCH_AARCH64 -#define ITT_ARCH_AARCH64 3 -#endif /* ITT_ARCH_AARCH64 */ +#ifndef ITT_ARCH_IA64 +#define ITT_ARCH_IA64 3 +#endif /* ITT_ARCH_IA64 */ #ifndef ITT_ARCH_ARM #define ITT_ARCH_ARM 4 @@ -153,17 +158,9 @@ #define ITT_ARCH_PPC64 5 #endif /* ITT_ARCH_PPC64 */ -#ifndef ITT_ARCH_MIPS -#define ITT_ARCH_MIPS 6 -#endif /* ITT_ARCH_MIPS */ - -#ifndef ITT_ARCH_MIPS64 -#define ITT_ARCH_MIPS64 6 -#endif /* ITT_ARCH_MIPS64 */ - -#ifndef ITT_ARCH_RISCV64 -#define ITT_ARCH_RISCV64 7 -#endif /* ITT_ARCH_RISCV64 */ +#ifndef ITT_ARCH_ARM64 +#define ITT_ARCH_ARM64 6 +#endif /* ITT_ARCH_ARM64 */ #ifndef ITT_ARCH #if defined _M_IX86 || defined __i386__ @@ -174,16 +171,10 @@ #define ITT_ARCH ITT_ARCH_IA64 #elif defined _M_ARM || defined __arm__ #define ITT_ARCH ITT_ARCH_ARM +#elif defined __aarch64__ +#define ITT_ARCH ITT_ARCH_ARM64 #elif defined __powerpc64__ #define ITT_ARCH ITT_ARCH_PPC64 -#elif defined __aarch64__ -#define ITT_ARCH ITT_ARCH_AARCH64 -#elif defined __mips__ && !defined __mips64 -#define ITT_ARCH ITT_ARCH_MIPS -#elif defined __mips__ && defined __mips64 -#define ITT_ARCH ITT_ARCH_MIPS64 -#elif defined __riscv && __riscv_xlen == 64 -#define ITT_ARCH ITT_ARCH_RISCV64 #endif #endif @@ -212,10 +203,10 @@ { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } /* Replace with snapshot date YYYYMMDD for promotion build. */ -#define API_VERSION_BUILD 20151119 +#define API_VERSION_BUILD 20180723 #ifndef API_VERSION_NUM -#define API_VERSION_NUM 0.0.0 +#define API_VERSION_NUM 3.20.1 #endif /* API_VERSION_NUM */ #define API_VERSION \ @@ -228,8 +219,13 @@ typedef HMODULE lib_t; typedef DWORD TIDT; typedef CRITICAL_SECTION mutex_t; +#ifdef __cplusplus +#define MUTEX_INITIALIZER \ + {} +#else #define MUTEX_INITIALIZER \ { 0 } +#endif #define strong_alias(name, aliasname) /* empty for Windows */ #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ #include @@ -318,7 +314,17 @@ #ifdef SDL_STRNCPY_S #define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) #else -#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l) +#define __itt_fstrcpyn(s1, b, s2, l) \ + { \ + if (b > 0) { \ + /* 'volatile' is used to suppress the warning that a destination */ \ + /* bound depends on the length of the source. */ \ + volatile size_t num_to_copy = \ + (size_t)(b - 1) < (size_t)(l) ? (size_t)(b - 1) : (size_t)(l); \ + strncpy(s1, s2, num_to_copy); \ + s1[num_to_copy] = 0; \ + } \ + } #endif /* SDL_STRNCPY_S */ #define __itt_fstrdup(s) strdup(s) @@ -342,9 +348,7 @@ : "memory"); return result; } -#elif ITT_ARCH == ITT_ARCH_ARM || ITT_ARCH == ITT_ARCH_PPC64 || \ - ITT_ARCH == ITT_ARCH_AARCH64 || ITT_ARCH == ITT_ARCH_MIPS || \ - ITT_ARCH == ITT_ARCH_MIPS64 || ITT_ARCH == ITT_ARCH_RISCV64 +#else #define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) #endif /* ITT_ARCH==ITT_ARCH_IA64 */ #ifndef ITT_SIMPLE_INIT @@ -441,6 +445,7 @@ struct ___itt_domain; struct ___itt_string_handle; +struct ___itt_histogram; typedef struct ___itt_global { unsigned char magic[8]; @@ -462,6 +467,8 @@ struct ___itt_string_handle *string_list; __itt_collection_state state; __itt_counter_info_t *counter_list; + unsigned int ipt_collect_events; + struct ___itt_histogram *histogram_list; } __itt_global; #pragma pack(pop) @@ -604,4 +611,40 @@ } \ } +#define NEW_HISTOGRAM_W(gptr, h, h_tail, domain, name, x_type, y_type) \ + { \ + h = (__itt_histogram *)malloc(sizeof(__itt_histogram)); \ + if (h != NULL) { \ + h->domain = domain; \ + h->nameA = NULL; \ + h->nameW = name ? _wcsdup(name) : NULL; \ + h->x_type = x_type; \ + h->y_type = y_type; \ + h->extra1 = 0; \ + h->extra2 = NULL; \ + if (h_tail == NULL) \ + (gptr)->histogram_list = h; \ + else \ + h_tail->next = h; \ + } \ + } + +#define NEW_HISTOGRAM_A(gptr, h, h_tail, domain, name, x_type, y_type) \ + { \ + h = (__itt_histogram *)malloc(sizeof(__itt_histogram)); \ + if (h != NULL) { \ + h->domain = domain; \ + h->nameA = name ? __itt_fstrdup(name) : NULL; \ + h->nameW = NULL; \ + h->x_type = x_type; \ + h->y_type = y_type; \ + h->extra1 = 0; \ + h->extra2 = NULL; \ + if (h_tail == NULL) \ + (gptr)->histogram_list = h; \ + else \ + h_tail->next = h; \ + } \ + } + #endif /* _ITTNOTIFY_CONFIG_H_ */ diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.h b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.h --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.h +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.h @@ -36,6 +36,13 @@ (ITT_FORMAT name), domain_create, __itt_group_structure, "\"%s\"") #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, module_load_with_sections, + (__itt_module_object * module_obj), (ITT_FORMAT module_obj), + module_load_with_sections, __itt_group_module, "%p") +ITT_STUBV(ITTAPI, void, module_unload_with_sections, + (__itt_module_object * module_obj), (ITT_FORMAT module_obj), + module_unload_with_sections, __itt_group_module, "%p") + #if ITT_PLATFORM == ITT_PLATFORM_WIN ITT_STUB(ITTAPI, __itt_string_handle *, string_handle_createA, (const char *name), (ITT_FORMAT name), string_handle_createA, @@ -110,6 +117,26 @@ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ ITT_STUBV(LIBITTAPI, void, thr_ignore, (void), (ITT_NO_PARAMS), thr_ignore, __itt_group_thread | __itt_group_legacy, "no args") + +#if ITT_PLATFORM == ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_histogram *, histogram_createA, + (const __itt_domain *domain, const char *name, + __itt_metadata_type x_type, __itt_metadata_type y_type), + (ITT_FORMAT domain, name, x_type, y_type), histogram_createA, + __itt_group_structure, "%p, \"%s\", %d, %d") +ITT_STUB(ITTAPI, __itt_histogram *, histogram_createW, + (const __itt_domain *domain, const wchar_t *name, + __itt_metadata_type x_type, __itt_metadata_type y_type), + (ITT_FORMAT domain, name, x_type, y_type), histogram_createW, + __itt_group_structure, "%p, \"%s\", %d, %d") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_histogram *, histogram_create, + (const __itt_domain *domain, const char *name, + __itt_metadata_type x_type, __itt_metadata_type y_type), + (ITT_FORMAT domain, name, x_type, y_type), histogram_create, + __itt_group_structure, "%p, \"%s\", %d, %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + #endif /* __ITT_INTERNAL_BODY */ ITT_STUBV(ITTAPI, void, enable_attach, (void), (ITT_NO_PARAMS), enable_attach, @@ -524,6 +551,16 @@ ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain), (ITT_FORMAT domain), frame_create, __itt_group_frame, "\"%s\"") #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM == ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createA, (const char *name), + (ITT_FORMAT name), pt_region_createA, __itt_group_structure, "\"%s\"") +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createW, (const wchar_t *name), + (ITT_FORMAT name), pt_region_createW, __itt_group_structure, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_pt_region, pt_region_create, (const char *name), + (ITT_FORMAT name), pt_region_create, __itt_group_structure, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ #endif /* __ITT_INTERNAL_BODY */ ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame), (ITT_FORMAT frame), frame_begin, __itt_group_frame, "%p") @@ -737,22 +774,27 @@ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ #endif /* __ITT_INTERNAL_BODY */ -#ifndef __ITT_INTERNAL_BODY #if ITT_PLATFORM == ITT_PLATFORM_WIN ITT_STUBV(ITTAPI, void, module_loadA, (void *start_addr, void *end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_loadA, - __itt_group_none, "%p, %p, %p") + __itt_group_module, "%p, %p, %p") ITT_STUBV(ITTAPI, void, module_loadW, (void *start_addr, void *end_addr, const wchar_t *path), (ITT_FORMAT start_addr, end_addr, path), module_loadW, - __itt_group_none, "%p, %p, %p") + __itt_group_module, "%p, %p, %p") #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ ITT_STUBV(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_load, - __itt_group_none, "%p, %p, %p") + __itt_group_module, "%p, %p, %p") #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, module_unload, (void *start_addr), + (ITT_FORMAT start_addr), module_unload, __itt_group_module, "%p") + +ITT_STUBV(ITTAPI, void, histogram_submit, + (__itt_histogram * hist, size_t length, void *x_data, void *y_data), + (ITT_FORMAT hist, length, x_data, y_data), histogram_submit, + __itt_group_structure, "%p, %lu, %p, %p") #endif /* __ITT_INTERNAL_INIT */ diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.cpp b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.cpp --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.cpp +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.cpp @@ -7,14 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "kmp_config.h" -#include "kmp_os.h" +#include "kmp_config.h" // INTEL_ITTNOTIFY_PREFIX definition #include "ittnotify_config.h" #if ITT_PLATFORM == ITT_PLATFORM_WIN -#if defined(__MINGW32__) -#include -#else +#if !defined(PATH_MAX) #define PATH_MAX 512 #endif #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ @@ -32,14 +29,51 @@ #include "ittnotify.h" #include "legacy/ittnotify.h" -#if KMP_MSVC_COMPAT #include "disable_warnings.h" -#endif -static const char api_version[] = API_VERSION "\0\n@(#) $Revision: 481659 $\n"; +static const char api_version[] = API_VERSION "\0\n@(#) $Revision$\n"; #define _N_(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX, n) +#ifndef HAS_CPP_ATTR +#if defined(__cplusplus) && defined(__has_cpp_attribute) +#define HAS_CPP_ATTR(X) __has_cpp_attribute(X) +#else +#define HAS_CPP_ATTR(X) 0 +#endif +#endif + +#ifndef HAS_C_ATTR +#if defined(__STDC__) && defined(__has_c_attribute) +#define HAS_C_ATTR(X) __has_c_attribute(X) +#else +#define HAS_C_ATTR(X) 0 +#endif +#endif + +#ifndef HAS_GNU_ATTR +#if defined(__has_attribute) +#define HAS_GNU_ATTR(X) __has_attribute(X) +#else +#define HAS_GNU_ATTR(X) 0 +#endif +#endif + +#ifndef ITT_ATTRIBUTE_FALLTHROUGH +#if (HAS_CPP_ATTR(fallthrough) || HAS_C_ATTR(fallthrough)) && \ + (__cplusplus >= 201703L || _MSVC_LANG >= 201703L) +#define ITT_ATTRIBUTE_FALLTHROUGH [[fallthrough]] +#elif HAS_CPP_ATTR(gnu::fallthrough) +#define ITT_ATTRIBUTE_FALLTHROUGH [[gnu::fallthrough]] +#elif HAS_CPP_ATTR(clang::fallthrough) +#define ITT_ATTRIBUTE_FALLTHROUGH [[clang::fallthrough]] +#elif HAS_GNU_ATTR(fallthrough) && !__INTEL_COMPILER +#define ITT_ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough)) +#else +#define ITT_ATTRIBUTE_FALLTHROUGH +#endif +#endif + #if ITT_OS == ITT_OS_WIN static const char *ittnotify_lib_name = "libittnotify.dll"; #elif ITT_OS == ITT_OS_LINUX || ITT_OS == ITT_OS_FREEBSD @@ -92,13 +126,8 @@ #endif -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - #ifndef LIB_VAR_NAME -#if ITT_ARCH == ITT_ARCH_IA32 || ITT_ARCH == ITT_ARCH_ARM || \ - ITT_ARCH == ITT_ARCH_MIPS +#if ITT_ARCH == ITT_ARCH_IA32 || ITT_ARCH == ITT_ARCH_ARM #define LIB_VAR_NAME INTEL_LIBITTNOTIFY32 #else #define LIB_VAR_NAME INTEL_LIBITTNOTIFY64 @@ -120,6 +149,8 @@ } \ } +#define ITT_MODULE_OBJECT_VERSION 1 + typedef int(__itt_init_ittlib_t)(const char *, __itt_group_id); /* this define used to control initialization function name. */ @@ -138,6 +169,8 @@ #define __itt_fini_ittlib_name __itt_fini_ittlib_ptr #endif /* __itt_fini_ittlib_name */ +extern __itt_global _N_(_ittapi_global); + /* building pointers to imported funcs */ #undef ITT_STUBV #undef ITT_STUB @@ -148,7 +181,9 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init)); \ ITT_EXTERN_C_END \ static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init)) args { \ - __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (!_N_(_ittapi_global).api_initialized && \ + _N_(_ittapi_global).thread_list == NULL) \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ if (ITTNOTIFY_NAME(name) && \ ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init))) \ return ITTNOTIFY_NAME(name) params; \ @@ -163,7 +198,9 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init)); \ ITT_EXTERN_C_END \ static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init)) args { \ - __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (!_N_(_ittapi_global).api_initialized && \ + _N_(_ittapi_global).thread_list == NULL) \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ if (ITTNOTIFY_NAME(name) && \ ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name), _init))) \ ITTNOTIFY_NAME(name) params; \ @@ -218,13 +255,13 @@ #pragma pack(pop) -// clang-format off -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(push) -#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function - pointer 'XXX' to data pointer 'void *' */ +#pragma warning(disable : 4054) /* warning C4054: 'type cast' : from function \ + pointer 'XXX' to data pointer 'void *' */ +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -// clang-format onĂ¥ static __itt_api_info api_list[] = { /* Define functions with static implementation */ @@ -252,8 +289,10 @@ #include "ittnotify_static.h" {NULL, NULL, NULL, NULL, __itt_group_none}}; -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(pop) +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ /* static part descriptor which handles. all notification api attributes. */ @@ -275,48 +314,48 @@ NULL, /* domain_list */ NULL, /* string_list */ __itt_collection_normal, /* collection state */ - NULL /* counter_list */ + NULL, /* counter_list */ + 0, /* ipt_collect_events */ + NULL /* histogram_list */ }; typedef void(__itt_api_init_t)(__itt_global *, __itt_group_id); typedef void(__itt_api_fini_t)(__itt_global *); +static __itt_domain dummy_domain; /* ========================================================================= */ #ifdef ITT_NOTIFY_EXT_REPORT ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); #endif /* ITT_NOTIFY_EXT_REPORT */ -// clang-format off -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(push) -#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer - 'void *' to function pointer 'XXX' */ +#pragma warning( \ + disable : 4055) /* warning C4055: 'type cast' : from data pointer 'void *' \ + to function pointer 'XXX' */ +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -// clang-format on -static void __itt_report_error(unsigned code_arg, ...) { +static void __itt_report_error(int code, ...) { va_list args; - va_start(args, code_arg); - - // We use unsigned for the code argument and explicitly cast it here to the - // right enumerator because variadic functions are not compatible with - // default promotions. - __itt_error_code code = (__itt_error_code)code_arg; - + va_start(args, code); if (_N_(_ittapi_global).error_handler != NULL) { __itt_error_handler_t *handler = (__itt_error_handler_t *)(size_t)_N_(_ittapi_global).error_handler; - handler(code, args); + handler((__itt_error_code)code, args); } #ifdef ITT_NOTIFY_EXT_REPORT - _N_(error_handler)(code, args); + _N_(error_handler)((__itt_error_code)code, args); #endif /* ITT_NOTIFY_EXT_REPORT */ va_end(args); } -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(pop) +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ #if ITT_PLATFORM == ITT_PLATFORM_WIN @@ -335,6 +374,9 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW), _init))) { __itt_mutex_unlock(&_N_(_ittapi_global).mutex); return ITTNOTIFY_NAME(domain_createW)(name); + } else { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return &dummy_domain; } } for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; @@ -381,6 +423,15 @@ return ITTNOTIFY_NAME(domain_create)(name); } #endif + else { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#else + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif + return &dummy_domain; + } } for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) { @@ -395,6 +446,38 @@ return h; } +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN( + _N_(module_load_with_sections), _init))(__itt_module_object *module_obj) { + if (!_N_(_ittapi_global).api_initialized && + _N_(_ittapi_global).thread_list == NULL) { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(module_load_with_sections) && + ITTNOTIFY_NAME(module_load_with_sections) != + ITT_VERSIONIZE(ITT_JOIN(_N_(module_load_with_sections), _init))) { + if (module_obj != NULL) { + module_obj->version = ITT_MODULE_OBJECT_VERSION; + ITTNOTIFY_NAME(module_load_with_sections)(module_obj); + } + } +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN( + _N_(module_unload_with_sections), _init))(__itt_module_object *module_obj) { + if (!_N_(_ittapi_global).api_initialized && + _N_(_ittapi_global).thread_list == NULL) { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(module_unload_with_sections) && + ITTNOTIFY_NAME(module_unload_with_sections) != + ITT_VERSIONIZE(ITT_JOIN(_N_(module_unload_with_sections), _init))) { + if (module_obj != NULL) { + module_obj->version = ITT_MODULE_OBJECT_VERSION; + ITTNOTIFY_NAME(module_unload_with_sections)(module_obj); + } + } +} + #if ITT_PLATFORM == ITT_PLATFORM_WIN static __itt_string_handle *ITTAPI ITT_VERSIONIZE( ITT_JOIN(_N_(string_handle_createW), _init))(const wchar_t *name) { @@ -411,6 +494,9 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW), _init))) { __itt_mutex_unlock(&_N_(_ittapi_global).mutex); return ITTNOTIFY_NAME(string_handle_createW)(name); + } else { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return NULL; } } for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; @@ -456,6 +542,15 @@ return ITTNOTIFY_NAME(string_handle_create)(name); } #endif + else { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#else + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif + return NULL; + } } for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) { @@ -487,11 +582,14 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(counter_createW), _init))) { __itt_mutex_unlock(&_N_(_ittapi_global).mutex); return ITTNOTIFY_NAME(counter_createW)(name, domain); + } else { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return NULL; } } for (h_tail = NULL, h = _N_(_ittapi_global).counter_list; h != NULL; h_tail = h, h = h->next) { - if (h->nameW != NULL && h->type == type && !wcscmp(h->nameW, name) && + if (h->nameW != NULL && h->type == (int)type && !wcscmp(h->nameW, name) && ((h->domainW == NULL && domain == NULL) || (h->domainW != NULL && domain != NULL && !wcscmp(h->domainW, domain)))) break; @@ -537,10 +635,20 @@ return ITTNOTIFY_NAME(counter_create)(name, domain); } #endif + else { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#else + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif + return NULL; + } } for (h_tail = NULL, h = _N_(_ittapi_global).counter_list; h != NULL; h_tail = h, h = h->next) { - if (h->nameA != NULL && h->type == type && !__itt_fstrcmp(h->nameA, name) && + if (h->nameA != NULL && h->type == (int)type && + !__itt_fstrcmp(h->nameA, name) && ((h->domainA == NULL && domain == NULL) || (h->domainA != NULL && domain != NULL && !__itt_fstrcmp(h->domainA, domain)))) @@ -571,11 +679,14 @@ ITT_VERSIONIZE(ITT_JOIN(_N_(counter_create_typedW), _init))) { __itt_mutex_unlock(&_N_(_ittapi_global).mutex); return ITTNOTIFY_NAME(counter_create_typedW)(name, domain, type); + } else { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return NULL; } } for (h_tail = NULL, h = _N_(_ittapi_global).counter_list; h != NULL; h_tail = h, h = h->next) { - if (h->nameW != NULL && h->type == type && !wcscmp(h->nameW, name) && + if (h->nameW != NULL && h->type == (int)type && !wcscmp(h->nameW, name) && ((h->domainW == NULL && domain == NULL) || (h->domainW != NULL && domain != NULL && !wcscmp(h->domainW, domain)))) break; @@ -620,10 +731,20 @@ return ITTNOTIFY_NAME(counter_create_typed)(name, domain, type); } #endif + else { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#else + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif + return NULL; + } } for (h_tail = NULL, h = _N_(_ittapi_global).counter_list; h != NULL; h_tail = h, h = h->next) { - if (h->nameA != NULL && h->type == type && !__itt_fstrcmp(h->nameA, name) && + if (h->nameA != NULL && h->type == (int)type && + !__itt_fstrcmp(h->nameA, name) && ((h->domainA == NULL && domain == NULL) || (h->domainA != NULL && domain != NULL && !__itt_fstrcmp(h->domainA, domain)))) @@ -637,6 +758,106 @@ return (__itt_counter)h; } +#if ITT_PLATFORM == ITT_PLATFORM_WIN +static __itt_histogram *ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(histogram_createW), + _init))( + const __itt_domain *domain, const wchar_t *name, __itt_metadata_type x_type, + __itt_metadata_type y_type) { + __itt_histogram *h_tail = NULL, *h = NULL; + + if (domain == NULL || name == NULL) { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) { + if (ITTNOTIFY_NAME(histogram_createW) && + ITTNOTIFY_NAME(histogram_createW) != + ITT_VERSIONIZE(ITT_JOIN(_N_(histogram_createW), _init))) { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(histogram_createW)(domain, name, x_type, y_type); + } else { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return NULL; + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).histogram_list; h != NULL; + h_tail = h, h = h->next) { + if (h->domain == NULL) + continue; + else if (h->domain != domain && h->nameW != NULL && !wcscmp(h->nameW, name)) + break; + } + if (h == NULL) { + NEW_HISTOGRAM_W(&_N_(_ittapi_global), h, h_tail, domain, name, x_type, + y_type); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return (__itt_histogram *)h; +} + +static __itt_histogram *ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(histogram_createA), + _init))( + const __itt_domain *domain, const char *name, __itt_metadata_type x_type, + __itt_metadata_type y_type) +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +static __itt_histogram *ITTAPI ITT_VERSIONIZE(ITT_JOIN( + _N_(histogram_create), _init))(const __itt_domain *domain, const char *name, + __itt_metadata_type x_type, + __itt_metadata_type y_type) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + __itt_histogram *h_tail = NULL, *h = NULL; + + if (domain == NULL || name == NULL) { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(histogram_createA) && + ITTNOTIFY_NAME(histogram_createA) != + ITT_VERSIONIZE(ITT_JOIN(_N_(histogram_createA), _init))) { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(histogram_createA)(domain, name, x_type, y_type); + } +#else + if (ITTNOTIFY_NAME(histogram_create) && + ITTNOTIFY_NAME(histogram_create) != + ITT_VERSIONIZE(ITT_JOIN(_N_(histogram_create), _init))) { + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(histogram_create)(domain, name, x_type, y_type); + } +#endif + else { +#if ITT_PLATFORM == ITT_PLATFORM_WIN + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#else + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif + return NULL; + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).histogram_list; h != NULL; + h_tail = h, h = h->next) { + if (h->domain == NULL) + continue; + else if (h->domain != domain && h->nameA != NULL && + !__itt_fstrcmp(h->nameA, name)) + break; + } + if (h == NULL) { + NEW_HISTOGRAM_A(&_N_(_ittapi_global), h, h_tail, domain, name, x_type, + y_type); + } + if (PTHREAD_SYMBOLS) + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return (__itt_histogram *)h; +} + /* -------------------------------------------------------------------------- */ static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(pause), _init))(void) { @@ -968,8 +1189,8 @@ return lib_name; } -/* Avoid clashes with std::min, reported by tbb team */ -#define __itt_min(a, b) (a) < (b) ? (a) : (b) +/* Avoid clashes with std::min */ +#define __itt_min(a, b) ((a) < (b) ? (a) : (b)) static __itt_group_id __itt_get_groups(void) { int i; @@ -1026,7 +1247,7 @@ /* It's not used right now! Comment it out to avoid warnings. static void __itt_reinit_all_pointers(void) { - int i; + register int i; // Fill all pointers with initial stubs for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) *_N_(_ittapi_global).api_list_ptr[i].func_ptr = @@ -1036,22 +1257,23 @@ static void __itt_nullify_all_pointers(void) { int i; - /* Nullify all pointers except domain_create, string_handle_create and + /* Nulify all pointers except domain_create, string_handle_create and * counter_create */ for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; } -// clang-format off -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(push) -#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function - pointer 'XXX' to data pointer 'void *' */ -#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer - 'void *' to function pointer 'XXX' */ +#pragma warning(disable : 4054) /* warning C4054: 'type cast' : from function \ + pointer 'XXX' to data pointer 'void *' */ +#pragma warning( \ + disable : 4055) /* warning C4055: 'type cast' : from data pointer 'void *' \ + to function pointer 'XXX' */ +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -// clang-format on ITT_EXTERN_C void _N_(fini_ittlib)(void) { __itt_api_fini_t *__itt_api_fini_ptr = NULL; @@ -1087,6 +1309,59 @@ } } +/* !!! this function should be called under mutex lock !!! */ +static void __itt_free_allocated_resources(void) { + __itt_string_handle *current_string = _N_(_ittapi_global).string_list; + while (current_string != NULL) { + __itt_string_handle *tmp = current_string->next; + free((char *)current_string->strA); +#if ITT_PLATFORM == ITT_PLATFORM_WIN + free((wchar_t *)current_string->strW); +#endif + free(current_string); + current_string = tmp; + } + _N_(_ittapi_global).string_list = NULL; + + __itt_domain *current_domain = _N_(_ittapi_global).domain_list; + while (current_domain != NULL) { + __itt_domain *tmp = current_domain->next; + free((char *)current_domain->nameA); +#if ITT_PLATFORM == ITT_PLATFORM_WIN + free((wchar_t *)current_domain->nameW); +#endif + free(current_domain); + current_domain = tmp; + } + _N_(_ittapi_global).domain_list = NULL; + + __itt_counter_info_t *current_couter = _N_(_ittapi_global).counter_list; + while (current_couter != NULL) { + __itt_counter_info_t *tmp = current_couter->next; + free((char *)current_couter->nameA); + free((char *)current_couter->domainA); +#if ITT_PLATFORM == ITT_PLATFORM_WIN + free((wchar_t *)current_couter->nameW); + free((wchar_t *)current_couter->domainW); +#endif + free(current_couter); + current_couter = tmp; + } + _N_(_ittapi_global).counter_list = NULL; + + __itt_histogram *current_histogram = _N_(_ittapi_global).histogram_list; + while (current_histogram != NULL) { + __itt_histogram *tmp = current_histogram->next; + free((char *)current_histogram->nameA); +#if ITT_PLATFORM == ITT_PLATFORM_WIN + free((wchar_t *)current_histogram->nameW); +#endif + free(current_histogram); + current_histogram = tmp; + } + _N_(_ittapi_global).histogram_list = NULL; +} + ITT_EXTERN_C int _N_(init_ittlib)(const char *lib_name, __itt_group_id init_groups) { int i; @@ -1120,7 +1395,7 @@ switch (lib_version) { case 0: groups = __itt_group_legacy; - KMP_FALLTHROUGH(); + ITT_ATTRIBUTE_FALLTHROUGH; case 1: /* Fill all pointers from dynamic library */ for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; @@ -1140,8 +1415,10 @@ __itt_error_no_symbol, lib_name, _N_(_ittapi_global).api_list_ptr[i].name); #ifdef ITT_COMPLETE_GROUP - zero_group = (__itt_group_id)( - zero_group | _N_(_ittapi_global).api_list_ptr[i].group); + zero_group = + (__itt_group_id)(zero_group | _N_(_ittapi_global) + .api_list_ptr[i] + .group); #endif /* ITT_COMPLETE_GROUP */ } } else @@ -1183,6 +1460,7 @@ break; } } else { + __itt_free_allocated_resources(); __itt_nullify_all_pointers(); __itt_report_error(__itt_error_no_module, lib_name, @@ -1194,6 +1472,7 @@ ); } } else { + __itt_free_allocated_resources(); __itt_nullify_all_pointers(); } _N_(_ittapi_global).api_initialized = 1; @@ -1229,6 +1508,50 @@ return prev; } -#if ITT_PLATFORM == ITT_PLATFORM_WIN && KMP_MSVC_COMPAT +#if ITT_PLATFORM == ITT_PLATFORM_WIN +#if _MSC_VER #pragma warning(pop) +#endif #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** __itt_mark_pt_region functions marks region of interest + * region parameter defines different regions. + * 0 <= region < 8 */ + +#if defined(ITT_API_IPT_SUPPORT) && \ + (ITT_PLATFORM == ITT_PLATFORM_WIN || \ + ITT_PLATFORM == ITT_PLATFORM_POSIX) && \ + !defined(__ANDROID__) +void __itt_pt_mark(__itt_pt_region region); +void __itt_pt_mark_event(__itt_pt_region region); +#endif + +ITT_EXTERN_C void _N_(mark_pt_region_begin)(__itt_pt_region region) { +#if defined(ITT_API_IPT_SUPPORT) && \ + (ITT_PLATFORM == ITT_PLATFORM_WIN || \ + ITT_PLATFORM == ITT_PLATFORM_POSIX) && \ + !defined(__ANDROID__) + if (_N_(_ittapi_global).ipt_collect_events == 1) { + __itt_pt_mark_event(2 * region); + } else { + __itt_pt_mark(2 * region); + } +#else + (void)region; +#endif +} + +ITT_EXTERN_C void _N_(mark_pt_region_end)(__itt_pt_region region) { +#if defined(ITT_API_IPT_SUPPORT) && \ + (ITT_PLATFORM == ITT_PLATFORM_WIN || \ + ITT_PLATFORM == ITT_PLATFORM_POSIX) && \ + !defined(__ANDROID__) + if (_N_(_ittapi_global).ipt_collect_events == 1) { + __itt_pt_mark_event(2 * region + 1); + } else { + __itt_pt_mark(2 * region + 1); + } +#else + (void)region; +#endif +} diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_types.h b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_types.h --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_types.h +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_types.h @@ -29,6 +29,7 @@ __itt_group_structure = 1 << 12, __itt_group_suppress = 1 << 13, __itt_group_arrays = 1 << 14, + __itt_group_module = 1 << 15, __itt_group_all = -1 } __itt_group_id; @@ -57,6 +58,7 @@ {__itt_group_structure, "structure"}, \ {__itt_group_suppress, "suppress"}, \ {__itt_group_arrays, "arrays"}, \ + {__itt_group_module, "module"}, \ {__itt_group_none, NULL}} #endif /* _ITTNOTIFY_TYPES_H_ */ diff --git a/openmp/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h b/openmp/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h --- a/openmp/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h +++ b/openmp/runtime/src/thirdparty/ittnotify/legacy/ittnotify.h @@ -119,7 +119,13 @@ #if ITT_PLATFORM == ITT_PLATFORM_WIN /* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline +#if defined(__MINGW32__) && !defined(__cplusplus) +#define ITT_INLINE \ + static __inline__ __attribute__((__always_inline__, __gnu_inline__)) +#else +#define ITT_INLINE static __forceinline +#endif /* __MINGW32__ */ + #define ITT_INLINE_ATTRIBUTE /* nothing */ #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ /*