public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113905] New: [OpenMP] Declare variant rejects variant-function re-usage
@ 2024-02-13 11:54 burnus at gcc dot gnu.org
2024-05-17 10:49 ` [Bug c/113905] " burnus at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-02-13 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113905
Bug ID: 113905
Summary: [OpenMP] Declare variant rejects variant-function
re-usage
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: openmp, rejects-valid
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org, parras at gcc dot gnu.org,
sandra at gcc dot gnu.org
Target Milestone: ---
The attached testcase works with Clang 17 and prints:
Got 42 (OK)
Got 99 (OK)
Got 1 (OK)
Got 2 (OK)
Got 2 (OK)
Got 1 (OK)
Where foo() and bar() share the variant functions 'var1' and 'var2', which
seems to be perfectly valid.
In GCC it fails to compile:
test.c: In function 'bar':
test.c:8:36: error: 'var1' used as a variant with incompatible 'construct'
selector sets
8 | #pragma omp declare variant (var1) match(construct={target})
| ^~~~~
test.c:9:36: error: 'var2' used as a variant with incompatible 'construct'
selector sets
9 | #pragma omp declare variant (var2) match(construct={parallel})
| ^~~~~
If I only keep the 'declare variant' for 'foo', it compiles. The gimple dump
shows:
__attribute__((omp declare target, omp declare variant variant (parallel )))
int var1 ()
__attribute__((omp declare target, omp declare variant variant (target )))
int var2 ()
__attribute__((omp declare target, omp declare variant base (var2 construct
target ), omp declare variant base (var1 construct parallel )))
int foo ()
I guess the problem is the 'omp declare variant variant' attribute on 'var1'
and 'var2', which causes the issue I am seeing.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/113905] [OpenMP] Declare variant rejects variant-function re-usage
2024-02-13 11:54 [Bug c/113905] New: [OpenMP] Declare variant rejects variant-function re-usage burnus at gcc dot gnu.org
@ 2024-05-17 10:49 ` burnus at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-05-17 10:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113905
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Ups, testcase was lost. Re-written from scratch:
-------------------
int var1() { return 1; }
int var2() { return 2; }
#pragma omp declare variant (var1) match(construct={target})
#pragma omp declare variant (var2) match(construct={parallel})
int foo() { return 42; }
#pragma omp declare variant (var2) match(construct={parallel})
#pragma omp declare variant (var2) match(construct={target})
int bar() { return 99; }
int main() {
__builtin_printf("foo: %d (expected: 42)\n", foo());
__builtin_printf("bar: %d (expected: 99)\n", bar());
#pragma omp parallel if(0)
{
__builtin_printf("foo<parallel>: %d (expected: 2)\n", foo());
__builtin_printf("bar<parallel>: %d (expected: 1)\n", bar());
}
#pragma omp target //device(-1 /*omp_initial_device*/)
{
__builtin_printf("foo<target>: %d (expected: 1)\n", foo());
__builtin_printf("bar<target>: %d (expected: 2)\n", bar());
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-17 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 11:54 [Bug c/113905] New: [OpenMP] Declare variant rejects variant-function re-usage burnus at gcc dot gnu.org
2024-05-17 10:49 ` [Bug c/113905] " burnus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).