From patchwork Tue Jul 28 19:00:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 501450 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 C5F7E140E10 for ; Wed, 29 Jul 2015 05:00:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=j2UfUJ95; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=TKeRV4JQsCtgSxGX37u15wETsQP49IOOTOM3NBU37POOK9kcFo 3ZAuvdQ85bEwTKPY6DyzVXVfV1R9FF4H7ueHl0JSEqp863m08bQT4XBmIdkL7olU AIrcFlgFcTLn9bfRIra9RvWTbEg9EUss0F3xQ3MNox6Dtwnaefbk6IUcU= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=ObBmGyeIcPtLOSMaglKf6GruYiU=; b=j2UfUJ95hN9nH9PmgewJ ds2DykV8rvKOAc/o943HdzRhp2gN/ZJuDnrm5Lj/az3M/3vS2iO6Nw8igRqp0Sjf GN6poUgNscA3eQeHWDVrWnFHxSN8oGXa+wjzmofmFeHFhr9IodYzFZuol7MbgakV e6NUUI8gKaEOpfFBBgXJiSA= Received: (qmail 13007 invoked by alias); 28 Jul 2015 19:00:12 -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 12994 invoked by uid 89); 28 Jul 2015 19:00:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_40, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qk0-f173.google.com Received: from mail-qk0-f173.google.com (HELO mail-qk0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 28 Jul 2015 19:00:09 +0000 Received: by qkdv3 with SMTP id v3so55143648qkd.3 for ; Tue, 28 Jul 2015 12:00:07 -0700 (PDT) X-Received: by 10.55.20.72 with SMTP id e69mr52590578qkh.63.1438110007215; Tue, 28 Jul 2015 12:00:07 -0700 (PDT) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id x137sm11759197qkx.28.2015.07.28.12.00.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jul 2015 12:00:06 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [gomp4] unify open acc level constants Message-ID: <55B7D134.2070302@acm.org> Date: Tue, 28 Jul 2015 15:00:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 I've committed this to the gomp4 branch. It cleans up the existing OACC_foo constants defined in omp-low.h, replacing them with the ones I just defined in gomp-constants.h nathan 2015-07-28 Nathan Sidwell * omp-low.h (enum oacc_loop_levels): Delete. (OACC_LOOP_MASK): Delete. * omp-low.c: Change all OACC_x to GOMP_DIM_x * config/nvptx/nvptx.c: Change all OACC_x to GOMP_DIM_x * builtins.c (expand_oacc_id): Change OACC_HWM to GOMP_DIM_MAX. Index: gcc/config/nvptx/nvptx.c =================================================================== --- gcc/config/nvptx/nvptx.c (revision 226314) +++ gcc/config/nvptx/nvptx.c (working copy) @@ -1075,7 +1075,7 @@ void nvptx_expand_oacc_fork (rtx mode) { /* Emit fork for worker level. */ - if (UINTVAL (mode) == OACC_worker) + if (UINTVAL (mode) == GOMP_DIM_WORKER) emit_insn (gen_nvptx_fork (mode)); } @@ -2169,8 +2169,6 @@ nvptx_reorg_subreg () a NULL loop. We should be able to extend this to represent superblocks. */ -#define OACC_null OACC_HWM - struct parallel { /* Parent parallel. */ @@ -2369,7 +2367,7 @@ typedef auto_vec bb_par_vec_t; static parallel * nvptx_discover_pars (bb_insn_map_t *map) { - parallel *outer_par = new parallel (0, OACC_null); + parallel *outer_par = new parallel (0, GOMP_DIM_MAX); bb_par_vec_t worklist; basic_block block; @@ -2413,7 +2411,7 @@ nvptx_discover_pars (bb_insn_map_t *map) l = new parallel (l, mode); l->forked_block = block; l->forked_insn = end; - if (mode == OACC_worker) + if (mode == GOMP_DIM_WORKER) l->fork_insn = nvptx_discover_pre (block, CODE_FOR_nvptx_fork); } @@ -2428,7 +2426,7 @@ nvptx_discover_pars (bb_insn_map_t *map) gcc_assert (l->mode == mode); l->join_block = block; l->join_insn = end; - if (mode == OACC_worker) + if (mode == GOMP_DIM_WORKER) l->joining_insn = nvptx_discover_pre (block, CODE_FOR_nvptx_joining); l = l->parent; @@ -2706,7 +2704,7 @@ nvptx_single (unsigned mask, basic_block { /* If we're only doing vector single, there's no need to emit skip code because we'll not insert anything. */ - if (!(mask & OACC_LOOP_MASK (OACC_vector))) + if (!(mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR))) skip_mask = 0; } else if (tail_branch) @@ -2717,8 +2715,8 @@ nvptx_single (unsigned mask, basic_block /* Insert the vector test inside the worker test. */ unsigned mode; rtx_insn *before = tail; - for (mode = OACC_worker; mode <= OACC_vector; mode++) - if (OACC_LOOP_MASK (mode) & skip_mask) + for (mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++) + if (GOMP_DIM_MASK (mode) & skip_mask) { rtx id = gen_reg_rtx (SImode); rtx pred = gen_reg_rtx (BImode); @@ -2728,7 +2726,7 @@ nvptx_single (unsigned mask, basic_block rtx cond = gen_rtx_SET (pred, gen_rtx_NE (BImode, id, const0_rtx)); emit_insn_before (cond, head); rtx br; - if (mode == OACC_vector) + if (mode == GOMP_DIM_VECTOR) br = gen_br_true (pred, label); else br = gen_br_true_uni (pred, label); @@ -2746,7 +2744,7 @@ nvptx_single (unsigned mask, basic_block { rtx pvar = XEXP (XEXP (cond_branch, 0), 0); - if (OACC_LOOP_MASK (OACC_vector) == mask) + if (GOMP_DIM_MASK (GOMP_DIM_VECTOR) == mask) { /* Vector mode only, do a shuffle. */ emit_insn_before (nvptx_gen_vcast (pvar), tail); @@ -2806,7 +2804,7 @@ nvptx_skip_par (unsigned mask, parallel static unsigned nvptx_process_pars (parallel *par) { - unsigned inner_mask = OACC_LOOP_MASK (par->mode); + unsigned inner_mask = GOMP_DIM_MASK (par->mode); /* Do the inner parallels first. */ if (par->inner) @@ -2817,15 +2815,15 @@ nvptx_process_pars (parallel *par) switch (par->mode) { - case OACC_null: + case GOMP_DIM_MAX: /* Dummy parallel. */ break; - case OACC_vector: + case GOMP_DIM_VECTOR: nvptx_vpropagate (par->forked_block, par->forked_insn); break; - case OACC_worker: + case GOMP_DIM_WORKER: { nvptx_wpropagate (false, par->forked_block, par->forked_insn); @@ -2836,7 +2834,7 @@ nvptx_process_pars (parallel *par) } break; - case OACC_gang: + case GOMP_DIM_GANG: break; default:gcc_unreachable (); @@ -2855,30 +2853,30 @@ nvptx_process_pars (parallel *par) static void nvptx_neuter_pars (parallel *par, unsigned modes, unsigned outer) { - unsigned me = (OACC_LOOP_MASK (par->mode) - & (OACC_LOOP_MASK (OACC_worker) - | OACC_LOOP_MASK (OACC_vector))); + unsigned me = (GOMP_DIM_MASK (par->mode) + & (GOMP_DIM_MASK (GOMP_DIM_WORKER) + | GOMP_DIM_MASK (GOMP_DIM_VECTOR))); unsigned skip_mask = 0, neuter_mask = 0; if (par->inner) nvptx_neuter_pars (par->inner, modes, outer | me); - for (unsigned mode = OACC_worker; mode <= OACC_vector; mode++) + for (unsigned mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++) { - if ((outer | me) & OACC_LOOP_MASK (mode)) + if ((outer | me) & GOMP_DIM_MASK (mode)) { /* Mode is partitioned: no neutering. */ } - else if (!(modes & OACC_LOOP_MASK (mode))) + else if (!(modes & GOMP_DIM_MASK (mode))) { /* Mode is not used: nothing to do. */ } - else if (par->inner_mask & OACC_LOOP_MASK (mode) + else if (par->inner_mask & GOMP_DIM_MASK (mode) || !par->forked_insn) /* Partitioned in inner parallels, or we're not a partitioned at all: neuter individual blocks. */ - neuter_mask |= OACC_LOOP_MASK (mode); + neuter_mask |= GOMP_DIM_MASK (mode); else if (!par->parent || !par->parent->forked_insn - || par->parent->inner_mask & OACC_LOOP_MASK (mode)) + || par->parent->inner_mask & GOMP_DIM_MASK (mode)) /* Parent isn't a parallel or contains this paralleling: skip parallel at this level. */ - skip_mask |= OACC_LOOP_MASK (mode); + skip_mask |= GOMP_DIM_MASK (mode); else { /* Parent will skip this parallel itself. */ } } @@ -2936,8 +2934,8 @@ nvptx_reorg (void) parallel *pars = nvptx_discover_pars (&bb_insn_map); nvptx_process_pars (pars); - nvptx_neuter_pars (pars, (OACC_LOOP_MASK (OACC_vector) - | OACC_LOOP_MASK (OACC_worker)), 0); + nvptx_neuter_pars (pars, (GOMP_DIM_MASK (GOMP_DIM_VECTOR) + | GOMP_DIM_MASK (GOMP_DIM_WORKER)), 0); delete pars; Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 226314) +++ gcc/omp-low.c (working copy) @@ -2678,17 +2678,17 @@ scan_omp_for (gomp_for *stmt, omp_contex int val; if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_GANG) { - val = OACC_LOOP_MASK (OACC_gang); + val = GOMP_DIM_MASK (GOMP_DIM_GANG); gwv_clause = true; } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_WORKER) { - val = OACC_LOOP_MASK (OACC_worker); + val = GOMP_DIM_MASK (GOMP_DIM_WORKER); gwv_clause = true; } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_VECTOR) { - val = OACC_LOOP_MASK (OACC_vector); + val = GOMP_DIM_MASK (GOMP_DIM_VECTOR); gwv_clause = true; } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SEQ) @@ -2833,11 +2833,11 @@ scan_omp_target (gomp_target *stmt, omp_ for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) { if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_GANGS) - ctx->gwv_this |= OACC_LOOP_MASK (OACC_gang); + ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_GANG); else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_WORKERS) - ctx->gwv_this |= OACC_LOOP_MASK (OACC_worker); + ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_WORKER); else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_VECTOR_LENGTH) - ctx->gwv_this |= OACC_LOOP_MASK (OACC_vector); + ctx->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_VECTOR); } } @@ -3472,8 +3472,8 @@ gen_oacc_fork (gimple_seq *seq, unsigned { unsigned level; - for (level = OACC_gang; level != OACC_HWM; level++) - if (mask & OACC_LOOP_MASK (level)) + for (level = GOMP_DIM_GANG; level != GOMP_DIM_MAX; level++) + if (mask & GOMP_DIM_MASK (level)) { tree arg = build_int_cst (unsigned_type_node, level); gcall *call = gimple_build_call_internal (IFN_GOACC_FORK, 1, arg); @@ -3488,8 +3488,8 @@ gen_oacc_join (gimple_seq *seq, unsigned { unsigned level; - for (level = OACC_HWM; level-- != OACC_gang; ) - if (mask & OACC_LOOP_MASK (level)) + for (level = GOMP_DIM_MAX; level-- != GOMP_DIM_GANG; ) + if (mask & GOMP_DIM_MASK (level)) { tree arg = build_int_cst (unsigned_type_node, level); gcall *call = gimple_build_call_internal (IFN_GOACC_JOIN, 1, arg); @@ -4681,8 +4681,8 @@ expand_oacc_get_num_threads (gimple_seq tree decl = builtin_decl_explicit (BUILT_IN_GOACC_NID); unsigned ix; - for (ix = OACC_gang; ix != OACC_HWM; ix++) - if (OACC_LOOP_MASK(ix) & gwv_bits) + for (ix = GOMP_DIM_GANG; ix != GOMP_DIM_MAX; ix++) + if (GOMP_DIM_MASK(ix) & gwv_bits) { tree arg = build_int_cst (unsigned_type_node, ix); tree count = create_tmp_var (unsigned_type_node); @@ -4709,8 +4709,8 @@ expand_oacc_get_thread_num (gimple_seq * unsigned ix; /* Start at gang level, and examine relevant dimension indices. */ - for (ix = OACC_gang; ix != OACC_HWM; ix++) - if (OACC_LOOP_MASK (ix) & gwv_bits) + for (ix = GOMP_DIM_GANG; ix != GOMP_DIM_MAX; ix++) + if (GOMP_DIM_MASK (ix) & gwv_bits) { tree arg = build_int_cst (unsigned_type_node, ix); @@ -10047,11 +10047,11 @@ find_omp_for_region_gwv (gimple stmt) tree clauses = gimple_omp_for_clauses (stmt); if (find_omp_clause (clauses, OMP_CLAUSE_GANG)) - tmp |= OACC_LOOP_MASK (OACC_gang); + tmp |= GOMP_DIM_MASK (GOMP_DIM_GANG); if (find_omp_clause (clauses, OMP_CLAUSE_WORKER)) - tmp |= OACC_LOOP_MASK (OACC_worker); + tmp |= GOMP_DIM_MASK (GOMP_DIM_WORKER); if (find_omp_clause (clauses, OMP_CLAUSE_VECTOR)) - tmp |= OACC_LOOP_MASK (OACC_vector); + tmp |= GOMP_DIM_MASK (GOMP_DIM_VECTOR); return tmp; } @@ -10096,11 +10096,11 @@ find_omp_target_region_data (struct omp_ tree clauses = gimple_omp_target_clauses (stmt); if (find_omp_clause (clauses, OMP_CLAUSE_NUM_GANGS)) - region->gwv_this |= OACC_LOOP_MASK (OACC_gang); + region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_GANG); if (find_omp_clause (clauses, OMP_CLAUSE_NUM_WORKERS)) - region->gwv_this |= OACC_LOOP_MASK (OACC_worker); + region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_WORKER); if (find_omp_clause (clauses, OMP_CLAUSE_VECTOR_LENGTH)) - region->gwv_this |= OACC_LOOP_MASK (OACC_vector); + region->gwv_this |= GOMP_DIM_MASK (GOMP_DIM_VECTOR); region->kind = gimple_omp_target_kind (stmt); } @@ -11665,9 +11665,9 @@ oacc_init_count_vars (omp_context *ctx, tree getnid = builtin_decl_explicit (BUILT_IN_GOACC_NID); tree worker_var, worker_count; - if (ctx->gwv_this & OACC_LOOP_MASK (OACC_worker)) + if (ctx->gwv_this & GOMP_DIM_MASK (GOMP_DIM_WORKER)) { - tree arg = build_int_cst (unsigned_type_node, OACC_worker); + tree arg = build_int_cst (unsigned_type_node, GOMP_DIM_WORKER); worker_var = create_tmp_var (unsigned_type_node, ".worker"); worker_count = create_tmp_var (unsigned_type_node, ".workercount"); Index: gcc/omp-low.h =================================================================== --- gcc/omp-low.h (revision 226314) +++ gcc/omp-low.h (working copy) @@ -20,17 +20,6 @@ along with GCC; see the file COPYING3. #ifndef GCC_OMP_LOW_H #define GCC_OMP_LOW_H -/* Levels of parallelism as defined by OpenACC. Increasing numbers - correspond to deeper loop nesting levels. */ -enum oacc_loop_levels - { - OACC_gang, - OACC_worker, - OACC_vector, - OACC_HWM - }; -#define OACC_LOOP_MASK(X) (1 << (X)) - struct omp_region; extern tree find_omp_clause (tree, enum omp_clause_code); Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 226314) +++ gcc/builtins.c (working copy) @@ -5929,10 +5929,11 @@ expand_oacc_id (enum built_in_function f rtx arg; arg = expand_normal (arg0); - if (GET_CODE (arg) != CONST_INT || UINTVAL (arg) >= OACC_HWM) + + if (GET_CODE (arg) != CONST_INT || UINTVAL (arg) >= GOMP_DIM_MAX) { error ("argument to %D must be constant in range 0 to %d", - get_callee_fndecl (exp), OACC_HWM - 1); + get_callee_fndecl (exp), GOMP_DIM_MAX - 1); return result; }