This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 131
Honor property::queue::enable_profiling #825
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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,69 @@ | ||
// REQUIRES: gpu, level_zero | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: env ZE_DEBUG=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 | FileCheck --check-prefixes=WITHOUT %s | ||
// RUN: env ZE_DEBUG=-1 %GPU_RUN_PLACEHOLDER %t.out profile 2>&1 | FileCheck --check-prefixes=WITH %s | ||
|
||
// Test case adapted from the SYCL version of Rodinia benchmark hotspot. | ||
|
||
// clang-format off | ||
// Check the expected output when queue::enable_profiling is not specified | ||
// | ||
// WITHOUT: ze_event_pool_desc_t flags set to: 1 | ||
// WITHOUT: SYCL exception caught: Native API failed. Native API returns: -7 (CL_PROFILING_INFO_NOT_AVAILABLE) | ||
|
||
// Check the expected output when queue::enable_profiling is specified | ||
// | ||
// WITH: ze_event_pool_desc_t flags set to: 5 | ||
// WITH: Device kernel time: | ||
// clang-format on | ||
// | ||
|
||
#include <CL/sycl.hpp> | ||
using namespace cl::sycl; | ||
|
||
int foo(queue &q, int n) { | ||
for (int i = 0; i < n; i++) { | ||
|
||
sycl::event queue_event = q.submit([&](handler &cgh) { | ||
cgh.parallel_for<class empty>(range<2>(10000, 10000), | ||
[=](item<2> item) {}); | ||
}); | ||
|
||
q.wait(); | ||
|
||
// Get kernel computation time | ||
try { | ||
auto startk = queue_event.template get_profiling_info< | ||
cl::sycl::info::event_profiling::command_start>(); | ||
auto endk = queue_event.template get_profiling_info< | ||
cl::sycl::info::event_profiling::command_end>(); | ||
auto kernel_time = | ||
(float)(endk - startk) * 1e-9f; // to seconds, 1e-6f to milliseconds | ||
printf("Device kernel time: %.12fs\n", (float)kernel_time); | ||
|
||
} catch (const sycl::exception &e) { | ||
std::cout << "SYCL exception caught: " << e.what() << '\n'; | ||
return 0; | ||
} | ||
} | ||
return n; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
|
||
bool profiling = argc > 1; | ||
|
||
{ | ||
gpu_selector dev_sel; | ||
property_list propList{}; | ||
if (profiling) | ||
propList = cl::sycl::property::queue::enable_profiling(); | ||
|
||
queue q(dev_sel, propList); | ||
// Perform the computation | ||
foo(q, 2); | ||
} // SYCL scope | ||
|
||
return 0; | ||
} |
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.