llvm/openmp/runtime/src/thirdparty/ittnotify/ittnotify.h


//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _ITTNOTIFY_H_
#define _ITTNOTIFY_H_

/**
@file
@brief Public User API functions and types
@mainpage

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.

@section API Concepts
The following general concepts are used throughout the API.

@subsection Unicode Support
Many API functions take character string arguments. On Windows, there
are two versions of each such function. The function name is suffixed
by W if Unicode support is enabled, and by A otherwise. Any API function
that takes a character string argument adheres to this convention.

@subsection Conditional Compilation
Many users prefer having an option to modify ITT API code when linking it
inside their runtimes. ITT API header file provides a mechanism to replace
ITT API function names inside your code with empty strings. To do this,
define the macros INTEL_NO_ITTNOTIFY_API during compilation and remove the
static library from the linker script.

@subsection Domains
[see domains]
Domains provide a way to separate notification for different modules or
libraries in a program. Domains are specified by dotted character strings,
e.g. TBB.Internal.Control.

A mechanism (to be specified) is provided to enable and disable
domains. By default, all domains are enabled.
@subsection Named Entities and Instances
Named entities (frames, regions, tasks, and markers) communicate
information about the program to the analysis tools. A named entity often
refers to a section of program code, or to some set of logical concepts
that the programmer wants to group together.

Named entities relate to the programmer's static view of the program. When
the program actually executes, many instances of a given named entity
may be created.

The API annotations denote instances of named entities. The actual
named entities are displayed using the analysis tools. In other words,
the named entities come into existence when instances are created.

Instances of named entities may have instance identifiers (IDs). Some
API calls use instance identifiers to create relationships between
different instances of named entities. Other API calls associate data
with instances of named entities.

Some named entities must always have instance IDs. In particular, regions
and frames always have IDs. Task and markers need IDs only if the ID is
needed in another API call (such as adding a relation or metadata).

The lifetime of instance IDs is distinct from the lifetime of
instances. This allows various relationships to be specified separate
from the actual execution of instances. This flexibility comes at the
expense of extra API calls.

The same ID may not be reused for different instances, unless a previous
[ref] __itt_id_destroy call for that ID has been issued.
*/

/** @cond exclude_from_documentation */
#ifndef ITT_OS_WIN
#define ITT_OS_WIN
#endif /* ITT_OS_WIN */

#ifndef ITT_OS_LINUX
#define ITT_OS_LINUX
#endif /* ITT_OS_LINUX */

#ifndef ITT_OS_MAC
#define ITT_OS_MAC
#endif /* ITT_OS_MAC */

#ifndef ITT_OS_FREEBSD
#define ITT_OS_FREEBSD
#endif /* ITT_OS_FREEBSD */

#ifndef ITT_OS
#if defined WIN32 || defined _WIN32
#define ITT_OS
#elif defined(__APPLE__) && defined(__MACH__)
#define ITT_OS
#elif defined(__FreeBSD__)
#define ITT_OS
#else
#define ITT_OS
#endif
#endif /* ITT_OS */

#ifndef ITT_PLATFORM_WIN
#define ITT_PLATFORM_WIN
#endif /* ITT_PLATFORM_WIN */

#ifndef ITT_PLATFORM_POSIX
#define ITT_PLATFORM_POSIX
#endif /* ITT_PLATFORM_POSIX */

#ifndef ITT_PLATFORM_MAC
#define ITT_PLATFORM_MAC
#endif /* ITT_PLATFORM_MAC */

#ifndef ITT_PLATFORM_FREEBSD
#define ITT_PLATFORM_FREEBSD
#endif /* ITT_PLATFORM_FREEBSD */

#ifndef ITT_PLATFORM
#if ITT_OS == ITT_OS_WIN
#define ITT_PLATFORM
#elif ITT_OS == ITT_OS_MAC
#define ITT_PLATFORM
#elif ITT_OS == ITT_OS_FREEBSD
#define ITT_PLATFORM
#else
#define ITT_PLATFORM
#endif
#endif /* ITT_PLATFORM */

#if defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif

#include <stddef.h>
#if ITT_PLATFORM == ITT_PLATFORM_WIN
#include <tchar.h>
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#include <stdint.h>
#if defined(UNICODE) || defined(_UNICODE)
#include <wchar.h>
#endif /* UNICODE || _UNICODE */
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */

#ifndef ITTAPI_CDECL
#if ITT_PLATFORM == ITT_PLATFORM_WIN
#define ITTAPI_CDECL
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#if defined _M_IX86 || defined __i386__
#define ITTAPI_CDECL
#else /* _M_IX86 || __i386__ */
#define ITTAPI_CDECL
#endif /* _M_IX86 || __i386__ */
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* ITTAPI_CDECL */

