From patchwork Wed Oct 2 16:55:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul-Antoine Arras X-Patchwork-Id: 1992107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=JJ7iLegZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XJgxh0F6yz1xtY for ; Thu, 3 Oct 2024 02:58:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D957A3857000 for ; Wed, 2 Oct 2024 16:58:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 8D2513858C66 for ; Wed, 2 Oct 2024 16:56:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D2513858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8D2513858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727888167; cv=none; b=DHUEtw5vpdyN/ImGtDuz5FIjyC0ywQBBzY33nFDIYgYOrBiYg3RFxrf8yqIPHXWFsxvZQd174HcmVE9rw3ydP14QRyRz/KPThyc3x0U8dXeex/pMbZ7mr0ao15vbS2cCfH8PF3c8qb76oMrkycBwiQCVE3pQ2adECeplnbG9DJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727888167; c=relaxed/simple; bh=Eb5iw7omvY4tGhoF8nfNTvW6wFi3oYvhjMqjfbefeCs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ldE6bUA7C2okdulZXcg5FkSuc9WVZJ8m/QMTu2xzEDqFdcj1ltBKoQejnbYZo1C0jmo9F9L/fjkhwg44HLZpgs5T1bPidUOS1bQENsak14NHzhSuTw7Sg9i92iJm/mah2yv9J1XjbB55YpQF3xzXTzUlVwrdC0S4dYKRh95eGVY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42cb6f3a5bcso85140185e9.2 for ; Wed, 02 Oct 2024 09:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1727888160; x=1728492960; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OuY+7AYhsciJomKbmKYUjxEORl7S0Cxpo6CcRKO3yxs=; b=JJ7iLegZ03WdNJicm49fmmNXcSqvFhtLzHLm2TstSZoq27JxCO3EOR0MegoQ/92F18 FNu/tcfMMID/r7rBcRIggr6ZcZ9t1mfnPdaeAKi2Dsb7RqEqZLZpivhhMbvYn2zpyHPH Mu5U3iEA5WPnpZhOwNKMRRWkE4bs1kInBGxIg9vv/fW46ks2QIOwhTngY4ztyGx9kqJ9 L5kroxshg2XksCcBWnCksly5KEr2h4spTqk1XI7+ZroDYT8yvWqpscjZpn/iqjpp8dht TCwc9eQ9TBbFxE6l15YUzmZlihyFl0u3upoAREOTNe0hI4X5lARsBjGOSl5EeHEgw4Mr tWEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727888160; x=1728492960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OuY+7AYhsciJomKbmKYUjxEORl7S0Cxpo6CcRKO3yxs=; b=oVGrT8AUF6ieGJwJdhQMq+AgewSDkKbOdGnf+nw1qU6azqMHlJhUq5JLzDY0N/ggo5 NRSOY1jN3CJWxCm0/NSx+UOgaRMm+nVkx3RkOL5nf7rN7Byh3iJvkt+kMdA94LNuo++N 6kmL5RyL69bCLnCqJpfwiby5+ROvPpmR919mmaq9rDV3wUSb/4xAN7n+nLWnfz6nYAwz R1WyyFFQJ1I5T0M4v7030J2zaZWgOBVqsCSR08JMGkoZaXsVeWEAjWQsvu1aDhOZ7ZGe PXRytBvJ25y+4zf8+1bz6OVnwbLJarGKYxIp1gYQUuYHGneFNpHvf7+IlUMxuMmtayMH lRNA== X-Gm-Message-State: AOJu0YysfOec1jrqDIvj19jk0HPJmG1BXjSC9zJ4ymPWu96SUwRgxyVO D53b+qQNqEcNg7K47pqhDDHi6WQ6lBVaJacsYeKOiZf8v86xmUIHximLrbuJIB1Jk02bspn2WY3 5 X-Google-Smtp-Source: AGHT+IH1bIuiOp5+bpadqY0OVKVhKIKLaBiI0J6Hd9vAHoDLG7773QvGJaJrRdfYFZsk5G0IAFRXFQ== X-Received: by 2002:a05:6000:b87:b0:374:c9f0:7533 with SMTP id ffacd0b85a97d-37cfba0a5c5mr3426694f8f.41.1727888159631; Wed, 02 Oct 2024 09:55:59 -0700 (PDT) Received: from localhost.localdomain (2a01cb0018c22f0003fd7af961426ad9.ipv6.abo.wanadoo.fr. [2a01:cb00:18c2:2f00:3fd:7af9:6142:6ad9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd575de73sm14244859f8f.115.2024.10.02.09.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 09:55:59 -0700 (PDT) From: Paul-Antoine Arras To: gcc-patches@gcc.gnu.org Cc: Paul-Antoine Arras Subject: [PATCH v4 5/7] OpenMP: common C/C++ testcases for dispatch + adjust_args Date: Wed, 2 Oct 2024 18:55:36 +0200 Message-ID: <20241002165538.3237107-6-parras@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241002165538.3237107-1-parras@baylibre.com> References: <20241002165538.3237107-1-parras@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org gcc/testsuite/ChangeLog: * c-c++-common/gomp/declare-variant-2.c: Adjust dg-error directives. * c-c++-common/gomp/adjust-args-1.c: New test. * c-c++-common/gomp/adjust-args-2.c: New test. * c-c++-common/gomp/dispatch-1.c: New test. * c-c++-common/gomp/dispatch-2.c: New test. * c-c++-common/gomp/dispatch-3.c: New test. * c-c++-common/gomp/dispatch-4.c: New test. * c-c++-common/gomp/dispatch-5.c: New test. * c-c++-common/gomp/dispatch-6.c: New test. * c-c++-common/gomp/dispatch-7.c: New test. * c-c++-common/gomp/dispatch-8.c: New test. --- .../c-c++-common/gomp/adjust-args-1.c | 30 ++++++++ .../c-c++-common/gomp/adjust-args-2.c | 31 ++++++++ .../c-c++-common/gomp/declare-variant-2.c | 4 +- gcc/testsuite/c-c++-common/gomp/dispatch-1.c | 71 +++++++++++++++++++ gcc/testsuite/c-c++-common/gomp/dispatch-2.c | 28 ++++++++ gcc/testsuite/c-c++-common/gomp/dispatch-3.c | 12 ++++ gcc/testsuite/c-c++-common/gomp/dispatch-4.c | 18 +++++ gcc/testsuite/c-c++-common/gomp/dispatch-5.c | 34 +++++++++ gcc/testsuite/c-c++-common/gomp/dispatch-6.c | 18 +++++ gcc/testsuite/c-c++-common/gomp/dispatch-7.c | 21 ++++++ gcc/testsuite/c-c++-common/gomp/dispatch-8.c | 63 ++++++++++++++++ gcc/testsuite/c-c++-common/gomp/dispatch-9.c | 17 +++++ .../dispatch-1.c | 0 .../dispatch-2.c | 0 14 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/adjust-args-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/adjust-args-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-1.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-2.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-3.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-4.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-5.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-6.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-7.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-8.c create mode 100644 gcc/testsuite/c-c++-common/gomp/dispatch-9.c rename libgomp/testsuite/{libgomp.c => libgomp.c-c++-common}/dispatch-1.c (100%) rename libgomp/testsuite/{libgomp.c => libgomp.c-c++-common}/dispatch-2.c (100%) diff --git a/gcc/testsuite/c-c++-common/gomp/adjust-args-1.c b/gcc/testsuite/c-c++-common/gomp/adjust-args-1.c new file mode 100644 index 00000000000..728abe62092 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/adjust-args-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +int f (int a, void *b, float c[2]); + +#pragma omp declare variant (f) match (construct={dispatch}) adjust_args (nothing: a) adjust_args (need_device_ptr: b, c) +int f0 (int a, void *b, float c[2]); +#pragma omp declare variant (f) match (construct={dispatch}) adjust_args (nothing: a) adjust_args (need_device_ptr: b) adjust_args (need_device_ptr: c) +int f1 (int a, void *b, float c[2]); + +int test () { + int a; + void *b; + float c[2]; + struct {int a;} s; + + s.a = f0 (a, b, c); + #pragma omp dispatch + s.a = f0 (a, b, c); + + f1 (a, b, c); + #pragma omp dispatch + s.a = f1 (a, b, c); + + return s.a; +} + +/* { dg-final { scan-tree-dump-times "__builtin_omp_get_default_device \\(\\);" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(&c, D\.\[0-9]+\\);" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(b, D\.\[0-9]+\\);" 2 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/adjust-args-2.c b/gcc/testsuite/c-c++-common/gomp/adjust-args-2.c new file mode 100644 index 00000000000..d2a4a5f4ec4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/adjust-args-2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +int f (int a, void *b, float c[2]); + +#pragma omp declare variant (f) match (construct={dispatch}) adjust_args (nothing: a) adjust_args (need_device_ptr: b, c) +int f0 (int a, void *b, float c[2]); +#pragma omp declare variant (f) adjust_args (need_device_ptr: b, c) match (construct={dispatch}) adjust_args (nothing: a) +int f1 (int a, void *b, float c[2]); + +void test () { + int a; + void *b; + float c[2]; + + #pragma omp dispatch + f0 (a, b, c); + + #pragma omp dispatch device (-4852) + f0 (a, b, c); + + #pragma omp dispatch device (a + a) + f0 (a, b, c); +} + +/* { dg-final { scan-tree-dump-times "__builtin_omp_get_default_device \\(\\);" 3 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(&c, D\.\[0-9]+\\);" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(b, D\.\[0-9]+\\);" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(&c, -4852\\);" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "D\.\[0-9]+ = __builtin_omp_get_mapped_ptr \\(b, -4852\\);" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-not "#pragma omp dispatch device" "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c index 05e485ef6a8..50d9b2dcf4b 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c @@ -8,9 +8,9 @@ void f3 (void); void f4 (void); #pragma omp declare variant match(user={condition(0)}) /* { dg-error "expected '\\(' before 'match'" } */ void f5 (void); -#pragma omp declare variant (f1) /* { dg-error "expected 'match' before end of line" } */ +#pragma omp declare variant (f1) /* { dg-error "expected 'match' or 'adjust_args' before end of line" } */ void f6 (void); -#pragma omp declare variant (f1) simd /* { dg-error "expected 'match' before 'simd'" } */ +#pragma omp declare variant (f1) simd /* { dg-error "expected 'match' or 'adjust_args' before 'simd'" } */ void f7 (void); #pragma omp declare variant (f1) match /* { dg-error "expected '\\(' before end of line" } */ void f8 (void); diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-1.c b/gcc/testsuite/c-c++-common/gomp/dispatch-1.c new file mode 100644 index 00000000000..2a4e939d000 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-1.c @@ -0,0 +1,71 @@ +#include + +int f0 (int, long, double); +void f2 (void); +int f3 (void); +void (*f4) (void); +void f5 (int*, int); + +int *pp (void); +int dd (void); + +void f1 (void) +{ + int a, c; + long b; + double x; + struct {int a; float b; short c;} s, *sp; + int arr[3]; + +#pragma omp dispatch + c = f0 (a, b, x); +#pragma omp dispatch + x = f0 (a * 4, 2 - b, x * x); +#pragma omp dispatch + s.a = f0 (a, sp->c, x); +#pragma omp dispatch + sp->c = f0 (s.a - 2, b / 3, x * 5); +#pragma omp dispatch + arr[0] = f0 (arr[1], !b, arr[2]); +#pragma omp dispatch + (*sp).c = f0 (s.a, b, x); +#pragma omp dispatch + sp->b = f0 (s.a++, b % 4, --x); +#pragma omp dispatch + f0 (f3(), b, s.b); +#pragma omp dispatch + f2 (); +#pragma omp dispatch + f4 (); +#pragma omp dispatch + f5 (pp(), pp()[dd()]); + +#pragma omp dispatch nocontext(sp->a * x + arr[2]) + f2 (); +#pragma omp dispatch nocontext(arr - (intptr_t)(x / s.b)) + f2 (); +#pragma omp dispatch nocontext(x == s.c || b != c) + f2 (); +#pragma omp dispatch novariants(b << sp->c) + f2 (); +#pragma omp dispatch novariants(!arr | s.a) + f2 (); +#pragma omp dispatch novariants(s.c ? f3() : a & c) + f2 (); +#pragma omp dispatch nowait + f2 (); +#pragma omp dispatch device(-25373654) + f2 (); +#pragma omp dispatch device(b * (int)(x - sp->b)) + f2 (); +#pragma omp dispatch is_device_ptr(arr) + f2 (); +#pragma omp dispatch is_device_ptr(sp) + f2 (); +#pragma omp dispatch depend(inout: sp) + f2 (); +#pragma omp dispatch depend(inoutset: arr[:2]) + f2 (); +#pragma omp dispatch depend(out: arr) + f2 (); +} diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-2.c b/gcc/testsuite/c-c++-common/gomp/dispatch-2.c new file mode 100644 index 00000000000..24ab9545b73 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +int f0 (void); +int f1 (void); +#pragma omp declare variant (f0) match (construct={dispatch}) +#pragma omp declare variant (f1) match (implementation={vendor(gnu)}) +int f2 (void); + +int test (void) +{ + int a; +#pragma omp dispatch + a = f2 (); +#pragma omp dispatch novariants(1) + a = f2 (); +#pragma omp dispatch novariants(0) + a = f2 (); +#pragma omp dispatch nocontext(1) + a = f2 (); +#pragma omp dispatch nocontext(0) + a = f2 (); + return a; +} + +/* { dg-final { scan-tree-dump-times "a = f0 \\\(\\\);" 3 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "a = f1 \\\(\\\);" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "a = f2 \\\(\\\);" 1 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-3.c b/gcc/testsuite/c-c++-common/gomp/dispatch-3.c new file mode 100644 index 00000000000..dba1d4ffdc8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +void f2 (void); + +void test (void) +{ +#pragma omp dispatch /* { dg-final { scan-tree-dump-not "#pragma omp task" "gimple" } } */ + f2 (); +#pragma omp dispatch nowait /* { dg-final { scan-tree-dump-not "nowait" "gimple" } } */ + f2 (); +} diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-4.c b/gcc/testsuite/c-c++-common/gomp/dispatch-4.c new file mode 100644 index 00000000000..ac746f755be --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +void f2 (int a); + +void test (void) +{ + int a; + +#pragma omp dispatch device(-25373654) +/* { dg-final { scan-tree-dump-times "__builtin_omp_set_default_device \\(-25373654\\);" 1 "gimple" } } */ + f2 (a); +#pragma omp dispatch device(a + a) +/* { dg-final { scan-tree-dump-times "(D\.\[0-9]+) = a \\* 2;.*#pragma omp dispatch.*__builtin_omp_set_default_device \\(\\1\\);.*f2 \\(a\\)" 2 "gimple" } } */ + f2 (a); +} + +/* { dg-final { scan-tree-dump-times "(D\.\[0-9]+) = __builtin_omp_get_default_device \\(\\);.*__builtin_omp_set_default_device \\(\\1\\);" 4 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-5.c b/gcc/testsuite/c-c++-common/gomp/dispatch-5.c new file mode 100644 index 00000000000..608c6d9f154 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-5.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +void f1 (void* p, int arr[]); +#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args (need_device_ptr: p, arr) +void f2 (void* p, int arr[]); + +void test (void) +{ + void *p; + int arr[2]; + +/* Note there are multiple matches because every variable capturing matches in addition, + i.e. scan-tree-dump-times = 1 plus number of captures used for backward references. + + For the first scan-tree-dump, on some targets the __builtin_omp_get_mapped_ptr get + swapped. As the counting does not work well with variable-name capturing, it only + uses 'scan-tree-dump' and not 'scan-tree-dump-times'. */ + +#pragma omp dispatch +/* { dg-final { scan-tree-dump "#pragma omp dispatch\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(&arr, \\1\\);\[ \t\n\r]*\\3 = __builtin_omp_get_mapped_ptr \\(p, \\1\\);\[ \t\n\r]*f1 \\(\\3, \\2\\);|#pragma omp dispatch\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\4 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\5 = __builtin_omp_get_mapped_ptr \\(p, \\4\\);\[ \t\n\r]*\\6 = __builtin_omp_get_mapped_ptr \\(&arr, \\4\\);\[ \t\n\r]*f1 \\(\\5, \\6\\);" "gimple" } } */ + f2 (p, arr); +#pragma omp dispatch is_device_ptr(p) +/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(p\\)\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(&arr, \\1\\);\[ \t\n\r]*f1 \\(p, \\2\\);" 3 "gimple" } } */ + f2 (p, arr); +#pragma omp dispatch is_device_ptr(arr) +/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(arr\\)\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(p, \\1\\);\[ \t\n\r]*f1 \\(\\2, &arr\\);" 3 "gimple" } } */ + f2 (p, arr); +#pragma omp dispatch is_device_ptr(p, arr) +/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(arr\\) is_device_ptr\\(p\\)\[ \t\n\r\{]*f1 \\(p, &arr\\);" 1 "gimple" } } */ + f2 (p, arr); +} + + diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-6.c b/gcc/testsuite/c-c++-common/gomp/dispatch-6.c new file mode 100644 index 00000000000..4e900bb5e8d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-6.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-ompexp" } */ + +void f2 (void* p); + +void test (void) +{ + void *p; + +#pragma omp dispatch +/* { dg-final { scan-tree-dump-not "__builtin_GOMP_task " "ompexp" } } */ + f2 (p); +#pragma omp dispatch depend(inout: p) +/* { dg-final { scan-tree-dump-times "(D\.\[0-9]+)\\\[2] = &p;\[ \n]*__builtin_GOMP_taskwait_depend \\(&\\1\\);" 2 "ompexp" } } */ + f2 (p); +} + + diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-7.c b/gcc/testsuite/c-c++-common/gomp/dispatch-7.c new file mode 100644 index 00000000000..44a62608eb0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-7.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-gimple" } */ + +int f0 (void); +int f1 (void); +#pragma omp declare variant (f0) match (construct={dispatch}) +#pragma omp declare variant (f1) match (implementation={vendor(gnu)}) +int f2 (void); + +int test (void) +{ + int a, n; +#pragma omp dispatch novariants(n < 1024) nocontext(n > 1024) + a = f2 (); + return a; +} + +/* { dg-final { scan-tree-dump-times "#pragma omp dispatch nocontext\\(0\\) novariants\\(0\\)" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "a = f2 \\\(\\\);" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "a = f1 \\\(\\\);" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "a = f0 \\\(\\\);" 1 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-8.c b/gcc/testsuite/c-c++-common/gomp/dispatch-8.c new file mode 100644 index 00000000000..11713554a82 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-8.c @@ -0,0 +1,63 @@ +int g1() { return 100; } +int g2() { return 200; } + +#pragma omp declare variant (g1) match (construct={dispatch},user={condition(1)}) +#pragma omp declare variant (g2) match (user={condition(1)}) +int g() { return 300; } + + +int f1(int x) { return 1 + x; } +int f2(int x) { return 2 + x; } + +#pragma omp declare variant (f1) match (construct={dispatch},user={condition(1)}) +#pragma omp declare variant (f2) match (user={condition(1)}) +int f(int x) { return 3 + x; } + + +void +test () +{ + int res; + + // Call f2(g2()) due to user condition(1) + res = f (g ()); + __builtin_printf("%d\n", res); + if (res != 202) + __builtin_abort (); + + // Call 'f1(g1())' due to construct 'dispatch' and user conditional(1) + #pragma omp dispatch + res = f (g ()); + __builtin_printf("%d\n", res); + if (res != 101) + __builtin_abort (); + + // Call 'f2(g2())' due to nocontext (i.e. ignore construct 'dispatch') and user conditional(1) + #pragma omp dispatch nocontext(1) + res = f (g ()); + __builtin_printf("%d\n", res); + if (res != 202) + __builtin_abort (); + + // Call 'f' due to 'novariants' + // Call 'g1' due to construct 'dispatch' and user conditional(1) + #pragma omp dispatch novariants(1) + res = f (g ()); + __builtin_printf("%d\n", res); /* ACTUAL RESULT: 303, i.e. 'g' and not 'g1' was called */ + if (res != 103) + __builtin_abort (); + + // Call 'f' due to 'novariants' + // Call 'g2' due to nocontext (i.e. ignore construct 'dispatch') and user conditional(1) + #pragma omp dispatch novariants(1) nocontext(1) + res = f (g ()); + __builtin_printf("%d\n", res); /* ACTUAL RESULT: 303, i.e. 'g' and not 'g2' was called */ + if (res != 203) + __builtin_abort (); +} + +int +main () +{ + test (); +} diff --git a/gcc/testsuite/c-c++-common/gomp/dispatch-9.c b/gcc/testsuite/c-c++-common/gomp/dispatch-9.c new file mode 100644 index 00000000000..b4b46b946fd --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/dispatch-9.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fdump-tree-original -fdump-tree-gimple" } */ + +/* Check that the right call to f is wrapped in a GOMP_DISPATCH internal function + before translation and that it is stripped during gimplification. */ + +int f(int); +void g(int *x) +{ + #pragma omp dispatch + x[f(1)] = f(f(2)); + // ^ only this call to f is a dispatch call +} + +/* { dg-final { scan-tree-dump "\.GOMP_DISPATCH \\(f \\(f \\(2\\)\\)\\)" "original" } } */ +/* { dg-final { scan-tree-dump-times "\.GOMP_DISPATCH" 1 "original" } } */ +/* { dg-final { scan-tree-dump-not "\.GOMP_DISPATCH" "gimple" } } */ diff --git a/libgomp/testsuite/libgomp.c/dispatch-1.c b/libgomp/testsuite/libgomp.c-c++-common/dispatch-1.c similarity index 100% rename from libgomp/testsuite/libgomp.c/dispatch-1.c rename to libgomp/testsuite/libgomp.c-c++-common/dispatch-1.c diff --git a/libgomp/testsuite/libgomp.c/dispatch-2.c b/libgomp/testsuite/libgomp.c-c++-common/dispatch-2.c similarity index 100% rename from libgomp/testsuite/libgomp.c/dispatch-2.c rename to libgomp/testsuite/libgomp.c-c++-common/dispatch-2.c