Skip to content

Commit 7053a19

Browse files
committed
workaround for SYCL 2020 aspect-* change, still support GPU family and device availability gpu-intel-*
1 parent 3330ea4 commit 7053a19

File tree

1 file changed

+51
-15
lines changed

1 file changed

+51
-15
lines changed

suite_generator_sycl.pl

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ sub main
7676

7777
execute("cd $sycl_dir && find -iname '*.cpp' | grep -vw 'Inputs' | sort");
7878
my @list = split( "\n", $command_output);
79-
execute("rm -rf $config_folder && mkdir $config_folder");
79+
# execute("rm -rf $config_folder && mkdir $config_folder");
80+
execute("mv $config_folder $config_folder.old && mkdir $config_folder");
8081

8182
my $tests = {};
8283
my %subsuite_tests;
@@ -110,8 +111,7 @@ sub main
110111
$tests->{ $name} = $r;
111112

112113
print( Dumper( $r));
113-
my $xml_text = gen_test( $r);
114-
print2file( $xml_text, "./$config_folder/$name.xml");
114+
gen_test($r, "$name.xml");
115115

116116
# Save tests for subsuites
117117
foreach my $subsuite (sort keys %{ $feature_subsuite{$feature_folder} }) {
@@ -131,6 +131,8 @@ sub main
131131
print "\nThe number of tests in $subsuite_name: ";
132132
print scalar keys %{ $subsuite_tests{$subsuite} };
133133
}
134+
135+
execute("rm -rf $config_folder.old");
134136
}
135137

136138
sub gen_suite
@@ -166,9 +168,9 @@ sub gen_suite
166168
} else {
167169
if ($subsuite ne "") {
168170
# For subsuite
169-
$xml->{files} = { file => [ { path => 'double_test.list'}, { path => 'cmake'}, { path => 'tools'}, { path => 'CMakeLists.txt'}, { path => 'litsupport'}, { path => 'lit.cfg'}, { path => 'lit.site.cfg.in'}, { path => 'SYCL'}, { path => "$feature_folder/$subsuite", dst => "SYCL_${subsuite}/$subsuite"}, { path => '$INFO_TDRIVE/ref/lit'}, { path => $config_folder}]};
171+
$xml->{files} = { file => [ { path => 'suite_generator_sycl.pl'}, { path => 'double_test.list'}, { path => 'cmake'}, { path => 'tools'}, { path => 'CMakeLists.txt'}, { path => 'litsupport'}, { path => 'lit.cfg'}, { path => 'lit.site.cfg.in'}, { path => 'SYCL'}, { path => "$feature_folder/$subsuite", dst => "SYCL_${subsuite}/$subsuite"}, { path => '$INFO_TDRIVE/ref/lit'}, { path => $config_folder}]};
170172
} else {
171-
$xml->{files} = { file => [ { path => 'double_test.list'}, { path => 'cmake'}, { path => 'tools'}, { path => 'CMakeLists.txt'}, { path => 'litsupport'}, { path => 'lit.cfg'}, { path => 'lit.site.cfg.in'}, { path => 'SYCL'}, { path => $feature_folder}, { path => '$INFO_TDRIVE/ref/lit'}, { path => $config_folder}, { path => 'setenv.list'}]};
173+
$xml->{files} = { file => [ { path => 'suite_generator_sycl.pl'}, { path => 'double_test.list'}, { path => 'cmake'}, { path => 'tools'}, { path => 'CMakeLists.txt'}, { path => 'litsupport'}, { path => 'lit.cfg'}, { path => 'lit.site.cfg.in'}, { path => 'SYCL'}, { path => $feature_folder}, { path => '$INFO_TDRIVE/ref/lit'}, { path => $config_folder}, { path => 'setenv.list'}]};
172174
}
173175
}
174176

