-
Notifications
You must be signed in to change notification settings - Fork 769
[CI][Benchmarks] Automatically detect component versions in benchmark CI #18339
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
Open
ianayl
wants to merge
17
commits into
sycl
Choose a base branch
from
ianayl/benchmark-ci-detect-version
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+445
−70
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eb4e123
Add L0 driver code for detecting compute-runtime versions
ianayl 86263e1
instrument main with detect_versions
ianayl b21be5f
change wording, add frontend
ianayl 0c77780
Fix bug
ianayl 274be61
Hook up benchmark script to detect_versions
ianayl d8ab622
test changes in ci
ianayl 4cb45ce
Fix bug
ianayl 3648a35
Fix bug
ianayl 7d927f7
Remove test code
ianayl a447867
Remove more checking for args
ianayl c67e052
Remove some odd choices
ianayl d611471
Merge branch 'sycl' of https://github.com/intel/llvm into ianayl/benc…
ianayl a07c211
add newline
ianayl 3b0c996
Fix bug
ianayl 233c062
darker format python
ianayl 6915b3e
Apply clang-format
ianayl 2bb4959
Add a way to predefine a cache beforehand
ianayl 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
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
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,82 @@ | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <level_zero/ze_api.h> | ||
|
||
#define _assert(cond, msg) \ | ||
if (!(cond)) { \ | ||
std::cout << std::endl << "Error: " << msg << std::endl; \ | ||
exit(1); \ | ||
} | ||
|
||
#define _success(res) res == ZE_RESULT_SUCCESS | ||
|
||
std::string query_dpcpp_ver() { return std::string(__clang_version__); } | ||
|
||
std::string query_l0_driver_ver() { | ||
// Initialize L0 drivers: | ||
ze_init_driver_type_desc_t driver_type = {}; | ||
driver_type.stype = ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC; | ||
driver_type.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU; | ||
driver_type.pNext = nullptr; | ||
|
||
uint32_t driver_count = 0; | ||
ze_result_t result = zeInitDrivers(&driver_count, nullptr, &driver_type); | ||
_assert(_success(result), "Failed to initialize L0."); | ||
_assert(driver_count > 0, "No L0 drivers available."); | ||
|
||
std::vector<ze_driver_handle_t> drivers(driver_count); | ||
result = zeInitDrivers(&driver_count, drivers.data(), &driver_type); | ||
_assert(_success(result), "Could not fetch L0 drivers."); | ||
|
||
// Check support for fetching driver version strings: | ||
uint32_t ext_count = 0; | ||
result = zeDriverGetExtensionProperties(drivers[0], &ext_count, nullptr); | ||
_assert(_success(result), "Failed to obtain L0 extensions count."); | ||
_assert(ext_count > 0, "No L0 extensions available."); | ||
|
||
std::vector<ze_driver_extension_properties_t> extensions(ext_count); | ||
result = | ||
zeDriverGetExtensionProperties(drivers[0], &ext_count, extensions.data()); | ||
_assert(_success(result), "Failed to obtain L0 extensions."); | ||
bool version_ext_support = false; | ||
for (const auto &extension : extensions) { | ||
// std::cout << extension.name << std::endl; | ||
if (strcmp(extension.name, "ZE_intel_get_driver_version_string")) { | ||
version_ext_support = true; | ||
} | ||
} | ||
_assert(version_ext_support, | ||
"ZE_intel_get_driver_version_string extension is not supported."); | ||
|
||
// Fetch L0 driver version: | ||
ze_result_t (*pfnGetDriverVersionFn)(ze_driver_handle_t, char *, size_t *); | ||
result = zeDriverGetExtensionFunctionAddress(drivers[0], | ||
"zeIntelGetDriverVersionString", | ||
(void **)&pfnGetDriverVersionFn); | ||
_assert(_success(result), "Failed to obtain GetDriverVersionString fn."); | ||
|
||
size_t ver_str_len = 0; | ||
result = pfnGetDriverVersionFn(drivers[0], nullptr, &ver_str_len); | ||
_assert(_success(result), "Call to GetDriverVersionString failed."); | ||
|
||
std::cout << "ver_str_len: " << ver_str_len << std::endl; | ||
ver_str_len++; // ver_str_len does not account for '\0' | ||
char *ver_str = (char *)calloc(ver_str_len, sizeof(char)); | ||
result = pfnGetDriverVersionFn(drivers[0], ver_str, &ver_str_len); | ||
_assert(_success(result), "Failed to write driver version string."); | ||
|
||
std::string res(ver_str); | ||
free(ver_str); | ||
return res; | ||
} | ||
|
||
int main() { | ||
std::string dpcpp_ver = query_dpcpp_ver(); | ||
std::cout << "DPCPP_VER='" << dpcpp_ver << "'" << std::endl; | ||
|
||
std::string l0_ver = query_l0_driver_ver(); | ||
std::cout << "L0_VER='" << l0_ver << "'" << std::endl; | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to be an argument? We know where this file resides (
f"{os.path.dirname(__file__)}/utils/detect_versions.cpp"
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly for incase it is not found where it should be / we want to supply a different one, but maybe I am overcomplicating this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;-)
We should do the absolute minimum that does the job.