Skip to content

[SYCL] Print supported SG sizes in sycl-ls --verbose #9481

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 4 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sycl/test-e2e/GroupAlgorithm/SYCL2020/sort.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: sg-8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I do wonder if we could maybe also add a way for the test-config to tell us what a (common?) supported sub-group size is, so we could for example pass that to the test (e.g. as a -D definition) so we don't have to guess at a sub-group size when writing tests like this.

Not directly related to this, but it's something to think about.

// RUN: %{build} -fsycl-device-code-split=per_kernel -o %t.out
// RUN: %{run} %t.out
// UNSUPPORTED: accelerator
Expand Down Expand Up @@ -454,8 +455,10 @@ int main() {
}

std::cout << "Test passed." << std::endl;
return 0;
} catch (std::exception &E) {
std::cout << "Test failed" << std::endl;
std::cout << E.what() << std::endl;
return 1;
}
}
40 changes: 29 additions & 11 deletions sycl/test-e2e/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,42 @@
be, device, sp.stdout, sp.stderr))

dev_aspects = []
dev_sg_sizes = []
for line in sp.stdout.split('\n'):
if not re.search(r'^ *Aspects *:', line):
continue
_, aspects_str = line.split(':', 1)
dev_aspects.append(aspects_str.strip().split(' '))
if re.search(r'^ *Aspects *:', line):
_, aspects_str = line.split(':', 1)
dev_aspects.append(aspects_str.strip().split(' '))
if re.search(r'^ *info::device::sub_group_sizes:', line):
_, sg_sizes_str = line.split(':', 1)
dev_sg_sizes.append(sg_sizes_str.strip().split(' '))

if dev_aspects == []:
lit_config.error('Cannot detect device aspect for {}\nstdout:\n{}\nstderr:\n'.format(
sycl_device, sp.stdout, sp.stderr))
sycl_dev_aspects.append(set())
continue
dev_aspects.append(set())
else:
# We might have several devices matching the same filter in the system.
# Compute intersection of aspects.
aspects = set(dev_aspects[0]).intersection(*dev_aspects)
lit_config.note('Aspects for {}: {}'.format(sycl_device, ', '.join(aspects)))

if dev_sg_sizes == []:
lit_config.error('Cannot detect device SG sizes for {}\nstdout:\n{}\nstderr:\n'.format(
sycl_device, sp.stdout, sp.stderr))
dev_sg_sizes.append(set())
else:
# We might have several devices matching the same filter in the system.
# Compute intersection of aspects.
sg_sizes = set(dev_sg_sizes[0]).intersection(*dev_sg_sizes)
lit_config.note('SG sizes for {}: {}'.format(sycl_device, ', '.join(sg_sizes)))


# We might have several devices matching the same filter in the system.
# Compute intersection of aspects.
aspects = set(dev_aspects[0]).intersection(*dev_aspects)
lit_config.note('Aspects for {}: {}'.format(sycl_device, ', '.join(aspects)))
aspect_features = set('aspect-' + a for a in aspects)
sg_size_features = set('sg-' + s for s in sg_sizes)
features = set();
features.update(aspect_features)
features.update(sg_size_features)

features = set('aspect-' + a for a in aspects)
be, dev = sycl_device.split(':')
features.add(dev.replace('acc', 'accelerator'))
# Use short names for LIT rules.
Expand Down
5 changes: 5 additions & 0 deletions sycl/tools/sycl-ls/sycl-ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ static void printDeviceInfo(const device &Device, bool Verbose,
std::cout << " " << #ASPECT;
#include <sycl/info/aspects.def>
std::cout << std::endl;
auto sg_sizes = Device.get_info<info::device::sub_group_sizes>();
std::cout << Prepend << "info::device::sub_group_sizes:";
for (auto size : sg_sizes)
std::cout << " " << size;
std::cout << std::endl;
} else {
std::cout << Prepend << ", " << DeviceName << " " << DeviceVersion << " ["
<< DeviceDriverVersion << "]" << std::endl;
Expand Down