@@ -248,14 +250,14 @@ sub token2feature
248250
if (substr($ut, 0, 1) eq '!') {
249251
my $subtoken = substr($ut, 1);
250252
foreach my $feature (@all_gpu_features) {
251-
if ($subtoken eq "$lit_feature_prefix$feature" or $subtoken eq "aspect-fp64" and $feature eq "double") {
253+
if ($subtoken eq "$lit_feature_prefix$feature") {
252254
push(@tokens, "!$feature");
253255
last;
254256
}
255257
}
256258
} else {
257259
foreach my $feature (@all_gpu_features) {
258-
if ($ut eq "$lit_feature_prefix$feature" or $ut eq "aspect-fp64" and $feature eq "double") {
260+
if ($ut eq "$lit_feature_prefix$feature") {
259261
push(@tokens, $feature);
260262
last;
261263
}
@@ -270,7 +272,7 @@ sub token2feature
270272
if (substr($rt, 0, 1) eq '!') {
271273
my $subtoken = substr($rt, 1);
272274
foreach my $feature (@all_gpu_features) {
273-
if ($subtoken eq "$lit_feature_prefix$feature"or $subtoken eq "aspect-fp64" and $feature eq "double") {
275+
if ($subtoken eq "$lit_feature_prefix$feature") {
274276
my $seen = 0;
275277
foreach my $ref (@tokens) {
276278
my $ref_token = $ref;
@@ -287,7 +289,7 @@ sub token2feature
287289
} else {
288290
foreach my $feature (@all_gpu_features) {
289291
#if (grep(/\Q$lit_feature_prefix$rt/, @all_gpu_features)) {
290-
if ($rt eq "$lit_feature_prefix$feature" or $rt eq "aspect-fp64" and $feature eq "double") {
292+
if ($rt eq "$lit_feature_prefix$feature") {
291293
my $seen = 0;
292294
foreach my $ref (@tokens) {
293295
my $ref_token = $ref;
@@ -321,6 +323,7 @@ sub feature2rule
321323
{
322324
my $xml_ref = shift;
323325
my $features_ref = shift;
326+
my $test_xml = shift;
324327

325328
if (scalar @${features_ref}) {
326329
$$xml_ref->{rules} = { optlevelRule => []};
@@ -329,12 +332,25 @@ sub feature2rule
329332
foreach my $feature (@{$features_ref}) {
330333
push(@{$$xml_ref->{rules}{optlevelRule}}, { GPUFeature => "$feature", excludeOptlevelNameString => 'gpu'});
331334
}
335+
336+
# CMPLRTST-16836: after the 'double' type tests are splitted done, this workaround can be removed.
337+
if (-f "config_sycl.old/$test_xml") {
338+
my @lines = read_file("config_sycl.old/$test_xml");
339+
foreach my $line (@lines) {
340+
if ($line =~ m/\QGPUFeature="!double"/) {
341+
push(@{$$xml_ref->{rules}{optlevelRule}}, { GPUFeature => "!double", excludeOptlevelNameString => 'gpu'});
342+
last;
343+
}
344+
}
345+
}
332346
}
333347

334348
sub translate_gpu_feature
335349
{
336350
my $r = shift;
337351
my $xml_ref = shift;
352+
my $test_xml = shift;
353+
338354
my $f = $r->{fullpath};
339355
my @gpu_features = ();
340356

@@ -355,31 +371,35 @@ sub translate_gpu_feature
355371
}
356372

357373
@gpu_features = token2feature($r, \@require_tokens, \@unsupported_tokens);
358-
feature2rule($xml_ref, \@gpu_features);
374+
feature2rule($xml_ref, \@gpu_features, $test_xml);
359375
}
360376

361377
sub requires2rule
362378
{
363379
my $r = shift;
364380
my $xml_ref = shift;
381+
my $test_xml = shift;
365382

366-
translate_gpu_feature($r, $xml_ref);
383+
translate_gpu_feature($r, $xml_ref, $test_xml);
367384
}
368385

369386
sub gen_test
370387
{
371388
my $r = shift;
389+
my $test_xml = shift;
390+
372391
my $f = $r->{fullpath};
373392
my $xml = {};
374393
$xml->{driverID} = 'llvm_test_suite_sycl';
375394
$xml->{name} = "$r->{name}";
376395
$xml->{description} = { content => "WARNING: DON'T UPDATE THIS FILE MANUALLY!!!\nThis config file auto-generated by suite_generator_sycl.pl."};
377396

378-
requires2rule($r, \$xml);
397+
requires2rule($r, \$xml, $test_xml);
379398

380399
print2file( "$r->{path}/$r->{short_name}.cpp", "./$config_folder/$r->{name}.info");
381400

382-
return XMLout( $xml, xmldecl => '<?xml version="1.0" encoding="UTF-8" ?>', RootName => 'test');
401+
my $xml_text = XMLout( $xml, xmldecl => '<?xml version="1.0" encoding="UTF-8" ?>', RootName => 'test');
402+
print2file( $xml_text, "$config_folder/$test_xml");
383403
}
384404

385405
sub file2str
@@ -413,6 +433,24 @@ sub dump2file
413433
print2file( Dumper( $r), $file);
414434
}
415435

436+
sub read_file
437+
{
438+
my $f = shift;
439+
440+
my $fd;
441+
open $fd, $f or die "Failed to open for reading: $f: $!";
442+
# binmode as some our source files have utf-8 symbold and perl issues warnings like:
443+
# Malformed UTF-8 character (unexpected continuation byte 0x96, with no preceding start byte) in pattern match (m//)
444+
# at /home/cmplr/icl_tools/omirochn/git/filter-intel-feature.pl line 242.
445+
binmode $fd;#, ':utf8';
446+
my @in = <$fd>;
447+
close $fd or die "Failed to close after reading: $f: $!";
448+
449+
# remove the BOM character at the begining of a file, because this tool will insert Intel header in front of this line.
450+
$in[0] =~ s/^\xEF\xBB\xBF// if scalar(@in);
451+
return @in;
452+
}
453+
416454
sub execute
417455
{
418456
my $cmd = shift;
@@ -472,5 +510,3 @@ sub execute
472510
copy("$suite_name.xml", "$valgrind_suite_name.xml");
473511
print "\n\nFinish the generation of $valgrind_suite_name Successfully.\n";
474512
}
475-
476-

0 commit comments

Comments
 (0)