[gcc/devel/omp/gcc-14] amdgcn: Support AMD-specific 'isa' and 'arch' traits in OpenMP context selectors
Paul-Antoine Arras
parras@gcc.gnu.org
Fri Jun 28 09:51:41 GMT 2024
https://gcc.gnu.org/g:5e56c3791448a93320388dc18d464ca283f92c65
commit 5e56c3791448a93320388dc18d464ca283f92c65
Author: Paul-Antoine Arras <pa@codesourcery.com>
Date: Wed Nov 30 14:52:55 2022 +0100
amdgcn: Support AMD-specific 'isa' and 'arch' traits in OpenMP context selectors
Add libgomp support for 'amdgcn' as arch, and for each processor type (as passed
to '-march') as isa traits.
Add test case for all supported 'isa' values used as context selectors in a
metadirective construct.
libgomp/ChangeLog:
* config/gcn/selector.c (GOMP_evaluate_current_device): Recognise 'amdgcn'
as arch, and '-march' values (as well as 'gfx803') as isa traits.
* testsuite/libgomp.c-c++-common/metadirective-6.c: New test.
Diff:
---
libgomp/ChangeLog.omp | 6 +++
.../libgomp.c-c++-common/metadirective-6.c | 48 ++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 663f004ed7f..4947ef676bb 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,9 @@
+2022-12-06 Paul-Antoine Arras <pa@codesourcery.com>
+
+ * config/gcn/selector.c (GOMP_evaluate_current_device): Recognise 'amdgcn'
+ as arch, and '-march' values (as well as 'gfx803') as isa traits.
+ * testsuite/libgomp.c-c++-common/metadirective-6.c: New test.
+
2022-11-02 Tobias Burnus <tobias@codesourcery.com>
* testsuite/libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-directive.f90:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/metadirective-6.c b/libgomp/testsuite/libgomp.c-c++-common/metadirective-6.c
new file mode 100644
index 00000000000..b3aa57be313
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/metadirective-6.c
@@ -0,0 +1,48 @@
+/* { dg-do link { target { offload_target_amdgcn } } } */
+/* { dg-additional-options "-foffload=-fdump-tree-ompdevlow" } */
+
+#define N 100
+
+void f (int x[], int y[], int z[])
+{
+ int i;
+
+ #pragma omp target map(to: x, y) map(from: z)
+ #pragma omp metadirective \
+ when (device={isa("gfx803")}: teams num_teams(512)) \
+ when (device={isa("gfx900")}: teams num_teams(256)) \
+ when (device={isa("gfx906")}: teams num_teams(128)) \
+ when (device={isa("gfx908")}: teams num_teams(64)) \
+ when (device={isa("gfx90a")}: teams num_teams(32)) \
+ default (teams num_teams(4))
+ for (i = 0; i < N; i++)
+ z[i] = x[i] * y[i];
+}
+
+int main (void)
+{
+ int x[N], y[N], z[N];
+ int i;
+
+ for (i = 0; i < N; i++)
+ {
+ x[i] = i;
+ y[i] = -i;
+ }
+
+ f (x, y, z);
+
+ for (i = 0; i < N; i++)
+ if (z[i] != x[i] * y[i])
+ return 1;
+
+ return 0;
+}
+
+/* The metadirective should be resolved after Gimplification. */
+
+/* { dg-final { scan-offload-tree-dump "__builtin_GOMP_teams4 \\(512, 512" "ompdevlow" { target { any-opts "-foffload=-march=fiji" } } } } */
+/* { dg-final { scan-offload-tree-dump "__builtin_GOMP_teams4 \\(256, 256" "ompdevlow" { target { any-opts "-foffload=-march=gfx900" } } } } */
+/* { dg-final { scan-offload-tree-dump "__builtin_GOMP_teams4 \\(128, 128" "ompdevlow" { target { any-opts "-foffload=-march=gfx906" } } } } */
+/* { dg-final { scan-offload-tree-dump "__builtin_GOMP_teams4 \\(64, 64" "ompdevlow" { target { any-opts "-foffload=-march=gfx908" } } } } */
+/* { dg-final { scan-offload-tree-dump "__builtin_GOMP_teams4 \\(32, 32" "ompdevlow" { target { any-opts "-foffload=-march=gfx90a" } } } } */
More information about the Gcc-cvs
mailing list