-
Notifications
You must be signed in to change notification settings - Fork 791
[SYCL] Implement sycl_ext_oneapi_clock #19858
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 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aa1cc9e
[SYCL] Implement sycl_ext_oneapi_clock
KornevNikita 3c58917
rest
KornevNikita 7f4762d
format
KornevNikita 8dff32b
Update sycl/test-e2e/Experimental/clock.cpp
KornevNikita 8332e50
throw if aspect it not supported
KornevNikita 7872221
apply suggestions
KornevNikita 9918c93
fix some
KornevNikita 1c21122
more fixes
KornevNikita a565716
add missing include
KornevNikita af1aab3
more more fixes
KornevNikita 4c75261
dummy for non-spirv
KornevNikita f63caae
aligh with new spec changes
KornevNikita 1ce9c3d
format
KornevNikita 4e39cdc
unused parameter
KornevNikita c690380
dummy UR part
KornevNikita 2976ff7
remove unnecessary include
KornevNikita 6019f70
apply suggestions
KornevNikita 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||
//==-------- clock.hpp --- SYCL extension for clock() free function --------==// | ||||||
// | ||||||
// 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 | ||||||
// | ||||||
//===----------------------------------------------------------------------===// | ||||||
|
||||||
#pragma once | ||||||
|
||||||
#include <sycl/__spirv/spirv_ops.hpp> | ||||||
#include <sycl/exception.hpp> | ||||||
|
||||||
namespace sycl { | ||||||
inline namespace _V1 { | ||||||
namespace ext::oneapi::experimental { | ||||||
|
||||||
enum class clock_scope : int { | ||||||
// Aligned with SPIR-V Scope<id> values | ||||||
|
// Aligned with SPIR-V Scope<id> values | |
// Aligned with SPIR-V Scope<id> values. |
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
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 |
---|---|---|
|
@@ -1579,6 +1579,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> { | |
UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP>() | ||
.value_or(0); | ||
} | ||
CASE(ext_oneapi_clock) { return has_extension("cl_khr_kernel_clock"); } | ||
|
||
else { | ||
return false; // This device aspect has not been implemented yet. | ||
} | ||
|
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,41 @@ | ||
// REQUIRES: aspect-ext_oneapi_clock, aspect-usm_shared_allocations | ||
|
||
#include <sycl/detail/core.hpp> | ||
#include <sycl/ext/oneapi/experimental/clock.hpp> | ||
#include <sycl/usm.hpp> | ||
|
||
int main() { | ||
sycl::queue q; | ||
uint64_t *data = sycl::malloc_shared<uint64_t>(3, q); | ||
KornevNikita marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
q.single_task([=]() { | ||
uint64_t sg_clock_start = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::sub_group); | ||
uint64_t wg_clock_start = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::work_group); | ||
uint64_t dev_clock_start = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::device); | ||
|
||
int count = 0; | ||
for (int i = 0; i < 1e6; ++i) | ||
count++; | ||
|
||
uint64_t sg_clock_end = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::sub_group); | ||
uint64_t wg_clock_end = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::work_group); | ||
uint64_t dev_clock_end = sycl::ext::oneapi::experimental::clock( | ||
sycl::ext::oneapi::experimental::clock_scope::device); | ||
data[0] = sg_clock_end - sg_clock_start; | ||
data[1] = wg_clock_end - wg_clock_start; | ||
data[2] = dev_clock_end - dev_clock_start; | ||
}); | ||
q.wait(); | ||
|
||
assert(data[0] > 0); | ||
assert(data[1] > 0); | ||
assert(data[2] > 0); | ||
sycl::free(data, q); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
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.