-
Notifications
You must be signed in to change notification settings - Fork 803
ITT stubs and wrappers for SPIR-V devices. #3279
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
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a985517
ITT stubs and compiler wrappers for SPIR-V devices.
e2e60cb
clang-format
47a8102
Removed \t.
391d0e3
Moved declarations to spirv_vars.h
ea511ff
Renamed itt_cmplr_wrappers.cpp
ab8c04c
Cleaned up names and added user wrappers.
2d9c6c6
clang-format
089a806
Revert changes that uncovered __spirv_GlobalInvocationId_x issue.
b5b3ff1
Added documentation.
e80f1b4
Fomatting fixed.
0c091bb
Updated __itt_atomic_mem_order_t enum.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| //==------- device_itt.h - ITT devicelib functions declarations ------------==// | ||
| // | ||
| // 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 __LIBDEVICE_DEVICE_ITT_H__ | ||
| #define __LIBDEVICE_DEVICE_ITT_H__ | ||
|
|
||
| #include "device.h" | ||
|
|
||
| #ifdef __SPIR__ | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
|
|
||
| // Use SPIRV constants directly in place of OCL intrinsic functions. | ||
| #define __SPIRV_VAR_QUALIFIERS EXTERN_C const | ||
| typedef size_t size_t_vec __attribute__((ext_vector_type(3))); | ||
| __SPIRV_VAR_QUALIFIERS size_t __spirv_BuiltInGlobalLinearId; | ||
| __SPIRV_VAR_QUALIFIERS size_t_vec __spirv_BuiltInWorkgroupId; | ||
| __SPIRV_VAR_QUALIFIERS size_t_vec __spirv_BuiltInWorkgroupSize; | ||
|
|
||
| #define ITT_STUB_ATTRIBUTES __attribute__((noinline, optnone)) | ||
|
|
||
| // FIXME: must be enabled via -fdeclare-spirv-builtins | ||
| DEVICE_EXTERN_C char __spirv_SpecConstant(int, char); | ||
|
|
||
| #define ITT_SPEC_CONSTANT 0xFF747469 | ||
|
|
||
| static inline bool isITTEnabled() { | ||
| return __spirv_SpecConstant(ITT_SPEC_CONSTANT, 0) != 0; | ||
| } | ||
|
|
||
| // Wrapper APIs that may be called by compiler-generated code. | ||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_start_wrapper(); | ||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_finish_wrapper(); | ||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wg_barrier_wrapper(); | ||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_resume_wrapper(); | ||
|
|
||
| // Non-inlinable and non-optimizable APIs that are recognized | ||
| // by profiling tools. | ||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wi_start_stub(size_t *group_id, size_t wi_id, uint32_t wg_size); | ||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wi_finish_stub(size_t *group_id, size_t wi_id); | ||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wg_barrier_stub(uintptr_t barrier_id); | ||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wi_resume_stub(size_t *group_id, size_t wi_id); | ||
vzakhari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #endif // __SPIR__ | ||
| #endif // __LIBDEVICE_DEVICE_ITT_H__ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //==--- itt_cmplr_wrappers.cpp - compiler wtappers for ITT -----------------==// | ||
vzakhari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "device_itt.h" | ||
|
|
||
| #ifdef __SPIR__ | ||
|
|
||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_start_wrapper() { | ||
| if (!isITTEnabled()) | ||
| return; | ||
|
|
||
| size_t GroupID[3] = {__spirv_BuiltInWorkgroupId.x, | ||
| __spirv_BuiltInWorkgroupId.y, | ||
| __spirv_BuiltInWorkgroupId.z}; | ||
| size_t WIID = __spirv_BuiltInGlobalLinearId; | ||
| uint32_t WGSize = static_cast<uint32_t>(__spirv_BuiltInWorkgroupSize.x * | ||
| __spirv_BuiltInWorkgroupSize.y * | ||
| __spirv_BuiltInWorkgroupSize.z); | ||
| __itt_spirv_wi_start_stub(GroupID, WIID, WGSize); | ||
| } | ||
|
|
||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_finish_wrapper() { | ||
| if (!isITTEnabled()) | ||
| return; | ||
|
|
||
| size_t GroupID[3] = {__spirv_BuiltInWorkgroupId.x, | ||
| __spirv_BuiltInWorkgroupId.y, | ||
| __spirv_BuiltInWorkgroupId.z}; | ||
| size_t WIID = __spirv_BuiltInGlobalLinearId; | ||
| __itt_spirv_wi_finish_stub(GroupID, WIID); | ||
| } | ||
|
|
||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wg_barrier_wrapper() { | ||
| if (!isITTEnabled()) | ||
| return; | ||
|
|
||
| __itt_spirv_wg_barrier_stub(0); | ||
| } | ||
|
|
||
| DEVICE_EXTERN_C | ||
| void __itt_spirv_wi_resume_wrapper() { | ||
| if (!isITTEnabled()) | ||
| return; | ||
|
|
||
| size_t GroupID[3] = {__spirv_BuiltInWorkgroupId.x, | ||
| __spirv_BuiltInWorkgroupId.y, | ||
| __spirv_BuiltInWorkgroupId.z}; | ||
| size_t WIID = __spirv_BuiltInGlobalLinearId; | ||
| __itt_spirv_wi_resume_stub(GroupID, WIID); | ||
| } | ||
|
|
||
| #endif // __SPIR__ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //==--- itt_stubs.cpp - stub functions for ITT ----------------------------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "device_itt.h" | ||
|
|
||
| #ifdef __SPIR__ | ||
|
|
||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
vzakhari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __itt_spirv_wi_start_stub(size_t *group_id, size_t wi_id, uint32_t wg_size) {} | ||
|
|
||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wi_finish_stub(size_t *group_id, size_t wi_id) {} | ||
|
|
||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wg_barrier_stub(uintptr_t barrier_id) {} | ||
|
|
||
| DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void | ||
| __itt_spirv_wi_resume_stub(size_t *group_id, size_t wi_id) {} | ||
|
|
||
| #endif // __SPIR__ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.