-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Add device config file consistency test #16369
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 all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
69e538a
[SYCL] Add device config file consistency test
jzc 78a751a
Merge remote-tracking branch 'intel/sycl' into device-config-consistency
jzc 3855884
Update cmake and CI
jzc 3c062ef
Add backslash
jzc 81431e7
Change install location
jzc 07e599e
Fix typo
jzc 215bf25
format
jzc d7264c9
Make style consistent
jzc b9e14c7
Move device config file feature detection
jzc 7cd1109
Add SYCL_ prefix
jzc ef8481f
Fix syntax
jzc 0b99853
Update HIP and CUDA aspects
jzc 7b61e9e
Merge remote-tracking branch 'intel/sycl' into device-config-consistency
jzc 9a893a0
Update HIP and CUDA aspects again
jzc 96da39b
punctuation
jzc 9a4f880
Merge remote-tracking branch 'intel/sycl' into device-config-consistency
jzc 415a6be
Update CUDA usm aspects
jzc d9e0582
Revert "Update CUDA usm aspects"
jzc 232357b
Update CUDA usm aspects
jzc fcb7c46
Merge remote-tracking branch 'intel/sycl' into device-config-consistency
jzc e359521
Merge remote-tracking branch 'upstream/sycl' into device-config-consi…
KornevNikita c278ad5
upd build_specific_features
KornevNikita c43cc7c
Apply review suggestions
KornevNikita 8c2cfc4
Merge remote-tracking branch 'upstream/sycl' into device-config-consi…
KornevNikita 2135b30
upd CudaMinAspects
KornevNikita fe49581
Merge remote-tracking branch 'upstream/sycl' into device-config-consi…
KornevNikita e098145
upd DeviceConfigFile.td
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
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,136 @@ | ||
// This test checks to see if every aspect and sub-group size declared in the | ||
// device config file is supported by the device. Note this does not mean | ||
// check that the device config file is exhaustive, only that the device | ||
// supports everything it declares. However, this test does print out any | ||
// aspects that are supported by the device but not declared in the device | ||
// config file. | ||
|
||
// REQUIRES: device-config-file | ||
maarquitos14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// RUN: %{build} -o %t.out %device_config_file_include_flag | ||
// RUN: %{run} %t.out | ||
#include <map> | ||
|
||
#include <llvm/SYCLLowerIR/DeviceConfigFile.hpp> | ||
#include <sycl/detail/core.hpp> | ||
|
||
#define __SYCL_ASPECT_DEPRECATED_ALIAS(ASPECT, ID, MESSAGE) \ | ||
__SYCL_ASPECT_DEPRECATED(ASPECT, ID, MESSAGE) | ||
|
||
using namespace sycl; | ||
|
||
const char *getArchName(const device &Device) { | ||
namespace syclex = sycl::ext::oneapi::experimental; | ||
auto Arch = Device.get_info<syclex::info::device::architecture>(); | ||
switch (Arch) { | ||
#define __SYCL_ARCHITECTURE(ARCH, VAL) \ | ||
case syclex::architecture::ARCH: \ | ||
return #ARCH; | ||
#define __SYCL_ARCHITECTURE_ALIAS(ARCH, VAL) | ||
#include <sycl/ext/oneapi/experimental/device_architecture.def> | ||
#undef __SYCL_ARCHITECTURE | ||
#undef __SYCL_ARCHITECTURE_ALIAS | ||
} | ||
return "unknown"; | ||
} | ||
|
||
// Checks if a container contains a specific element. | ||
template <typename Container, typename T> | ||
bool contains(const Container &C, const T &Elem) { | ||
return std::find(C.begin(), C.end(), Elem) != C.end(); | ||
} | ||
|
||
std::string_view getAspectName(aspect Asp) { | ||
switch (Asp) { | ||
#define __SYCL_ASPECT(ASPECT, ID) \ | ||
case aspect::ASPECT: \ | ||
return #ASPECT; | ||
#include <sycl/info/aspects.def> | ||
#undef __SYCL_ASPECT | ||
} | ||
return "unknown"; | ||
} | ||
|
||
aspect getAspectByName(std::string_view Name) { | ||
#define __SYCL_ASPECT(ASPECT, ID) \ | ||
if (Name == #ASPECT) \ | ||
return aspect::ASPECT; | ||
#include <sycl/info/aspects.def> | ||
throw std::invalid_argument("Unknown aspect name"); | ||
} | ||
|
||
int main() { | ||
// Get the device arch. | ||
queue Q; | ||
auto Dev = Q.get_device(); | ||
auto DeviceName = getArchName(Dev); | ||
|
||
auto TargetInfo = DeviceConfigFile::TargetTable.find(DeviceName); | ||
if (TargetInfo == DeviceConfigFile::TargetTable.end()) { | ||
std::cout << "No aspects found for device " << DeviceName << "\n"; | ||
return 1; | ||
} | ||
|
||
// Check aspects consistency. | ||
int NAspectInconsistencies = 0; | ||
|
||
auto SupportedAspects = Dev.get_info<info::device::aspects>(); | ||
auto DeviceConfigAspectNames = TargetInfo->second.aspects; | ||
std::vector<aspect> DeviceConfigAspects; | ||
for (auto AspectName : DeviceConfigAspectNames) { | ||
DeviceConfigAspects.push_back(getAspectByName(AspectName)); | ||
} | ||
|
||
for (auto Asp : DeviceConfigAspects) { | ||
if (!contains(SupportedAspects, Asp)) { | ||
std::cout << "error: " << DeviceName << " does not support aspect " | ||
<< getAspectName(Asp) | ||
<< " but it is declared in the device config file\n"; | ||
++NAspectInconsistencies; | ||
} | ||
} | ||
for (auto Asp : SupportedAspects) { | ||
if (!contains(DeviceConfigAspects, Asp)) { | ||
std::cout << "note: the device " << DeviceName << " supports aspect " | ||
<< getAspectName(Asp) | ||
<< " but it is not declared in the device config file\n"; | ||
// Not necessarily an error, so we won't increment n_fail. | ||
} | ||
} | ||
|
||
if (NAspectInconsistencies != 0) { | ||
std::cout << "Aspects are inconsistent\n"; | ||
return 1; | ||
} | ||
|
||
// Check sub-group sizes consistency. | ||
int NSubGroupSizeInconsistencies = 0; | ||
|
||
auto SupportedSubGroupSizes = Dev.get_info<info::device::sub_group_sizes>(); | ||
auto DeviceConfigSubGroupSizes = TargetInfo->second.subGroupSizes; | ||
|
||
for (auto Size : DeviceConfigSubGroupSizes) { | ||
if (!contains(SupportedSubGroupSizes, Size)) { | ||
std::cout << "error: " << DeviceName | ||
<< " does not support sub-group size " << Size | ||
<< " but it is declared in the device config file\n"; | ||
++NSubGroupSizeInconsistencies; | ||
} | ||
} | ||
for (auto Size : SupportedSubGroupSizes) { | ||
if (!contains(DeviceConfigSubGroupSizes, Size)) { | ||
std::cout << "note: the device " << DeviceName | ||
<< " supports sub-group size " << Size | ||
<< " but it is not declared in the device config file\n"; | ||
// Not necessarily an error, so we won't increment n_fail. | ||
} | ||
} | ||
|
||
if (NSubGroupSizeInconsistencies != 0) { | ||
std::cout << "Sub-group sizes are inconsistent\n"; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
#undef __SYCL_ASPECT_DEPRECATED_ALIAS |
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
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.
can you give some background on why we need to install this? thx
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.
I'm still testing things, so I might change some things, but I want to support the new
device_config_file_consistency
test. It uses theDeviceConfigFile.hpp
, and that file includesDeviceConfigFile.inc
, which is generated by tablegen. On CI from what I understand the e2e tests are invoked by using the packed install files from the build step and only runs CMake on thesycl/test-e2e
subfolder. So since we probably don't want to build tablegen and invoke other LLVM cmake files when running the e2e tests, I install theDeviceConfigFile.inc
it in the build step to pass it to the e2e tests. Also note that this test must be an e2e test as it queries the device it is running the test on, so it can't be moved tosycl/test
.Uh oh!
There was an error while loading. Please reload this page.
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.
sorry so what tools/files are required to generate that hpp file? Is it just
llvm-tablegen
andDeviceConfigFile.inc
?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.
Yea just tablegen and
DeviceConfigFile.td
are needed for the hpp fileThere 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.
Also just for some more background I was aiming so that DeviceConfigFile.hpp is not installed by default because outside of testing, this file is not needed for a SYCL distribution, it is only used in the compiler.