From patchwork Wed Dec 17 22:26:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 422389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 04B131400B7 for ; Thu, 18 Dec 2014 09:27:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=QRXzXDWR8gWP35p45503EP8XNrAkggmKBgLgWBKRT+zWBtMg1YdJj vUdpQOKCQm9hfhXWq1OsXCWDwfTLL2aVRXWjRTcu4Z+pFtO2jPh96VrRLGZQBOgc RInjc6oLq4qZEgGvsrx+KhtoZUc+Fq6Zb1q2qmXLgfx5yh2+FLFngg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=tP5SMWZb+aUvrqbaUtBJQKbk1c8=; b=yn1ZhLh0JWrMGnbMJjQI YHzWYnfZHDKox1vs035Zyx/RXc9FSYdRx6YqQ3b/CcRtRgzebr5o91OozpeF9xkn f2ostktdTmfMwZ7PxOjX7armWfE6RmsMyIsx87InneruWlBcHGazQnovFLFWhX1r aw2rvrB+yvRiJ8Ifl/Jew7A= Received: (qmail 13485 invoked by alias); 17 Dec 2014 22:27:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13474 invoked by uid 89); 17 Dec 2014 22:27:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_20, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Dec 2014 22:27:08 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Y1N3f-0004PA-LW from Thomas_Schwinge@mentor.com ; Wed, 17 Dec 2014 14:27:04 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.181.6; Wed, 17 Dec 2014 22:27:01 +0000 From: Thomas Schwinge To: Jakub Jelinek , Subject: [gomp4] Use include/gomp-constants.h more actively User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Wed, 17 Dec 2014 23:26:53 +0100 Message-ID: <87lhm5ud3m.fsf@schwinge.name> MIME-Version: 1.0 Hi! Committed to gomp-4_0-branch in r218840: commit febcd8dfdb10fa80edff0880973d1915ca2fef74 Author: tschwinge Date: Wed Dec 17 22:26:24 2014 +0000 Use include/gomp-constants.h more actively. include/ * gomp-constants.h: Update. Change all users. gcc/ * builtins.c (expand_builtin_acc_on_device): Use include/gomp-constants.h. * omp-low.c (expand_omp_target, oacc_process_reduction_data) (lower_omp_target): Likewise. * tree-core.h (enum omp_clause_map_kind): Likewise. gcc/c-family/ * c-omp.c (c_finish_oacc_wait): Use include/gomp-constants.h. gcc/c/ * c-parser.c (c_parser_oacc_clause_async): Use include/gomp-constants.h. gcc/cp/ * parser.c (cp_parser_oacc_clause_async): Use include/gomp-constants.h. gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Use include/gomp-constants.h. libgomp/ * Makefile.am: Don't add ../include/gomp-constants.h to nodist_libsubinclude_HEADERS. libgomp/ * openacc.h: Don't include "gomp-constants.h". libgomp/ * oacc-parallel.c (dump_var): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@218840 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 6 +++ gcc/builtins.c | 7 +-- gcc/c-family/ChangeLog.gomp | 4 ++ gcc/c-family/c-omp.c | 3 +- gcc/c/ChangeLog.gomp | 5 +++ gcc/c/c-parser.c | 4 +- gcc/cp/ChangeLog.gomp | 5 +++ gcc/cp/parser.c | 4 +- gcc/fortran/ChangeLog.gomp | 4 ++ gcc/fortran/openmp.c | 4 +- gcc/omp-low.c | 32 +++++++------- gcc/tree-core.h | 35 +++++++-------- include/ChangeLog.gomp | 2 + include/gomp-constants.h | 89 ++++++++++++++++++++++++--------------- libgomp/ChangeLog.gomp | 9 ++++ libgomp/Makefile.am | 2 +- libgomp/Makefile.in | 2 +- libgomp/libgomp_target.h | 10 ++--- libgomp/oacc-mem.c | 2 +- libgomp/oacc-parallel.c | 56 ++++++------------------ libgomp/openacc.f90 | 2 + libgomp/openacc.h | 15 +++---- libgomp/openacc_lib.h | 2 + libgomp/target.c | 23 +++++----- libgomp/testsuite/lib/libgomp.exp | 2 +- 25 files changed, 180 insertions(+), 149 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index f925902..1a2ccdd 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,5 +1,11 @@ 2014-12-17 Thomas Schwinge + * builtins.c (expand_builtin_acc_on_device): Use + include/gomp-constants.h. + * omp-low.c (expand_omp_target, oacc_process_reduction_data) + (lower_omp_target): Likewise. + * tree-core.h (enum omp_clause_map_kind): Likewise. + * omp-low.c (build_omp_regions_1, make_gimple_omp_edges): Simplify multi-line if conditions. diff --git gcc/builtins.c gcc/builtins.c index 9a9d935..fcf3f53 100644 --- gcc/builtins.c +++ gcc/builtins.c @@ -70,6 +70,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "tree-chkp.h" #include "rtl-chkp.h" +#include "gomp-constants.h" static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t)); @@ -5903,11 +5904,11 @@ expand_builtin_acc_on_device (tree exp, rtx target ATTRIBUTE_UNUSED) /* Build: (arg == v1 || arg == v2) ? 1 : 0. */ #ifdef ACCEL_COMPILER - v1 = build_int_cst (TREE_TYPE (arg), /* TODO: acc_device_not_host */ 3); + v1 = build_int_cst (TREE_TYPE (arg), GOMP_DEVICE_NOT_HOST); v2 = build_int_cst (TREE_TYPE (arg), ACCEL_COMPILER_acc_device); #else - v1 = build_int_cst (TREE_TYPE (arg), /* TODO: acc_device_none */ 0); - v2 = build_int_cst (TREE_TYPE (arg), /* TODO: acc_device_host */ 2); + v1 = build_int_cst (TREE_TYPE (arg), GOMP_DEVICE_NONE); + v2 = build_int_cst (TREE_TYPE (arg), GOMP_DEVICE_HOST); #endif v1 = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg, v1); diff --git gcc/c-family/ChangeLog.gomp gcc/c-family/ChangeLog.gomp index 5f3b641..2b6cb57 100644 --- gcc/c-family/ChangeLog.gomp +++ gcc/c-family/ChangeLog.gomp @@ -1,3 +1,7 @@ +2014-12-17 Thomas Schwinge + + * c-omp.c (c_finish_oacc_wait): Use include/gomp-constants.h. + 2014-11-05 James Norris * c-pragma.c (oacc_pragmas): Add "cache". diff --git gcc/c-family/c-omp.c gcc/c-family/c-omp.c index 9bbfe0e..5a42042 100644 --- gcc/c-family/c-omp.c +++ gcc/c-family/c-omp.c @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-expr.h" #include "langhooks.h" #include "omp-low.h" +#include "gomp-constants.h" /* Complete a #pragma oacc wait construct. LOC is the location of @@ -48,7 +49,7 @@ c_finish_oacc_wait (location_t loc, tree parms, tree clauses) if (find_omp_clause (clauses, OMP_CLAUSE_ASYNC)) t = OMP_CLAUSE_ASYNC_EXPR (clauses); else - t = build_int_cst (integer_type_node, -2); /* TODO: XXX FIX -2. */ + t = build_int_cst (integer_type_node, GOMP_ASYNC_SYNC); args->quick_push (t); args->quick_push (build_int_cst (integer_type_node, nparms)); diff --git gcc/c/ChangeLog.gomp gcc/c/ChangeLog.gomp index a223a17..b710f47 100644 --- gcc/c/ChangeLog.gomp +++ gcc/c/ChangeLog.gomp @@ -1,3 +1,8 @@ +2014-12-17 Thomas Schwinge + + * c-parser.c (c_parser_oacc_clause_async): Use + include/gomp-constants.h. + 2014-11-05 Thomas Schwinge * c-parser.c (c_parser_omp_clause_name) <"host">: Return diff --git gcc/c/c-parser.c gcc/c/c-parser.c index 7703096..741f21a 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -71,6 +71,7 @@ along with GCC; see the file COPYING3. If not see #include "plugin.h" #include "omp-low.h" #include "builtins.h" +#include "gomp-constants.h" /* Initialization routine for this file. */ @@ -10682,8 +10683,7 @@ c_parser_oacc_clause_async (c_parser *parser, tree list) tree c, t; location_t loc = c_parser_peek_token (parser)->location; - /* TODO XXX: FIX -1 (acc_async_noval). */ - t = build_int_cst (integer_type_node, -1); + t = build_int_cst (integer_type_node, GOMP_ASYNC_NOVAL); if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN) { diff --git gcc/cp/ChangeLog.gomp gcc/cp/ChangeLog.gomp index f5d400f..4490186 100644 --- gcc/cp/ChangeLog.gomp +++ gcc/cp/ChangeLog.gomp @@ -1,3 +1,8 @@ +2014-12-17 Thomas Schwinge + + * parser.c (cp_parser_oacc_clause_async): Use + include/gomp-constants.h. + 2014-11-05 Thomas Schwinge * parser.c (cp_parser_oacc_data_clause): Group diff --git gcc/cp/parser.c gcc/cp/parser.c index 176eec7..99fd5b2 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see #include "parser.h" #include "type-utils.h" #include "omp-low.h" +#include "gomp-constants.h" /* The lexer. */ @@ -29035,8 +29036,7 @@ cp_parser_oacc_clause_async (cp_parser *parser, tree list) tree c, t; location_t loc = cp_lexer_peek_token (parser->lexer)->location; - /* TODO XXX: FIX -1 (acc_async_noval). */ - t = build_int_cst (integer_type_node, -1); + t = build_int_cst (integer_type_node, GOMP_ASYNC_NOVAL); if (cp_lexer_peek_token (parser->lexer)->type == CPP_OPEN_PAREN) { diff --git gcc/fortran/ChangeLog.gomp gcc/fortran/ChangeLog.gomp index 2bc5820..385e348 100644 --- gcc/fortran/ChangeLog.gomp +++ gcc/fortran/ChangeLog.gomp @@ -1,3 +1,7 @@ +2014-12-17 Thomas Schwinge + + * openmp.c (gfc_match_omp_clauses): Use include/gomp-constants.h. + 2014-11-20 Cesar Philippidis * openmp.c (resolve_oacc_cache): Mark the code parameter as diff --git gcc/fortran/openmp.c gcc/fortran/openmp.c index c847003..46aeb60 100644 --- gcc/fortran/openmp.c +++ gcc/fortran/openmp.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "parse.h" #include "hash-set.h" #include "diagnostic.h" +#include "gomp-constants.h" /* Match an end of OpenMP directive. End of OpenMP directive is optional whitespace, followed by '\n' or comment '!'. */ @@ -502,8 +503,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask, c->async_expr = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind, &gfc_current_locus); - /* TODO XXX: FIX -1 (acc_async_noval). */ - mpz_set_si (c->async_expr->value.integer, -1); + mpz_set_si (c->async_expr->value.integer, GOMP_ASYNC_NOVAL); } continue; } diff --git gcc/omp-low.c gcc/omp-low.c index fd117dc..e5c6802 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -89,6 +89,7 @@ along with GCC; see the file COPYING3. If not see #include "cilk.h" #include "context.h" #include "lto-section-names.h" +#include "gomp-constants.h" /* Lowering of OpenMP parallel and workshare constructs proceeds in two @@ -9032,10 +9033,10 @@ expand_omp_target (struct omp_region *region) clauses = gimple_omp_target_clauses (entry_stmt); - /* By default, the value of DEVICE is -1 (let runtime library choose) - and there is no conditional. */ + /* By default, the value of DEVICE is GOMP_DEVICE_ICV (let runtime + library choose) and there is no conditional. */ cond = NULL_TREE; - device = build_int_cst (integer_type_node, -1); + device = build_int_cst (integer_type_node, GOMP_DEVICE_ICV); c = find_omp_clause (clauses, OMP_CLAUSE_IF); if (c) @@ -9060,7 +9061,7 @@ expand_omp_target (struct omp_region *region) device = fold_convert_loc (clause_loc, integer_type_node, device); /* If we found the clause 'if (cond)', build - (cond ? device : -2). */ + (cond ? device : GOMP_DEVICE_HOST_FALLBACK). */ if (cond) { cond = gimple_boolify (cond); @@ -9097,7 +9098,8 @@ expand_omp_target (struct omp_region *region) gsi = gsi_start_bb (else_bb); stmt = gimple_build_assign (tmp_var, - build_int_cst (integer_type_node, -2)); + build_int_cst (integer_type_node, + GOMP_DEVICE_HOST_FALLBACK)); gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING); make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE); @@ -9188,10 +9190,10 @@ expand_omp_target (struct omp_region *region) int t_wait_idx; /* Default values for t_async. */ - /* TODO: XXX FIX -2. */ t_async = fold_convert_loc (gimple_location (entry_stmt), integer_type_node, - build_int_cst (integer_type_node, -2)); + build_int_cst (integer_type_node, + GOMP_ASYNC_SYNC)); /* ..., but if present, use the value specified by the respective clause, making sure that is of the correct type. */ c = find_omp_clause (clauses, OMP_CLAUSE_ASYNC); @@ -9937,8 +9939,9 @@ oacc_process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp, /* Set nthreads = 1 for ACC_DEVICE_TYPE=host. */ acc_device_host = create_tmp_var (integer_type_node, ".acc_device_host"); - gimplify_assign (acc_device_host, build_int_cst (integer_type_node, - 2), + gimplify_assign (acc_device_host, + build_int_cst (integer_type_node, + GOMP_DEVICE_HOST), in_stmt_seqp); enter = create_artificial_label (UNKNOWN_LOCATION); @@ -9954,8 +9957,9 @@ oacc_process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp, gimple_seq_add_stmt (in_stmt_seqp, gimple_build_label (exit)); /* Also, set nthreads = 1 for ACC_DEVICE_TYPE=host_nonshm. */ - gimplify_assign (acc_device_host, build_int_cst (integer_type_node, - 3), + gimplify_assign (acc_device_host, + build_int_cst (integer_type_node, + GOMP_DEVICE_HOST_NONSHM), in_stmt_seqp); enter = create_artificial_label (UNKNOWN_LOCATION); @@ -11476,16 +11480,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) mark_addressable (avar); enum omp_clause_map_kind map_kind = OMP_CLAUSE_MAP_KIND (c); - if ((!(map_kind & OMP_CLAUSE_MAP_SPECIAL) - && (map_kind & OMP_CLAUSE_MAP_TO)) + if (GOMP_MAP_COPY_TO_P (map_kind) || map_kind == OMP_CLAUSE_MAP_POINTER || map_kind == OMP_CLAUSE_MAP_TO_PSET || map_kind == OMP_CLAUSE_MAP_FORCE_DEVICEPTR) gimplify_assign (avar, var, &ilist); avar = build_fold_addr_expr (avar); gimplify_assign (x, avar, &ilist); - if (((!(map_kind & OMP_CLAUSE_MAP_SPECIAL) - && (map_kind & OMP_CLAUSE_MAP_FROM)) + if ((GOMP_MAP_COPY_FROM_P (map_kind) || map_kind == OMP_CLAUSE_MAP_FORCE_DEVICEPTR) && !TYPE_READONLY (TREE_TYPE (var))) { diff --git gcc/tree-core.h gcc/tree-core.h index 743bc0d..fc61b88 100644 --- gcc/tree-core.h +++ gcc/tree-core.h @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "alias.h" #include "flags.h" #include "symtab.h" +#include "gomp-constants.h" /* This file contains all the data structures that define the 'tree' type. There are no accessor macros nor functions in this file. Only the @@ -1236,45 +1237,41 @@ enum omp_clause_depend_kind enum omp_clause_map_kind { /* If not already present, allocate. */ - OMP_CLAUSE_MAP_ALLOC = 0, + OMP_CLAUSE_MAP_ALLOC = GOMP_MAP_ALLOC, /* ..., and copy to device. */ - OMP_CLAUSE_MAP_TO = 1 << 0, + OMP_CLAUSE_MAP_TO = GOMP_MAP_TO, /* ..., and copy from device. */ - OMP_CLAUSE_MAP_FROM = 1 << 1, + OMP_CLAUSE_MAP_FROM = GOMP_MAP_FROM, /* ..., and copy to and from device. */ - OMP_CLAUSE_MAP_TOFROM = OMP_CLAUSE_MAP_TO | OMP_CLAUSE_MAP_FROM, - /* Special map kinds. */ - OMP_CLAUSE_MAP_SPECIAL = 1 << 2, + OMP_CLAUSE_MAP_TOFROM = GOMP_MAP_TOFROM, /* The following kind is an internal only map kind, used for pointer based array sections. OMP_CLAUSE_SIZE for these is not the pointer size, which is implicitly POINTER_SIZE_UNITS, but the bias. */ - OMP_CLAUSE_MAP_POINTER = OMP_CLAUSE_MAP_SPECIAL, + OMP_CLAUSE_MAP_POINTER = GOMP_MAP_POINTER, /* Also internal, behaves like OMP_CLAUS_MAP_TO, but additionally any OMP_CLAUSE_MAP_POINTER records consecutive after it which have addresses falling into that range will not be ignored if OMP_CLAUSE_MAP_TO_PSET wasn't mapped already. */ - OMP_CLAUSE_MAP_TO_PSET, + OMP_CLAUSE_MAP_TO_PSET = GOMP_MAP_TO_PSET, /* The following are only valid for OpenACC. */ - /* Flag to force a specific behavior (or else, a run-time error). */ - OMP_CLAUSE_MAP_FORCE = 1 << 3, /* Allocate. */ - OMP_CLAUSE_MAP_FORCE_ALLOC = OMP_CLAUSE_MAP_FORCE | OMP_CLAUSE_MAP_ALLOC, + OMP_CLAUSE_MAP_FORCE_ALLOC = GOMP_MAP_FORCE_ALLOC, /* ..., and copy to device. */ - OMP_CLAUSE_MAP_FORCE_TO = OMP_CLAUSE_MAP_FORCE | OMP_CLAUSE_MAP_TO, + OMP_CLAUSE_MAP_FORCE_TO = GOMP_MAP_FORCE_TO, /* ..., and copy from device. */ - OMP_CLAUSE_MAP_FORCE_FROM = OMP_CLAUSE_MAP_FORCE | OMP_CLAUSE_MAP_FROM, + OMP_CLAUSE_MAP_FORCE_FROM = GOMP_MAP_FORCE_FROM, /* ..., and copy to and from device. */ - OMP_CLAUSE_MAP_FORCE_TOFROM = OMP_CLAUSE_MAP_FORCE | OMP_CLAUSE_MAP_TOFROM, + OMP_CLAUSE_MAP_FORCE_TOFROM = GOMP_MAP_FORCE_TOFROM, /* Must already be present. */ - OMP_CLAUSE_MAP_FORCE_PRESENT = OMP_CLAUSE_MAP_FORCE | OMP_CLAUSE_MAP_SPECIAL, + OMP_CLAUSE_MAP_FORCE_PRESENT = GOMP_MAP_FORCE_PRESENT, /* Deallocate a mapping, without copying from device. */ - OMP_CLAUSE_MAP_FORCE_DEALLOC, + OMP_CLAUSE_MAP_FORCE_DEALLOC = GOMP_MAP_FORCE_DEALLOC, /* Is a device pointer. OMP_CLAUSE_SIZE for these is unused; is implicitly - POINTER_SIZE / BITS_PER_UNIT. */ - OMP_CLAUSE_MAP_FORCE_DEVICEPTR, + POINTER_SIZE_UNITS. */ + OMP_CLAUSE_MAP_FORCE_DEVICEPTR = GOMP_MAP_FORCE_DEVICEPTR, /* End marker. */ - OMP_CLAUSE_MAP_LAST + OMP_CLAUSE_MAP_LAST = GOMP_MAP_VALUE_LIMIT }; enum omp_clause_proc_bind_kind diff --git include/ChangeLog.gomp include/ChangeLog.gomp index 6baa7a8..c65a210 100644 --- include/ChangeLog.gomp +++ include/ChangeLog.gomp @@ -1,5 +1,7 @@ 2014-12-17 Thomas Schwinge + * gomp-constants.h: Update. Change all users. + * gomp-constants.h: Don't define GOMP_MAP_FORCE_PRIVATE and GOMP_MAP_FORCE_FIRSTPRIVATE. Change all users. diff --git include/gomp-constants.h include/gomp-constants.h index e042f9e..b5f8d88 100644 --- include/gomp-constants.h +++ include/gomp-constants.h @@ -1,4 +1,7 @@ -/* Copyright (C) 2014 Free Software Foundation, Inc. +/* Communication between GCC and libgomp. + + Copyright (C) 2014 Free Software Foundation, Inc. + Contributed by Mentor Embedded. This file is part of the GNU Offloading and Multi Processing Library @@ -26,46 +29,66 @@ #ifndef GOMP_CONSTANTS_H #define GOMP_CONSTANTS_H 1 -/* Enumerated variable mapping types used to communicate between GCC and - libgomp. These values are used for both OpenMP and OpenACC. */ +/* Memory mapping types. */ -#define _GOMP_MAP_FLAG_SPECIAL (1 << 2) -#define _GOMP_MAP_FLAG_FORCE (1 << 3) +/* One byte. */ +#define GOMP_MAP_VALUE_LIMIT (1 << 8) -#define GOMP_MAP_ALLOC 0x00 -#define GOMP_MAP_ALLOC_TO 0x01 -#define GOMP_MAP_ALLOC_FROM 0x02 -#define GOMP_MAP_ALLOC_TOFROM 0x03 -#define GOMP_MAP_POINTER 0x04 -#define GOMP_MAP_TO_PSET 0x05 -#define GOMP_MAP_FORCE_ALLOC 0x08 -#define GOMP_MAP_FORCE_TO 0x09 -#define GOMP_MAP_FORCE_FROM 0x0a -#define GOMP_MAP_FORCE_TOFROM 0x0b -#define GOMP_MAP_FORCE_PRESENT 0x0c -#define GOMP_MAP_FORCE_DEALLOC 0x0d -#define GOMP_MAP_FORCE_DEVICEPTR 0x0e +#define GOMP_MAP_FLAG_TO (1 << 0) +#define GOMP_MAP_FLAG_FROM (1 << 1) +/* Special map kinds, enumerated starting here. */ +#define GOMP_MAP_FLAG_SPECIAL_0 (1 << 2) +#define GOMP_MAP_FLAG_SPECIAL_1 (1 << 3) +#define GOMP_MAP_FLAG_SPECIAL (GOMP_MAP_FLAG_SPECIAL_1 \ + | GOMP_MAP_FLAG_SPECIAL_0) +/* Flag to force a specific behavior (or else, trigger a run-time error). */ +#define GOMP_MAP_FLAG_FORCE (1 << 7) -#define GOMP_MAP_COPYTO_P(X) \ - ((X) == GOMP_MAP_ALLOC_TO || (X) == GOMP_MAP_FORCE_TO) +#define GOMP_MAP_ALLOC 0 +#define GOMP_MAP_TO (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_TO) +#define GOMP_MAP_FROM (GOMP_MAP_ALLOC | GOMP_MAP_FLAG_FROM) +#define GOMP_MAP_TOFROM (GOMP_MAP_TO | GOMP_MAP_FROM) +#define GOMP_MAP_POINTER (GOMP_MAP_FLAG_SPECIAL_0 | 0) +#define GOMP_MAP_TO_PSET (GOMP_MAP_FLAG_SPECIAL_0 | 1) +#define GOMP_MAP_FORCE_PRESENT (GOMP_MAP_FLAG_SPECIAL_0 | 2) +#define GOMP_MAP_FORCE_DEALLOC (GOMP_MAP_FLAG_SPECIAL_0 | 3) +#define GOMP_MAP_FORCE_DEVICEPTR (GOMP_MAP_FLAG_SPECIAL_1 | 0) +#define GOMP_MAP_FORCE_ALLOC (GOMP_MAP_FLAG_FORCE | GOMP_MAP_ALLOC) +#define GOMP_MAP_FORCE_TO (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TO) +#define GOMP_MAP_FORCE_FROM (GOMP_MAP_FLAG_FORCE | GOMP_MAP_FROM) +#define GOMP_MAP_FORCE_TOFROM (GOMP_MAP_FLAG_FORCE | GOMP_MAP_TOFROM) -#define GOMP_MAP_COPYFROM_P(X) \ - ((X) == GOMP_MAP_ALLOC_FROM || (X) == GOMP_MAP_FORCE_FROM) +#define GOMP_MAP_COPY_TO_P(X) \ + (!((X) & GOMP_MAP_FLAG_SPECIAL) \ + && ((X) & GOMP_MAP_FLAG_TO)) -#define GOMP_MAP_TOFROM_P(X) \ - ((X) == GOMP_MAP_ALLOC_TOFROM || (X) == GOMP_MAP_FORCE_TOFROM) +#define GOMP_MAP_COPY_FROM_P(X) \ + (!((X) & GOMP_MAP_FLAG_SPECIAL) \ + && ((X) & GOMP_MAP_FLAG_FROM)) #define GOMP_MAP_POINTER_P(X) \ ((X) == GOMP_MAP_POINTER) -#define GOMP_IF_CLAUSE_FALSE -2 - -/* Canonical list of target type codes for OpenMP/OpenACC. */ -#define GOMP_TARGET_NONE 0 -#define GOMP_TARGET_HOST 2 -#define GOMP_TARGET_HOST_NONSHM 3 -#define GOMP_TARGET_NOT_HOST 4 -#define GOMP_TARGET_NVIDIA_PTX 5 -#define GOMP_TARGET_INTEL_MIC 6 + +/* Asynchronous behavior. Keep in sync with + libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_async_t. */ + +#define GOMP_ASYNC_NOVAL -1 +#define GOMP_ASYNC_SYNC -2 + + +/* Device codes. Keep in sync with + libgomp/{openacc.h,openacc.f90,openacc_lib.h}:acc_device_t as well as + libgomp/libgomp_target.h. */ +#define GOMP_DEVICE_NONE 0 +#define GOMP_DEVICE_DEFAULT 1 +#define GOMP_DEVICE_HOST 2 +#define GOMP_DEVICE_HOST_NONSHM 3 +#define GOMP_DEVICE_NOT_HOST 4 +#define GOMP_DEVICE_NVIDIA_PTX 5 +#define GOMP_DEVICE_INTEL_MIC 6 + +#define GOMP_DEVICE_ICV -1 +#define GOMP_DEVICE_HOST_FALLBACK -2 #endif diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index ab668a5..dd37326 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,4 +1,13 @@ 2014-12-17 Thomas Schwinge + + * Makefile.am: Don't add ../include/gomp-constants.h to + nodist_libsubinclude_HEADERS. + + * openacc.h: Don't include "gomp-constants.h". + + * oacc-parallel.c (dump_var): Remove. + +2014-12-17 Thomas Schwinge Julian Brown David Malcolm diff --git libgomp/Makefile.am libgomp/Makefile.am index 01bb1ec..4471fab 100644 --- libgomp/Makefile.am +++ libgomp/Makefile.am @@ -72,7 +72,7 @@ libgomp_la_SOURCES += openacc.f90 endif nodist_noinst_HEADERS = libgomp_f.h -nodist_libsubinclude_HEADERS = omp.h openacc.h ../include/gomp-constants.h +nodist_libsubinclude_HEADERS = omp.h openacc.h if USE_FORTRAN nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \ openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod diff --git libgomp/Makefile.in libgomp/Makefile.in index 2447498..1457aeb 100644 --- libgomp/Makefile.in +++ libgomp/Makefile.in @@ -417,7 +417,7 @@ libgomp_plugin_host_nonshm_la_LDFLAGS = \ libgomp_plugin_host_nonshm_la_LIBTOOLFLAGS = --tag=disable-static nodist_noinst_HEADERS = libgomp_f.h -nodist_libsubinclude_HEADERS = omp.h openacc.h ../include/gomp-constants.h +nodist_libsubinclude_HEADERS = omp.h openacc.h @USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \ @USE_FORTRAN_TRUE@ openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod diff --git libgomp/libgomp_target.h libgomp/libgomp_target.h index 6da9be8..4d658cc 100644 --- libgomp/libgomp_target.h +++ libgomp/libgomp_target.h @@ -27,13 +27,13 @@ #include "gomp-constants.h" -/* Type of offload target device. Keep in sync with openacc.h:acc_device_t. */ +/* Type of offload target device. Keep in sync with include/gomp-constants.h. */ enum offload_target_type { - OFFLOAD_TARGET_TYPE_HOST = GOMP_TARGET_HOST, - OFFLOAD_TARGET_TYPE_HOST_NONSHM = GOMP_TARGET_HOST_NONSHM, - OFFLOAD_TARGET_TYPE_NVIDIA_PTX = GOMP_TARGET_NVIDIA_PTX, - OFFLOAD_TARGET_TYPE_INTEL_MIC = GOMP_TARGET_INTEL_MIC + OFFLOAD_TARGET_TYPE_HOST = 2, + OFFLOAD_TARGET_TYPE_HOST_NONSHM = 3, + OFFLOAD_TARGET_TYPE_NVIDIA_PTX = 5, + OFFLOAD_TARGET_TYPE_INTEL_MIC = 6 }; /* Auxiliary struct, used for transferring a host-target address range mapping diff --git libgomp/oacc-mem.c libgomp/oacc-mem.c index cfb63f5..7453020 100644 --- libgomp/oacc-mem.c +++ libgomp/oacc-mem.c @@ -385,7 +385,7 @@ present_create_copy (unsigned f, void *h, size_t s) void *hostaddrs = h; if (f & PCC_Copy) - kinds = GOMP_MAP_ALLOC_TO; + kinds = GOMP_MAP_TO; else kinds = GOMP_MAP_ALLOC; diff --git libgomp/oacc-parallel.c libgomp/oacc-parallel.c index 3726794..abe6aa9 100644 --- libgomp/oacc-parallel.c +++ libgomp/oacc-parallel.c @@ -38,36 +38,6 @@ #include #include -static void -dump_var (char *s, size_t idx, void *hostaddr, size_t size, unsigned char kind) -{ - gomp_debug (0, " %2zi: %3s 0x%.2x -", idx, s, kind & 0xff); - - switch (kind & 0xff) - { - case 0x00: gomp_debug (0, " ALLOC "); break; - case 0x01: gomp_debug (0, " ALLOC TO "); break; - case 0x02: gomp_debug (0, " ALLOC FROM "); break; - case 0x03: gomp_debug (0, " ALLOC TOFROM "); break; - case 0x04: gomp_debug (0, " POINTER "); break; - case 0x05: gomp_debug (0, " TO_PSET "); break; - - case 0x08: gomp_debug (0, " FORCE_ALLOC "); break; - case 0x09: gomp_debug (0, " FORCE_TO "); break; - case 0x0a: gomp_debug (0, " FORCE_FROM "); break; - case 0x0b: gomp_debug (0, " FORCE_TOFROM "); break; - case 0x0c: gomp_debug (0, " FORCE_PRESENT "); break; - case 0x0d: gomp_debug (0, " FORCE_DEALLOC "); break; - case 0x0e: gomp_debug (0, " FORCE_DEVICEPTR "); break; - - case (unsigned char) -1: gomp_debug (0, " DUMMY "); break; - default: gomp_debug (0, "UGH! 0x%x\n", kind); - } - - gomp_debug (0, "- %d - %4d/0x%04x ", 1 << (kind >> 8), (int) size, (int) size); - gomp_debug (0, "- %p\n", hostaddr); -} - static int find_pset (int pos, size_t mapnum, unsigned short *kinds) { @@ -90,7 +60,7 @@ select_acc_device (int device_type) { goacc_lazy_initialize (); - if (device_type == GOMP_IF_CLAUSE_FALSE) + if (device_type == GOMP_DEVICE_HOST_FALLBACK) return; if (device_type == acc_device_none) @@ -114,7 +84,7 @@ GOACC_parallel (int device, void (*fn) (void *), const void *offload_table, int num_gangs, int num_workers, int vector_length, int async, int num_waits, ...) { - bool if_clause_condition_value = device != GOMP_IF_CLAUSE_FALSE; + bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK; va_list ap; struct goacc_thread *thr; struct gomp_device_descr *acc_dev; @@ -139,7 +109,7 @@ GOACC_parallel (int device, void (*fn) (void *), const void *offload_table, /* Host fallback if "if" clause is false or if the current device is set to the host. */ - if (!if_clause_condition_value) + if (host_fallback) { goacc_save_and_set_bind (acc_device_host); fn (hostaddrs); @@ -206,7 +176,7 @@ void GOACC_data_start (int device, const void *offload_table, size_t mapnum, void **hostaddrs, size_t *sizes, unsigned short *kinds) { - bool if_clause_condition_value = device != GOMP_IF_CLAUSE_FALSE; + bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK; struct target_mem_desc *tgt; gomp_debug (0, "%s: mapnum=%zd, hostaddrs=%p, sizes=%p, kinds=%p\n", @@ -219,7 +189,7 @@ GOACC_data_start (int device, const void *offload_table, size_t mapnum, /* Host fallback or 'do nothing'. */ if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) - || !if_clause_condition_value) + || host_fallback) { tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false); tgt->prev = thr->mapped_data; @@ -255,7 +225,7 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum, { struct goacc_thread *thr; struct gomp_device_descr *acc_dev; - bool if_clause_condition_value = device != GOMP_IF_CLAUSE_FALSE; + bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK; bool data_enter = false; size_t i; @@ -265,7 +235,7 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum, acc_dev = thr->dev; if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) - || !if_clause_condition_value) + || host_fallback) return; if (num_waits > 0) @@ -289,14 +259,16 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum, if (kind == GOMP_MAP_POINTER || kind == GOMP_MAP_TO_PSET) continue; - if (kind == GOMP_MAP_FORCE_ALLOC || kind == GOMP_MAP_FORCE_PRESENT + if (kind == GOMP_MAP_FORCE_ALLOC + || kind == GOMP_MAP_FORCE_PRESENT || kind == GOMP_MAP_FORCE_TO) { data_enter = true; break; } - if (kind == GOMP_MAP_FORCE_DEALLOC || kind == GOMP_MAP_FORCE_FROM) + if (kind == GOMP_MAP_FORCE_DEALLOC + || kind == GOMP_MAP_FORCE_FROM) break; gomp_fatal (">>>> GOACC_enter_exit_data UNHANDLED kind 0x%.2x", @@ -466,7 +438,7 @@ GOACC_update (int device, const void *offload_table, size_t mapnum, void **hostaddrs, size_t *sizes, unsigned short *kinds, int async, int num_waits, ...) { - bool if_clause_condition_value = device != GOMP_IF_CLAUSE_FALSE; + bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK; size_t i; select_acc_device (device); @@ -475,7 +447,7 @@ GOACC_update (int device, const void *offload_table, size_t mapnum, struct gomp_device_descr *acc_dev = thr->dev; if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) - || !if_clause_condition_value) + || host_fallback) return; if (num_waits > 0) @@ -495,8 +467,6 @@ GOACC_update (int device, const void *offload_table, size_t mapnum, { unsigned char kind = kinds[i] & 0xff; - dump_var ("UPD", i, hostaddrs[i], sizes[i], kinds[i]); - switch (kind) { case GOMP_MAP_POINTER: diff --git libgomp/openacc.f90 libgomp/openacc.f90 index c2952e7..7d4710f 100644 --- libgomp/openacc.f90 +++ libgomp/openacc.f90 @@ -39,6 +39,7 @@ module openacc_kinds public :: acc_device_none, acc_device_default, acc_device_host public :: acc_device_not_host, acc_device_nvidia + ! Keep in sync with include/gomp-constants.h. integer (acc_device_kind), parameter :: acc_device_none = 0 integer (acc_device_kind), parameter :: acc_device_default = 1 integer (acc_device_kind), parameter :: acc_device_host = 2 @@ -52,6 +53,7 @@ module openacc_kinds public :: acc_async_noval, acc_async_sync + ! Keep in sync with include/gomp-constants.h. integer (acc_handle_kind), parameter :: acc_async_noval = -1 integer (acc_handle_kind), parameter :: acc_async_sync = -2 diff --git libgomp/openacc.h libgomp/openacc.h index 4ac1365..dd8c2b8 100644 --- libgomp/openacc.h +++ libgomp/openacc.h @@ -29,8 +29,6 @@ #ifndef _OPENACC_H #define _OPENACC_H 1 -#include "gomp-constants.h" - /* The OpenACC std is silent on whether or not including openacc.h might or must not include other header files. We chose to include some. */ @@ -51,18 +49,19 @@ extern "C" { /* Types */ typedef enum acc_device_t { + /* Keep in sync with include/gomp-constants.h. */ acc_device_none = 0, - acc_device_default, /* This has to be a distinct value, as no - return value can match it. */ - acc_device_host = GOMP_TARGET_HOST, - acc_device_host_nonshm = GOMP_TARGET_HOST_NONSHM, - acc_device_not_host, - acc_device_nvidia = GOMP_TARGET_NVIDIA_PTX, + acc_device_default = 1, + acc_device_host = 2, + acc_device_host_nonshm = 3, + acc_device_not_host = 4, + acc_device_nvidia = 5, _ACC_device_hwm } acc_device_t; typedef enum acc_async_t { + /* Keep in sync with include/gomp-constants.h. */ acc_async_noval = -1, acc_async_sync = -2 } acc_async_t; diff --git libgomp/openacc_lib.h libgomp/openacc_lib.h index 1f630c9..4924e24 100644 --- libgomp/openacc_lib.h +++ libgomp/openacc_lib.h @@ -34,6 +34,7 @@ integer, parameter :: acc_device_kind = 4 +! Keep in sync with include/gomp-constants.h. integer (acc_device_kind), parameter :: acc_device_none = 0 integer (acc_device_kind), parameter :: acc_device_default = 1 integer (acc_device_kind), parameter :: acc_device_host = 2 @@ -43,6 +44,7 @@ integer, parameter :: acc_handle_kind = 4 +! Keep in sync with include/gomp-constants.h. integer (acc_handle_kind), parameter :: acc_async_noval = -1 integer (acc_handle_kind), parameter :: acc_async_sync = -2 diff --git libgomp/target.c libgomp/target.c index c92b43a..fc94e8f 100644 --- libgomp/target.c +++ libgomp/target.c @@ -100,7 +100,7 @@ gomp_get_num_devices (void) static struct gomp_device_descr * resolve_device (int device_id) { - if (device_id == -1) + if (device_id == GOMP_DEVICE_ICV) { struct gomp_task_icv *icv = gomp_icv (false); device_id = icv->default_device_var; @@ -120,8 +120,7 @@ static inline void gomp_map_vars_existing (splay_tree_key oldn, splay_tree_key newn, unsigned char kind) { - if ((!(kind & _GOMP_MAP_FLAG_SPECIAL) - && (kind & _GOMP_MAP_FLAG_FORCE)) + if ((kind & GOMP_MAP_FLAG_FORCE) || oldn->host_start > newn->host_start || oldn->host_end < newn->host_end) gomp_fatal ("Trying to map into device [%p..%p) object when " @@ -339,8 +338,7 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, k->tgt = tgt; k->tgt_offset = tgt_size; tgt_size += k->host_end - k->host_start; - k->copy_from = GOMP_MAP_COPYFROM_P (kind & typemask) - || GOMP_MAP_TOFROM_P (kind & typemask); + k->copy_from = GOMP_MAP_COPY_FROM_P (kind & typemask); k->refcount = 1; k->async_refcount = 0; tgt->refcount++; @@ -352,12 +350,12 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, switch (kind & typemask) { case GOMP_MAP_ALLOC: - case GOMP_MAP_ALLOC_FROM: + case GOMP_MAP_FROM: case GOMP_MAP_FORCE_ALLOC: case GOMP_MAP_FORCE_FROM: break; - case GOMP_MAP_ALLOC_TO: - case GOMP_MAP_ALLOC_TOFROM: + case GOMP_MAP_TO: + case GOMP_MAP_TOFROM: case GOMP_MAP_FORCE_TO: case GOMP_MAP_FORCE_TOFROM: /* Copy from host to device memory. */ @@ -692,7 +690,7 @@ gomp_update (struct gomp_device_descr *devicep, struct gomp_memory_mapping *mm, (void *) cur_node.host_end, (void *) n->host_start, (void *) n->host_end); - if (GOMP_MAP_COPYTO_P (kind & typemask)) + if (GOMP_MAP_COPY_TO_P (kind & typemask)) /* Copy from host to device memory. */ devicep->host2dev_func (devicep->target_id, (void *) (n->tgt->tgt_start @@ -701,7 +699,7 @@ gomp_update (struct gomp_device_descr *devicep, struct gomp_memory_mapping *mm, - n->host_start), (void *) cur_node.host_start, cur_node.host_end - cur_node.host_start); - else if (GOMP_MAP_COPYFROM_P (kind & typemask)) + if (GOMP_MAP_COPY_FROM_P (kind & typemask)) /* Copy from device to host memory. */ devicep->dev2host_func (devicep->target_id, (void *) cur_node.host_start, @@ -826,8 +824,9 @@ gomp_fini_device (struct gomp_device_descr *devicep) } /* Called when encountering a target directive. If DEVICE - is -1, it means use device-var ICV. If it is -2 (or any other value - larger than last available hw device, use host fallback. + is GOMP_DEVICE_ICV, it means use device-var ICV. If it is + GOMP_DEVICE_HOST_FALLBACK (or any value + larger than last available hw device), use host fallback. FN is address of host code, OFFLOAD_TABLE contains value of the __OFFLOAD_TABLE__ symbol in the shared library or binary that invokes GOMP_target. HOSTADDRS, SIZES and KINDS are arrays diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp index 9ee71c4..81545db 100644 --- libgomp/testsuite/lib/libgomp.exp +++ libgomp/testsuite/lib/libgomp.exp @@ -162,7 +162,7 @@ proc libgomp_init { args } { lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs" lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" - # The top-level include directory, for libgomp-constants.h. + # The top-level include directory, for gomp-constants.h. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include" } lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."