Skip to content

Mark compiler ITT wrappers with always_inline. #3807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions libdevice/device_itt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "spirv_vars.h"

#define ITT_STUB_ATTRIBUTES __attribute__((noinline, optnone))
#define ITT_WRAPPER_ATTRIBUTES __attribute__((always_inline))

/// Atomic operation type
enum __itt_atomic_mem_op_t {
Expand All @@ -36,7 +37,7 @@ DEVICE_EXTERN_C char __spirv_SpecConstant(int, char);

#define ITT_SPEC_CONSTANT 0xFF747469

static inline bool isITTEnabled() {
static ITT_WRAPPER_ATTRIBUTES bool isITTEnabled() {
return __spirv_SpecConstant(ITT_SPEC_CONSTANT, 0) != 0;
}

Expand All @@ -50,14 +51,15 @@ static inline bool isITTEnabled() {
// be computed in the wrapper itself and has to be passed from outside.
// If a compiler needs to invoke such an API, it has to use the user
// visible API directly (i.e. __itt_offload_sync_acquired).
DEVICE_EXTERN_C
void __itt_offload_wi_start_wrapper();
DEVICE_EXTERN_C
void __itt_offload_wi_finish_wrapper();
DEVICE_EXTERN_C
void __itt_offload_wg_barrier_wrapper();
DEVICE_EXTERN_C
void __itt_offload_wi_resume_wrapper();
//
// FIXME: we need to add always_inline compiler wrappers
// for atomic_op_start/finish. Compiler calls user
// wrappers right now, and they may interfere with
// debugging user code in non-ITT mode.
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_start_wrapper();
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_finish_wrapper();
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wg_barrier_wrapper();
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_resume_wrapper();

// Non-inlinable and non-optimizable APIs that are recognized
// by profiling tools.
Expand Down