From patchwork Fri Oct 20 16:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 156229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1192378vqb; Fri, 20 Oct 2023 09:50:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0w0uHZyUPUWAFJgbAet/USw7qABKwE7Yz1/zz6s4bLUAIe1PrL7z3GBOs26QEAXuTwze+ X-Received: by 2002:aca:2809:0:b0:3a8:5ff0:6b52 with SMTP id 9-20020aca2809000000b003a85ff06b52mr2421489oix.15.1697820644973; Fri, 20 Oct 2023 09:50:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697820644; cv=pass; d=google.com; s=arc-20160816; b=mR0Uu60OOQRToooyagXKHbMPRaDEoGpY4PngJLBTxJR00ir+PW8dfDKBdPmzZvivQT vOeMHdIcWWSXhY4OxtwCWqM3c/GDqbB0mFF2KFlGc9uJrJ1v1afo2qy20i6vA+JC7P2F cI3D8vIdl8ktKuZAtG5rs65888LcT2uo9scv06C//0QsslX1/71x5XoLgWbtYH6lLjRJ q91hYib7qQqNzMs79Ep3o0NZ05mhcIg4JL8cL/s0KZ+9WT2PgQWQzVQEgyz6LZJnoTNm bUNZaH1Nil2rdIydVIrgRphnxi+aidAVqJuYpKBpfvaPzYQg8rnwbrPR8zh1ggk8WbS+ ccuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:arc-filter:dmarc-filter:delivered-to; bh=Dvqh6+SrZhLOrspFT/WUGenYxTND0Pg9b0dSGbrvSTs=; fh=CT9ANdoiYgjVt7HQGxGdzRB+HPa196wDRuos5o/1sIg=; b=PQ3ypo1Fs4eadV6H7bXoufMAXv2w6HEJLgbzvUj47BFFX+OHn617UzGUI0MKS2nIdx I15r10oNGMaDae5EEw+g5wjpX48xTHy5TkYtBF1PUG1a8yd/eDwL39s1/wToV12JRrrH AgnbIeHM/hMZN6gv8729VpTNi9qE8U40AldSmQ+qzuX4bAXX5iM0teOx4r8foLTn1r/5 JOhFm48CVmlSRaMcJWOB5socEPgs9ZveOicxna/vtjO/mEwSMx0RcQ9MJqH20Gda0IXA rObulnj/SXnkSb28VBFSY5eAKtt8P9J4DJP/k4/whAp5kbw00+CrR5pKtSKvOTb3R2om PzNA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f18-20020a05622a1a1200b00403abf5b44csi1591278qtb.264.2023.10.20.09.50.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 163373857721 for ; Fri, 20 Oct 2023 16:50:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id EEF933858D39 for ; Fri, 20 Oct 2023 16:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEF933858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EEF933858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697820609; cv=none; b=UKFWaBjVdQ4OkM/vYRJ2zfFEWh3EVrF8ZKlCHb8+0D0eG/scLdO5Txe8TDeCYGekwtChVp/1Bjj9pWdLUmFWOlRxu7PhR+oRDZATQ7D8y4K09piLN7MT+thtN/EGS6XadxPzjktQy2Kcq/6XkB1/VopG7yqvopzpOcG6M2AxQJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697820609; c=relaxed/simple; bh=Dvqh6+SrZhLOrspFT/WUGenYxTND0Pg9b0dSGbrvSTs=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=eoXbe0JE4BC/BJD74WnOneMLINIZrobY5Qm8rfl0cEEtvZtAyRmlDVGkh9T05i1SjNPVRbqTUmK4DUC/nzaEsOHjMIJWEP389r+/eOE8Rj9f3MlybIBziqjE5N1zisu9RfNNm+UwfpShPqoVBL8u8q03N8buVHD1gLwkTGOnAok= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: L3tkrOkGRh674cK6twLwog== X-CSE-MsgGUID: 6lpzJxMOTo+hBiSiqjLoRQ== X-IronPort-AV: E=Sophos;i="6.03,239,1694764800"; d="diff'?scan'208";a="22691601" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 20 Oct 2023 08:50:03 -0800 IronPort-SDR: AtUNqRAwnv/LxaUMxy4z0YtJCpMrnhBWsKfK2m3szwFPcWr1FDeor+Q18p87EUHuaMU2Cu/z8Q ohAsCi1cUbecONvIFWyiE0A704vkexRbwKk4zZSLnFkXnV5L0JqnNaQTNO+mGbLUsAveghASsJ A8JlMs6660LFNnDlk9XtZVIIYSHd5BSqZPHtuoArc5fWQnNCUuIb7HnRSvAaw1TkLpki95DVaT 7fmNPfDM+XvkIucMAiHQr9lKHTLAiuQChmVkb3WJLOyiwe6tE5nq/rrOc6iuznawidKrBpSfqB C1o= Message-ID: Date: Fri, 20 Oct 2023 18:49:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] OpenMP: Add C++ support for 'omp allocate' with stack variables X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780293981029205369 X-GMAIL-MSGID: 1780293981029205369 This patch adds C++ support for OpenMP's 'omp allocate' for stack/automatic arrays. Comments and suggestions? — I bet there are given my little knowledge about the C++ FE... Tobias PS: I think I should write some additional C++-specific code, I bet some corner cases are missed. The question is only which ones. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 OpenMP: Add C++ support for 'omp allocate' with stack variables gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_allocate): Change error wording. gcc/cp/ChangeLog: * cp-tree.h (finish_omp_allocate): New prototype. * parser.cc (struct cp_omp_loc_tree, cp_check_omp_allocate_allocator_r): New. (cp_parser_omp_allocate): Call it; remove sorry, improve checks, call finish_omp_allocate. * pt.cc (tsubst_stmt): Call finish_omp_allocate. * semantics.cc (finish_omp_allocate): New. libgomp/ChangeLog: * libgomp.texi (OpenMP Impl. Status): Document that 'omp allocate' is now supported for C++ stack/automatic variables. * testsuite/libgomp.c-c++-common/allocate-4.c: Renamed from ... testsuite/libgomp.c/allocate-4.c: ... this. * testsuite/libgomp.c-c++-common/allocate-5.c: Renamed from ... testsuite/libgomp.c/allocate-5.c: ... this. * testsuite/libgomp.c-c++-common/allocate-6.c: Renamed from ... testsuite/libgomp.c/allocate-6.c: ... this. * testsuite/libgomp.c++/allocate-2.C: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/allocate-5.c: Remove C++ 'sorry'; minor updates. * c-c++-common/gomp/allocate-9.c: Likewise. * c-c++-common/gomp/allocate-17.c: Likewise. * c-c++-common/gomp/directive-1.c: Likewise. * g++.dg/gomp/allocate-5.C: New test. gcc/c/c-parser.cc | 2 +- gcc/cp/cp-tree.h | 4 + gcc/cp/parser.cc | 149 +++++++--- gcc/cp/pt.cc | 4 + gcc/cp/semantics.cc | 80 +++++ gcc/testsuite/c-c++-common/gomp/allocate-17.c | 2 +- gcc/testsuite/c-c++-common/gomp/allocate-5.c | 24 +- gcc/testsuite/c-c++-common/gomp/allocate-9.c | 59 ++-- gcc/testsuite/g++.dg/gomp/allocate-5.C | 14 + libgomp/libgomp.texi | 4 +- libgomp/testsuite/libgomp.c++/allocate-2.C | 329 +++++++++++++++++++++ .../allocate-4.c | 3 - .../allocate-5.c | 3 - .../allocate-6.c | 3 - 14 files changed, 567 insertions(+), 113 deletions(-) diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 0d468b86bd8..49befd6ffc4 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -19501,7 +19501,7 @@ c_parser_omp_allocate (c_parser *parser) != get_identifier ("omp_allocator_handle_t")) { error_at (expr_loc, - "% clause allocator expression has type " + "% clause expression has type " "%qT rather than %", TREE_TYPE (allocator)); allocator = NULL_TREE; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 30fe716b109..d3a85f39e3e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7801,6 +7801,10 @@ extern tree finish_omp_for (location_t, enum tree_code, tree, tree, tree, tree, tree, tree, tree, vec *, tree); extern tree finish_omp_for_block (tree, tree); +extern void finish_omp_allocate (bool, location_t, tree, + tree = NULL_TREE, + tsubst_flags_t = tf_warning_or_error, + tree = NULL_TREE); extern void finish_omp_atomic (location_t, enum tree_code, enum tree_code, tree, tree, tree, tree, tree, tree, tree, diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 5483121f51c..b163618292e 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -41864,6 +41864,67 @@ cp_parser_omp_structured_block (cp_parser *parser, bool *if_p) return finish_omp_structured_block (stmt); } +struct cp_omp_loc_tree +{ + location_t loc; + tree var; +}; + +/* Check whether the expression used in the allocator clause is declared or + modified between the variable declaration and its allocate directive. */ +static tree +cp_check_omp_allocate_allocator_r (tree *tp, int *, void *data) +{ + tree var = ((struct cp_omp_loc_tree *) data)->var; + location_t loc = ((struct cp_omp_loc_tree *) data)->loc; + tree v = NULL_TREE; + if (TREE_CODE (*tp) == VAR_DECL) + for (v = current_binding_level->names; v; v = TREE_CHAIN (v)) + if (v == var) + break; + if (v != NULL_TREE) + { + if (linemap_location_before_p (line_table, DECL_SOURCE_LOCATION (var), + DECL_SOURCE_LOCATION (*tp))) + { + error_at (loc, "variable %qD used in the % clause must " + "be declared before %qD", *tp, var); + inform (DECL_SOURCE_LOCATION (*tp), "declared here"); + inform (DECL_SOURCE_LOCATION (var), + "to be allocated variable declared here"); + return *tp; + } + else + { + gcc_assert (cur_stmt_list + && TREE_CODE (cur_stmt_list) == STATEMENT_LIST); + + tree_stmt_iterator l = tsi_last (cur_stmt_list); + while (!tsi_end_p (l)) + { + if (linemap_location_before_p (line_table, EXPR_LOCATION (*l), + DECL_SOURCE_LOCATION (var))) + break; + if (TREE_CODE (*l) == MODIFY_EXPR + && TREE_OPERAND (*l, 0) == *tp) + { + error_at (loc, + "variable %qD used in the % clause " + "must not be modified between declaration of %qD " + "and its % directive", *tp, var); + inform (EXPR_LOCATION (*l), "modified here"); + inform (DECL_SOURCE_LOCATION (var), + "to be allocated variable declared here"); + return *tp; + } + --l; + } + } + } + return NULL_TREE; +} + + /* OpenMP 5.x: # pragma omp allocate (list) clauses @@ -41878,7 +41939,6 @@ cp_parser_omp_allocate (cp_parser *parser, cp_token *pragma_tok) { tree allocator = NULL_TREE; tree alignment = NULL_TREE; - location_t loc = pragma_tok->location; tree nl = cp_parser_omp_var_list (parser, OMP_CLAUSE_ALLOCATE, NULL_TREE); do @@ -41908,63 +41968,56 @@ cp_parser_omp_allocate (cp_parser *parser, cp_token *pragma_tok) break; } else if (p[2] == 'i') - { - if (expr != error_mark_node) - alignment = expr; - /* FIXME: Remove when adding check to semantics.cc; cf FIXME below. */ - if (alignment - && !type_dependent_expression_p (alignment) - && !INTEGRAL_TYPE_P (TREE_TYPE (alignment))) - { - error_at (cloc, "% clause argument needs to be " - "positive constant power of two integer " - "expression"); - alignment = NULL_TREE; - } - else if (alignment) - { - alignment = mark_rvalue_use (alignment); - if (!processing_template_decl) - { - alignment = maybe_constant_value (alignment); - if (TREE_CODE (alignment) != INTEGER_CST - || !tree_fits_uhwi_p (alignment) - || !integer_pow2p (alignment)) - { - error_at (cloc, "% clause argument needs to be " - "positive constant power of two integer " - "expression"); - alignment = NULL_TREE; - } - } - } - } + alignment = expr; else if (allocator) { error_at (cloc, "too many %qs clauses", "allocator"); break; } else - { - if (expr != error_mark_node) - allocator = expr; - } + allocator = expr; parens.require_close (parser); } while (true); cp_parser_require_pragma_eol (parser, pragma_tok); - if (allocator || alignment) - for (tree c = nl; c != NULL_TREE; c = OMP_CLAUSE_CHAIN (c)) - { - OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) = allocator; - OMP_CLAUSE_ALLOCATE_ALIGN (c) = alignment; - } - - /* FIXME: When implementing properly, delete the align/allocate expr error - check above and add one in semantics.cc (to properly handle templates). - Base this on the allocator/align modifiers check for the 'allocate' clause - in semantics.cc's finish_omp_clauses. */ - sorry_at (loc, "%<#pragma omp allocate%> not yet supported"); + for (tree c = nl; c != NULL_TREE; c = OMP_CLAUSE_CHAIN (c)) + { + tree var = OMP_CLAUSE_DECL (c); + if (lookup_attribute ("omp allocate", DECL_ATTRIBUTES (var))) + { + error_at (OMP_CLAUSE_LOCATION (nl), + "%qD already appeared as list item in an " + "% directive", var); + continue; + } + if (TREE_CODE (var) == PARM_DECL) + { + error_at (OMP_CLAUSE_LOCATION (nl), + "function parameter %qD may not appear as list item in an " + "% directive", var); + continue; + } + tree v; + for (v = current_binding_level->names; v; v = TREE_CHAIN (v)) + if (v == var) + break; + if (v == NULL_TREE) + { + error_at (OMP_CLAUSE_LOCATION (nl), + "% directive must be in the same scope as %qD", + var); + inform (DECL_SOURCE_LOCATION (var), "declared here"); + continue; + } + struct cp_omp_loc_tree data + = {EXPR_LOC_OR_LOC (allocator, OMP_CLAUSE_LOCATION (nl)), var}; + walk_tree (&allocator, cp_check_omp_allocate_allocator_r, &data, NULL); + DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("omp allocate"), + build_tree_list (allocator, alignment), + DECL_ATTRIBUTES (var)); + if (!processing_template_decl) + finish_omp_allocate (true, OMP_CLAUSE_LOCATION (nl), var); + } } /* OpenMP 2.5: diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 210c6cb9e4d..10603f4c39f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -18379,6 +18379,10 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) cp_finish_decl (decl, init, const_init, asmspec_tree, 0, decomp); + + if (flag_openmp && VAR_P (decl)) + finish_omp_allocate (false, DECL_SOURCE_LOCATION (decl), + decl, args, complain, in_decl); if (ndecl != error_mark_node) cp_finish_decomp (ndecl, decomp); diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index dc3c11461fb..30c70c0b13e 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -10987,6 +10987,86 @@ finish_omp_for_block (tree bind, tree omp_for) return bind; } +void +finish_omp_allocate (bool in_parsing, location_t loc, tree decl, tree args, + tsubst_flags_t complain, tree in_decl) +{ + location_t loc2; + tree attr = lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl)); + if (attr == NULL_TREE) + return; + + tree allocator = TREE_PURPOSE (TREE_VALUE (attr)); + tree alignment = TREE_VALUE (TREE_VALUE (attr)); + + if (alignment == error_mark_node) + TREE_VALUE (TREE_VALUE (attr)) = NULL_TREE; + else if (alignment) + { + location_t loc2 = EXPR_LOCATION (alignment); + if (!in_parsing) + alignment = tsubst_expr (alignment, args, complain, in_decl); + alignment = fold_non_dependent_expr (alignment); + + if (TREE_CODE (alignment) != INTEGER_CST + || !INTEGRAL_TYPE_P (TREE_TYPE (alignment)) + || tree_int_cst_sgn (alignment) != 1 + || !integer_pow2p (alignment)) + { + error_at (loc2, "% clause argument needs to be positive " + "constant power of two integer expression"); + TREE_VALUE (TREE_VALUE (attr)) = NULL_TREE; + } + else + TREE_VALUE (TREE_VALUE (attr)) = alignment; + } + loc2 = allocator ? EXPR_LOCATION (allocator) : UNKNOWN_LOCATION; + if (allocator == error_mark_node) + { + allocator = TREE_PURPOSE (TREE_VALUE (attr)) = NULL_TREE; + return; + } + else + { + if (!in_parsing) + allocator = tsubst_expr (allocator, args, complain, in_decl); + allocator = fold_non_dependent_expr (allocator); + } + + if (allocator) + { + tree orig_type = TYPE_MAIN_VARIANT (TREE_TYPE (allocator)); + if (!INTEGRAL_TYPE_P (TREE_TYPE (allocator)) + || TREE_CODE (orig_type) != ENUMERAL_TYPE + || TYPE_NAME (orig_type) == NULL_TREE + || (DECL_NAME (TYPE_NAME (orig_type)) + != get_identifier ("omp_allocator_handle_t"))) + { + error_at (loc2, "% clause expression has type " + "%qT rather than %", + TREE_TYPE (allocator)); + allocator = TREE_PURPOSE (TREE_VALUE (attr)) = NULL_TREE; + } + else + TREE_PURPOSE (TREE_VALUE (attr)) = fold_non_dependent_expr (allocator); + } + if (TREE_STATIC (decl)) + { + if (allocator == NULL_TREE) + error_at (loc, "% clause required for " + "static variable %qD", decl); + else if (allocator + && (wi::to_widest (allocator) < 1 + || wi::to_widest (allocator) > 8)) + /* 8 = largest predefined memory allocator. */ + error_at (loc2, "% clause requires a predefined allocator " + "as %qD is static", decl); + else + sorry_at (loc, "%<#pragma omp allocate%> for static variables like %qD " + "not yet supported", decl); + } +} + void finish_omp_atomic (location_t loc, enum tree_code code, enum tree_code opcode, tree lhs, tree rhs, tree v, tree lhs1, tree rhs1, tree r, diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-17.c b/gcc/testsuite/c-c++-common/gomp/allocate-17.c index f75af0c2d93..2a896cc334d 100644 --- a/gcc/testsuite/c-c++-common/gomp/allocate-17.c +++ b/gcc/testsuite/c-c++-common/gomp/allocate-17.c @@ -20,7 +20,7 @@ one () #pragma omp target map(tofrom: result) firstprivate(n) { int var = 5; //, var2[n]; - #pragma omp allocate(var) align(128) allocator(omp_low_lat_mem_alloc) /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } } */ + #pragma omp allocate(var) align(128) allocator(omp_low_lat_mem_alloc) var = 7; } diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-5.c b/gcc/testsuite/c-c++-common/gomp/allocate-5.c index 2ca4786264f..b9eed152613 100644 --- a/gcc/testsuite/c-c++-common/gomp/allocate-5.c +++ b/gcc/testsuite/c-c++-common/gomp/allocate-5.c @@ -21,11 +21,10 @@ foo () omp_allocator_handle_t my_allocator = omp_default_mem_alloc; int a, b; static int c; -#pragma omp allocate (a) /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } } */ -#pragma omp allocate (b) allocator(my_allocator) /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } } */ +#pragma omp allocate (a) +#pragma omp allocate (b) allocator(my_allocator) #pragma omp allocate(c) align(32) - /* { dg-message "'allocator' clause required for static variable 'c'" "" { target c } .-1 } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ + /* { dg-message "'allocator' clause required for static variable 'c'" "" { target *-*-* } .-1 } */ } void @@ -34,14 +33,12 @@ bar () int a, a2, b; omp_allocator_handle_t my_allocator; #pragma omp allocate /* { dg-error "expected '\\(' before end of line" } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate allocator(my_allocator) /* { dg-error "expected '\\(' before 'allocator'" } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(a) foo(my_allocator) /* { dg-error "expected 'allocator'" } */ /* { dg-error "expected end of line before '\\(' token" "" { target *-*-* } .-1 } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ -#pragma omp allocate(a2) allocator(b) /* { dg-error "'allocator' clause allocator expression has type 'int' rather than 'omp_allocator_handle_t'" "todo: cp/semantics.c" { xfail c++ } } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ +#pragma omp allocate(a2) allocator(b) /* { dg-error "'allocator' clause expression has type 'int' rather than 'omp_allocator_handle_t'" } */ + /* The following error is correct albeit slightly surprising: */ + /* { dg-error "variable 'b' used in the 'allocator' clause must be declared before 'a2'" "" { target c++ } .-2 } */ } @@ -50,22 +47,16 @@ align_test () { int i1,i2,i3,i4,i5,i6; #pragma omp allocate(i1) allocator(omp_default_mem_alloc), align(32) - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i2) align ( 32 ),allocator(omp_default_mem_alloc) - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i3),allocator(omp_default_mem_alloc) align(32) - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i4) align ( 32 ) allocator(omp_default_mem_alloc) - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i5) allocator ( omp_high_bw_mem_alloc ), align ( 32 ) allocator(omp_default_mem_alloc) /* { dg-error "too many 'allocator' clauses" "" { target *-*-* } .-1 } */ /* { dg-error "expected end of line before '\\)' token" "" { target *-*-* } .-2 } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-3 } */ #pragma omp allocate(i6) align ( 32 ), align(32) allocator(omp_default_mem_alloc) /* { dg-error "too many 'align' clauses" "" { target *-*-* } .-1 } */ /* { dg-error "expected end of line before '\\)' token" "" { target *-*-* } .-2 } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-3 } */ } void @@ -73,9 +64,6 @@ align_test2 () { int i, i2,i3; #pragma omp allocate(i) align (32.0) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i2) align ( 31 ) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ #pragma omp allocate(i3) align ( -32 ) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ - /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ } diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-9.c b/gcc/testsuite/c-c++-common/gomp/allocate-9.c index 31382748be6..aaa52b359f8 100644 --- a/gcc/testsuite/c-c++-common/gomp/allocate-9.c +++ b/gcc/testsuite/c-c++-common/gomp/allocate-9.c @@ -17,7 +17,11 @@ typedef enum omp_allocator_handle_t } omp_allocator_handle_t; -static int A[5] = {1,2,3,4,5}; +static int A1[5] = {1,2,3,4,5}; +static int A2[5] = {1,2,3,4,5}; +static int A3[5] = {1,2,3,4,5}; +static int A4[5] = {1,2,3,4,5}; +static int A5[5] = {1,2,3,4,5}; int B, C, D; /* If the following fails because of added predefined allocators, please update @@ -27,72 +31,60 @@ int B, C, D; - libgomp/libgomp.texi (document the new values - multiple locations) + ensure that the memory-spaces are also up to date. */ -#pragma omp allocate(A) align(32) allocator((omp_allocator_handle_t) 9) /* { dg-error "'allocator' clause requires a predefined allocator as 'A' is static" "" { xfail c++ } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ +#pragma omp allocate(A1) align(32) allocator((omp_allocator_handle_t) 9) /* { dg-error "'allocator' clause requires a predefined allocator as 'A1' is static" } */ // typo in allocator name: -#pragma omp allocate(A) allocator(omp_low_latency_mem_alloc) +#pragma omp allocate(A2) allocator(omp_low_latency_mem_alloc) /* { dg-error "'omp_low_latency_mem_alloc' undeclared here \\(not in a function\\); did you mean 'omp_low_lat_mem_alloc'\\?" "" { target c } .-1 } */ /* { dg-error "'omp_low_latency_mem_alloc' was not declared in this scope; did you mean 'omp_low_lat_mem_alloc'\\?" "" { target c++ } .-2 } */ -/* { dg-error "'allocator' clause required for static variable 'A'" "" { target c } .-3 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-4 } */ +/* { dg-error "'allocator' clause required for static variable 'A2'" "" { target c } .-3 } */ /* align be const multiple of 2 */ -#pragma omp allocate(A) align(31) allocator(omp_default_mem_alloc) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'A' not yet supported" "" { target c } .-1 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ +#pragma omp allocate(A3) align(31) allocator(omp_default_mem_alloc) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ +/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'A3' not yet supported" "" { target *-*-* } .-1 } */ /* allocator missing (required as A is static) */ -#pragma omp allocate(A) align(32) /* { dg-error "'allocator' clause required for static variable 'A'" "" { xfail c++ } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ +#pragma omp allocate(A4) align(32) /* { dg-error "'allocator' clause required for static variable 'A4'" } */ /* "expression in the clause must be a constant expression that evaluates to one of the predefined memory allocator values -> omp_low_lat_mem_alloc" */ #pragma omp allocate(B) allocator((omp_allocator_handle_t) (omp_high_bw_mem_alloc+1)) align(32) /* OK: omp_low_lat_mem_alloc */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'B' not yet supported" "" { target c } .-1 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ +/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'B' not yet supported" "" { target *-*-* } .-1 } */ #pragma omp allocate(C) allocator((omp_allocator_handle_t) 2) /* OK: omp_large_cap_mem_alloc */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'C' not yet supported" "" { target c } .-1 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ +/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'C' not yet supported" "" { target *-*-* } .-1 } */ -#pragma omp allocate(A) align(32) allocator(omp_null_allocator) /* { dg-error "'allocator' clause requires a predefined allocator as 'A' is static" "" { xfail c++ } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ +#pragma omp allocate(A5) align(32) allocator(omp_null_allocator) /* { dg-error "'allocator' clause requires a predefined allocator as 'A5' is static" } */ -#pragma omp allocate(C) align(32) allocator(omp_large_cap_mem_alloc) /* { dg-error "'C' already appeared as list item in an 'allocate' directive" "" { xfail *-*-* } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'C' not yet supported" "" { target c } .-1 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ +#pragma omp allocate(C) align(32) allocator(omp_large_cap_mem_alloc) +/* { dg-error "'C' already appeared as list item in an 'allocate' directive" "" { target c++ } .-1 } */ +/* { dg-message "sorry, unimplemented: '#pragma omp allocate' for static variables like 'C' not yet supported" "" { target c } .-2 } */ // allocate directive in same TU int f() { - #pragma omp allocate(D) align(32) allocator(omp_large_cap_mem_alloc) /* { dg-error "'allocate' directive must be in the same scope as 'D'" "" { xfail c++ } } */ -/* { dg-note "declared here" "" { target c } 21 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ - return A[0]; + #pragma omp allocate(D) align(32) allocator(omp_large_cap_mem_alloc) /* { dg-error "'allocate' directive must be in the same scope as 'D'" } */ +/* { dg-note "declared here" "" { target *-*-* } 25 } */ + return A1[0]; } int g() { int a2=1, b2=2; #pragma omp allocate(a2) -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ - #pragma omp allocate(a2) /* { dg-error "'a2' already appeared as list item in an 'allocate' directive" "" { xfail c++ } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ + #pragma omp allocate(a2) /* { dg-error "'a2' already appeared as list item in an 'allocate' directive" } */ { int c2=3; - #pragma omp allocate(c2, b2) /* { dg-error "'allocate' directive must be in the same scope as 'b2'" "" { xfail c++ } } */ -/* { dg-note "declared here" "" { target c } .-8 } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-2 } */ + #pragma omp allocate(c2, b2) /* { dg-error "'allocate' directive must be in the same scope as 'b2'" } */ +/* { dg-note "declared here" "" { target *-*-* } .-6 } */ return c2+a2+b2; } } int h(int q) { - #pragma omp allocate(q) /* { dg-error "function parameter 'q' may not appear as list item in an 'allocate' directive" "" { xfail c++ } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ + #pragma omp allocate(q) /* { dg-error "function parameter 'q' may not appear as list item in an 'allocate' directive" } */ return q; } @@ -100,7 +92,6 @@ int k () { static int var3 = 8; - #pragma omp allocate(var3) allocator((omp_allocator_handle_t)-1L) /* { dg-error "'allocator' clause requires a predefined allocator as 'var3' is static" "" { target c } } */ -/* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */ + #pragma omp allocate(var3) allocator((omp_allocator_handle_t)-1L) /* { dg-error "'allocator' clause requires a predefined allocator as 'var3' is static" } */ return var3; } diff --git a/gcc/testsuite/g++.dg/gomp/allocate-5.C b/gcc/testsuite/g++.dg/gomp/allocate-5.C new file mode 100644 index 00000000000..39f423cf794 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/allocate-5.C @@ -0,0 +1,14 @@ +template +t +foo() +{ + t var = 5; + #pragma omp allocate(var) align(sizeof(t) + 1) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */ + return var; +} + +int +b() +{ + return foo(); /* { dg-message "required from here" } */ +} diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 02f2d0e5767..315e471e4d4 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -232,7 +232,7 @@ The OpenMP 4.5 specification is fully supported. @item Predefined memory spaces, memory allocators, allocator traits @tab Y @tab See also @ref{Memory allocation} @item Memory management routines @tab Y @tab -@item @code{allocate} directive @tab P @tab Only C and Fortran, only stack variables +@item @code{allocate} directive @tab P @tab Only for stack variables @item @code{allocate} clause @tab P @tab Initial support @item @code{use_device_addr} clause on @code{target data} @tab Y @tab @item @code{ancestor} modifier on @code{device} clause @tab Y @tab @@ -304,7 +304,7 @@ The OpenMP 4.5 specification is fully supported. @item @code{strict} modifier in the @code{grainsize} and @code{num_tasks} clauses of the @code{taskloop} construct @tab Y @tab @item @code{align} clause in @code{allocate} directive @tab P - @tab Only C and Fortran (and only stack variables) + @tab Only for stack variables @item @code{align} modifier in @code{allocate} clause @tab Y @tab @item @code{thread_limit} clause to @code{target} construct @tab Y @tab @item @code{has_device_addr} clause to @code{target} construct @tab Y @tab diff --git a/libgomp/testsuite/libgomp.c++/allocate-2.C b/libgomp/testsuite/libgomp.c++/allocate-2.C new file mode 100644 index 00000000000..f79cada1777 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/allocate-2.C @@ -0,0 +1,329 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fdump-tree-omplower" } */ + +/* For the 4 vars in omp_parallel, 4 in omp_target and 1 of 2 in each of no_alloc{,2}_func. */ +/* { dg-final { scan-tree-dump-times "__builtin_GOMP_alloc \\(" 10 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(" 10 "omplower" } } */ + +#include + + +void +check_int (int *x, int y) +{ + if (*x != y) + __builtin_abort (); +} + +void +check_ptr (int **x, int *y) +{ + if (*x != y) + __builtin_abort (); +} + + +template +t +no_alloc_func () +{ + /* There is no __builtin_GOMP_alloc / __builtin_GOMP_free as + allocator == omp_default_mem_alloc (known at compile time. */ + t no_alloc, alloc_has_align = 3; + #pragma omp allocate(no_alloc) allocator(omp_default_mem_alloc) + /* But this one is allocated because of align. */ + #pragma omp allocate(alloc_has_align) allocator(omp_default_mem_alloc) align(sizeof(t)) + no_alloc = 7; + return no_alloc + alloc_has_align; +} + +template +t +no_alloc2_func() +{ + /* There is no __builtin_GOMP_alloc / __builtin_GOMP_free as + no_alloc2 is TREE_UNUSED. But there is for is_alloc2. */ + t no_alloc2, is_alloc2; + #pragma omp allocate(no_alloc2, is_alloc2) + is_alloc2 = 7; + return is_alloc2; +} + + +template +void +omp_parallel () +{ + int n = 6; + t iii = 5, jjj[5], kkk[n]; + t *ptr = (t *) 0x1234; + #pragma omp allocate(iii, jjj, kkk, ptr) + + for (int i = 0; i < 5; i++) + jjj[i] = 3*i; + for (int i = 0; i < 6; i++) + kkk[i] = 7*i; + + #pragma omp parallel default(none) firstprivate(iii, jjj, kkk, ptr) if(0) + { + if (iii != 5) + __builtin_abort(); + iii = 7; + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + if (jjj[i] != 3*i) + __builtin_abort (); + for (int i = 0; i < 6; i++) + if (kkk[i] != 7*i) + __builtin_abort (); + for (int i = 0; i < 5; i++) + jjj[i] = 4*i; + for (int i = 0; i < 6; i++) + kkk[i] = 8*i; + for (int i = 0; i < 5; i++) + check_int (&jjj[i], 4*i); + for (int i = 0; i < 6; i++) + check_int (&kkk[i], 8*i); + if (ptr != (int *) 0x1234) + __builtin_abort (); + ptr = (int *) 0xabcd; + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); + } + if (iii != 5) + __builtin_abort (); + check_int (&iii, 5); + for (int i = 0; i < 5; i++) + { + if (jjj[i] != 3*i) + __builtin_abort (); + check_int (&jjj[i], 3*i); + } + for (int i = 0; i < 6; i++) + { + if (kkk[i] != 7*i) + __builtin_abort (); + check_int (&kkk[i], 7*i); + } + if (ptr != (int *) 0x1234) + __builtin_abort (); + check_ptr (&ptr, (int *) 0x1234); + + #pragma omp parallel default(firstprivate) if(0) + { + if (iii != 5) + __builtin_abort(); + iii = 7; + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + if (jjj[i] != 3*i) + __builtin_abort (); + for (int i = 0; i < 6; i++) + if (kkk[i] != 7*i) + __builtin_abort (); + for (int i = 0; i < 5; i++) + jjj[i] = 4*i; + for (int i = 0; i < 6; i++) + kkk[i] = 8*i; + for (int i = 0; i < 5; i++) + check_int (&jjj[i], 4*i); + for (int i = 0; i < 6; i++) + check_int (&kkk[i], 8*i); + if (ptr != (int *) 0x1234) + __builtin_abort (); + ptr = (int *) 0xabcd; + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); + } + if (iii != 5) + __builtin_abort (); + check_int (&iii, 5); + for (int i = 0; i < 5; i++) + { + if (jjj[i] != 3*i) + __builtin_abort (); + check_int (&jjj[i], 3*i); + } + for (int i = 0; i < 6; i++) + { + if (kkk[i] != 7*i) + __builtin_abort (); + check_int (&kkk[i], 7*i); + } + if (ptr != (int *) 0x1234) + __builtin_abort (); + check_ptr (&ptr, (int *) 0x1234); +} + + +template +void +omp_target () +{ + int n = 6; + t iii = 5, jjj[5], kkk[n]; + t *ptr = (int *) 0x1234; + #pragma omp allocate(iii, jjj, kkk, ptr) + + for (int i = 0; i < 5; i++) + jjj[i] = 3*i; + for (int i = 0; i < 6; i++) + kkk[i] = 7*i; + + #pragma omp target defaultmap(none) firstprivate(iii, jjj, kkk, ptr) + { + if (iii != 5) + __builtin_abort(); + iii = 7; + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + if (jjj[i] != 3*i) + __builtin_abort (); + for (int i = 0; i < 6; i++) + if (kkk[i] != 7*i) + __builtin_abort (); + for (int i = 0; i < 5; i++) + jjj[i] = 4*i; + for (int i = 0; i < 6; i++) + kkk[i] = 8*i; + for (int i = 0; i < 5; i++) + check_int (&jjj[i], 4*i); + for (int i = 0; i < 6; i++) + check_int (&kkk[i], 8*i); + if (ptr != (int *) 0x1234) + __builtin_abort (); + ptr = (int *) 0xabcd; + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); + } + if (iii != 5) + __builtin_abort (); + check_int (&iii, 5); + for (int i = 0; i < 5; i++) + { + if (jjj[i] != 3*i) + __builtin_abort (); + check_int (&jjj[i], 3*i); + } + for (int i = 0; i < 6; i++) + { + if (kkk[i] != 7*i) + __builtin_abort (); + check_int (&kkk[i], 7*i); + } + if (ptr != (int *) 0x1234) + __builtin_abort (); + check_ptr (&ptr, (int *) 0x1234); + + #pragma omp target defaultmap(firstprivate) + { + if (iii != 5) + __builtin_abort(); + iii = 7; + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + if (jjj[i] != 3*i) + __builtin_abort (); + for (int i = 0; i < 6; i++) + if (kkk[i] != 7*i) + __builtin_abort (); + for (int i = 0; i < 5; i++) + jjj[i] = 4*i; + for (int i = 0; i < 6; i++) + kkk[i] = 8*i; + for (int i = 0; i < 5; i++) + check_int (&jjj[i], 4*i); + for (int i = 0; i < 6; i++) + check_int (&kkk[i], 8*i); + if (ptr != (int *) 0x1234) + __builtin_abort (); + ptr = (int *) 0xabcd; + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); + } + if (iii != 5) + __builtin_abort (); + check_int (&iii, 5); + for (int i = 0; i < 5; i++) + { + if (jjj[i] != 3*i) + __builtin_abort (); + check_int (&jjj[i], 3*i); + } + for (int i = 0; i < 6; i++) + { + if (kkk[i] != 7*i) + __builtin_abort (); + check_int (&kkk[i], 7*i); + } + if (ptr != (int *) 0x1234) + __builtin_abort (); + check_ptr (&ptr, (int *) 0x1234); + + #pragma omp target defaultmap(tofrom) + { + if (iii != 5) + __builtin_abort(); + iii = 7; + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + if (jjj[i] != 3*i) + __builtin_abort (); + for (int i = 0; i < 6; i++) + if (kkk[i] != 7*i) + __builtin_abort (); + for (int i = 0; i < 5; i++) + jjj[i] = 4*i; + for (int i = 0; i < 6; i++) + kkk[i] = 8*i; + for (int i = 0; i < 5; i++) + check_int (&jjj[i], 4*i); + for (int i = 0; i < 6; i++) + check_int (&kkk[i], 8*i); + if (ptr != (int *) 0x1234) + __builtin_abort (); + ptr = (int *) 0xabcd; + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); + } + + if (iii != 7) + __builtin_abort (); + check_int (&iii, 7); + for (int i = 0; i < 5; i++) + { + if (jjj[i] != 4*i) + __builtin_abort (); + check_int (&jjj[i], 4*i); + } + for (int i = 0; i < 6; i++) + { + if (kkk[i] != 8*i) + __builtin_abort (); + check_int (&kkk[i], 8*i); + } + if (ptr != (int *) 0xabcd) + __builtin_abort (); + check_ptr (&ptr, (int *) 0xabcd); +} + +int +foo() +{ + return no_alloc_func() + no_alloc2_func(); +} + +int +main () +{ + omp_parallel (); + omp_target (); + if (foo() != 10 + 7) + __builtin_abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/allocate-4.c b/libgomp/testsuite/libgomp.c-c++-common/allocate-4.c similarity index 95% rename from libgomp/testsuite/libgomp.c/allocate-4.c rename to libgomp/testsuite/libgomp.c-c++-common/allocate-4.c index e81cc4093aa..706c8510b84 100644 --- a/libgomp/testsuite/libgomp.c/allocate-4.c +++ b/libgomp/testsuite/libgomp.c-c++-common/allocate-4.c @@ -1,6 +1,3 @@ -/* TODO: move to ../libgomp.c-c++-common once C++ is implemented. */ -/* NOTE: { target c } is unsupported with with the C compiler. */ - /* { dg-do run } */ /* { dg-additional-options "-fdump-tree-gimple" } */ diff --git a/libgomp/testsuite/libgomp.c/allocate-5.c b/libgomp/testsuite/libgomp.c-c++-common/allocate-5.c similarity index 96% rename from libgomp/testsuite/libgomp.c/allocate-5.c rename to libgomp/testsuite/libgomp.c-c++-common/allocate-5.c index beaf16440e1..3bbe78db840 100644 --- a/libgomp/testsuite/libgomp.c/allocate-5.c +++ b/libgomp/testsuite/libgomp.c-c++-common/allocate-5.c @@ -1,6 +1,3 @@ -/* TODO: move to ../libgomp.c-c++-common once C++ is implemented. */ -/* NOTE: { target c } is unsupported with with the C compiler. */ - /* { dg-do run } */ /* { dg-additional-options "-fdump-tree-gimple" } */ diff --git a/libgomp/testsuite/libgomp.c/allocate-6.c b/libgomp/testsuite/libgomp.c-c++-common/allocate-6.c similarity index 98% rename from libgomp/testsuite/libgomp.c/allocate-6.c rename to libgomp/testsuite/libgomp.c-c++-common/allocate-6.c index 6d7278ce571..669581b327d 100644 --- a/libgomp/testsuite/libgomp.c/allocate-6.c +++ b/libgomp/testsuite/libgomp.c-c++-common/allocate-6.c @@ -1,6 +1,3 @@ -/* TODO: move to ../libgomp.c-c++-common once C++ is implemented. */ -/* NOTE: { target c } is unsupported with with the C compiler. */ - /* { dg-do run } */ /* { dg-additional-options "-fdump-tree-omplower" } */