#ifndef STDCALL
#if ITT_PLATFORM == ITT_PLATFORM_WIN
#define STDCALL
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#if defined _M_IX86 || defined __i386__
#define STDCALL
#else /* _M_IX86 || __i386__ */
#define STDCALL
#endif /* _M_IX86 || __i386__ */
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* STDCALL */

#define ITTAPI
#define LIBITTAPI

/* TODO: Temporary for compatibility! */
#define ITTAPI_CALL
#define LIBITTAPI_CALL

#if ITT_PLATFORM == ITT_PLATFORM_WIN
/* use __forceinline (VC++ specific) */
#if defined(__MINGW32__) && !defined(__cplusplus)
#define ITT_INLINE
#else
#define ITT_INLINE
#endif /* __MINGW32__ */

#define ITT_INLINE_ATTRIBUTE
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/*
 * Generally, functions are not inlined unless optimization is specified.
 * For functions declared inline, this attribute inlines the function even
 * if no optimization level was specified.
 */
#ifdef __STRICT_ANSI__
#define ITT_INLINE
#define ITT_INLINE_ATTRIBUTE
#else /* __STRICT_ANSI__ */
#define ITT_INLINE
#define ITT_INLINE_ATTRIBUTE
#endif /* __STRICT_ANSI__ */
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/** @endcond */

#ifdef INTEL_ITTNOTIFY_ENABLE_LEGACY
#if ITT_PLATFORM == ITT_PLATFORM_WIN
#pragma message(                                                               \
    "WARNING!!! Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro")
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#warning                                                                       \
    "Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro"
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#include "legacy/ittnotify.h"
#endif /* INTEL_ITTNOTIFY_ENABLE_LEGACY */

/** @cond exclude_from_documentation */
/* Helper macro for joining tokens */
#define ITT_JOIN_AUX(p, n)
#define ITT_JOIN(p, n)

#ifdef ITT_MAJOR
#undef ITT_MAJOR
#endif
#ifdef ITT_MINOR
#undef ITT_MINOR
#endif
#define ITT_MAJOR
#define ITT_MINOR

/* Standard versioning of a token with major and minor version numbers */
#define ITT_VERSIONIZE(x)

#ifndef INTEL_ITTNOTIFY_PREFIX
#define INTEL_ITTNOTIFY_PREFIX
#endif /* INTEL_ITTNOTIFY_PREFIX */
#ifndef INTEL_ITTNOTIFY_POSTFIX
#define INTEL_ITTNOTIFY_POSTFIX
#endif /* INTEL_ITTNOTIFY_POSTFIX */

#define ITTNOTIFY_NAME_AUX(n)
#define ITTNOTIFY_NAME(n)

#define ITTNOTIFY_VOID(n)
#define ITTNOTIFY_DATA(n)

#define ITTNOTIFY_VOID_D0(n, d)
#define ITTNOTIFY_VOID_D1(n, d, x)
#define ITTNOTIFY_VOID_D2(n, d, x, y)
#define ITTNOTIFY_VOID_D3(n, d, x, y, z)
#define ITTNOTIFY_VOID_D4(n, d, x, y, z, a)
#define ITTNOTIFY_VOID_D5(n, d, x, y, z, a, b)
#define ITTNOTIFY_VOID_D6(n, d, x, y, z, a, b, c)
#define ITTNOTIFY_DATA_D0(n, d)
#define ITTNOTIFY_DATA_D1(n, d, x)
#define ITTNOTIFY_DATA_D2(n, d, x, y)
#define ITTNOTIFY_DATA_D3(n, d, x, y, z)
#define ITTNOTIFY_DATA_D4(n, d, x, y, z, a)
#define ITTNOTIFY_DATA_D5(n, d, x, y, z, a, b)
#define ITTNOTIFY_DATA_D6(n, d, x, y, z, a, b, c)

#ifdef ITT_STUB
#undef ITT_STUB
#endif
#ifdef ITT_STUBV
#undef ITT_STUBV
#endif
#define ITT_STUBV(api, type, name, args)
#define ITT_STUB
/** @endcond */

#ifdef __cplusplus
extern
#endif /* __cplusplus */

#endif /* _ITTNOTIFY_H_ */

#ifdef INTEL_ITTNOTIFY_API_PRIVATE

#ifndef _ITTNOTIFY_PRIVATE_
#define _ITTNOTIFY_PRIVATE_

#ifdef __cplusplus
extern
#endif /* __cplusplus */

#endif /* _ITTNOTIFY_PRIVATE_ */

#endif /* INTEL_ITTNOTIFY_API_PRIVATE */